Skip to main content
POST
JavaScript

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

account_id
string
required

The account for which the phone number should be created.

Example:

"acct_01j9a43avnfqzbjfch6pygv1td"

Body

application/json

Parameters for purchasing a new phone number. The system will automatically infer the type in certain cases:

  • If only area_code is provided, type is inferred from the area code
  • If only latitude/longitude are provided, type is inferred as 'local'
  • Otherwise, type must be explicitly specified

If phone_number is provided, all other search parameters are ignored.

area_code
string

The desired area code for this phone number. If provided without type, the type will be inferred.

Pattern: ^\d{3}$
Example:

"801"

latitude
number

Latitude to search for nearby phone numbers. Must be used with longitude. If provided without type, type will be inferred as 'local'.

Required range: -90 <= x <= 90
Example:

40.7128

longitude
number

Longitude to search for nearby phone numbers. Must be used with latitude. If provided without type, type will be inferred as 'local'.

Required range: -180 <= x <= 180
Example:

-74.006

name
string

A human-readable name for the phone number. If not provided, defaults to the formatted phone number.

Example:

"Support Line"

phone_number
string<phone-number>

The exact phone number to purchase in E.164 format. When provided, all other search parameters are ignored.

Pattern: ^\+[1-9]\d{6,14}$
Example:

"+18015551234"

type
enum<string>

Whether the phone number is local or toll-free. Can be omitted if area_code or latitude/longitude are provided.

Available options:
local,
toll_free
Example:

"local"

Response

Purchased phone number

A phone number that can be used to send and receive messages and calls

campaign
PhoneNumberCampaign · object | null
required

Campaign attachment details for domestic local numbers, or null for other types of numbers and local numbers without a campaign

Example:
campaign_id
string | null
required
deprecated

Deprecated. The unique identifier of the campaign this phone number is attached to, if any

id
string
required

Unique identifier for the phone number

name
string | null
required

A human-readable name for the phone number

number
string<phone-number>
required

The phone number in E.164 format

Pattern: ^\+[1-9]\d{6,14}$
Example:

"+18015551234"

type
enum<string>
required

Whether the phone number is local, toll-free, or short code

Available options:
local,
short_code,
toll_free