Buy phone number removed?
# support
r
Hi I can't find buy phone number API?
v
@rob Hello! It looks like you're trying to find the API for purchasing a phone number. You can use the following API endpoint to buy a phone number:
Copy code
plaintext
POST https://api.vapi.ai/phone-number/buy
You'll need to provide the necessary details such as
areaCode
,
name
,
assistantId
, and
serverUrl
in the request body. Here's an example of how you can make the request using cURL:
Copy code
bash
curl --request POST \
  --url https://api.vapi.ai/phone-number/buy \
  --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "areaCode": "YOUR_DESIRED_AREA_CODE",
    "name": "YOUR_PHONE_NAME",
    "assistantId": "YOUR_ASSISTANT_ID",
    "serverUrl": "YOUR_SERVER_URL"
  }'
Make sure to replace
YOUR_ACCESS_TOKEN
,
YOUR_DESIRED_AREA_CODE
,
YOUR_PHONE_NAME
,
YOUR_ASSISTANT_ID
, and
YOUR_SERVER_URL
with your actual credentials and desired values. If you need further assistance or have any questions, feel free to ask!
You can continue this conversation by mentioning me in the message.
r
@Vapi what's the proper syntax for the area code?
v
@rob The proper syntax for the
areaCode
is a string that represents the specific geographic region you're interested in. Typically, an area code is a sequence of digits. In the United States, for example, an area code is a three-digit number that precedes the local phone number. When you're using the API to buy a phone number, you should provide the area code without any additional characters or spaces. Here's an example of how you might format it:
Copy code
json
{
  "areaCode": "415"
}
In this example, "415" is the area code for San Francisco. Make sure to replace "415" with the area code that you're interested in purchasing a phone number from. If you have a specific area code in mind, please provide it, and I can assist you further.
s
@rob the phone number API is not public, instead you have to purchase numbers from dashboard only for now.
r
Should I not be using it? Is there a way to automate number creation? Maybe buy and setup with Twilio api then import to Vapi via API?
I used it yesterday successfully in testing, I will stop if it’s not allowed of course
@Shubham Bajaj
Please confirm if this is the case, if I cannot use the buy number API from Vapi my plan is to do this: Twilio offers APIs that allow you to search for and purchase phone numbers directly through their platform. Once purchased, you can manage and integrate those numbers with Vapi through the Twilio API. How to Buy a Phone Number Using Twilio API Twilio’s Phone Numbers API allows you to: 1. Search for available numbers. 2. Purchase a phone number that meets your criteria. 3. Configure the number for call forwarding, messaging, etc. Key Endpoints for Buying a Phone Number: 1. Search for Available Numbers GET https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/AvailablePhoneNumbers/{CountryCode}/Local.json • This endpoint searches for local phone numbers in a specific country. 2. Purchase a Phone Number POST https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/IncomingPhoneNumbers.json • This endpoint allows you to buy a number by passing the phone number you selected from the search. Example Workflow: 1. Search for a Number: curl -X GET "https://api.twilio.com/2010-04-01/Accounts/ACXXXXX/AvailablePhoneNumbers/US/Local.json?AreaCode=415" \ --user 'ACXXXXX:YourAuthToken' 2. Purchase the Number: curl -X POST "https://api.twilio.com/2010-04-01/Accounts/ACXXXXX/IncomingPhoneNumbers.json" \ --data-urlencode "PhoneNumber=+14155551234" \ --user 'ACXXXXX:YourAuthToken' After Purchasing: • The phone number will appear in your Twilio account. • You can then pass the Twilio SID and Auth Token to Vapi using their API to import and manage the number. In Vapi’s API: { "provider": "twilio", "twilioAccountSid": "ACXXXXX", "twilioAuthToken": "YourAuthToken", "number": "+14155551234" }
Please confirm if this is the case, if I cannot use the buy number API from Vapi my plan is to do this^
s
@rob sorry my bad you can purchase numbers using API from twilio directly, here's the link to it https://docs.vapi.ai/api-reference/phone-numbers/create?playground=%2Fapi-reference%2Fphone-numbers%2Fcreate
2 Views