Book Image

Twilio Best Practices

Book Image

Twilio Best Practices

Overview of this book

Table of Contents (15 chapters)
Twilio Best Practices
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with phone numbers, accounts, and usage


Now that we've looked at the core resources of the REST API—the Call and the Message—let's get to grips with some other interesting and useful parts.

Phone numbers

In the API, phone numbers are encapsulated into a number of different types of resources: the AvailablePhoneNumber, the IncomingPhoneNumber, the OutgoingCallerId, and the ShortCode.

Here, we're going to focus on dealing with numbers we'll actually buy through Twilio with AvailablePhoneNumber and IncomingPhoneNumber, but we'll briefly cover the remaining two.

We can purchase phone numbers via our Twilio Dashboard, but there are plenty of use cases where we might want to do this via the API, for instance, where we want to offer on-demand phone numbers to our users.

To get started, let's check what phone numbers are available for purchase by working with the AvailablePhoneNumber API.

To start, let's find an SMS-capable number in California, containing 123. To do this directly with the REST...