Create Phone Number API Request Error
# support
m
Create Phone Number API Request returns no phone number and is inaccessible on dashboard without errors(see image) I get this error when trying to even view the created number in dashboard: Error: TypeError Message: A phone number must either be a string or an object of shape { phone, [country] }. Timestamp: 2025-09-05T14:37:59.951Z I can get the phone fine with the API but once again it has no phone number. When creating phone number my body contains only: {provider: "vapi"} https://cdn.discordapp.com/attachments/1413534127503708170/1413534128372060252/image.png?ex=68bc47be&is=68baf63e&hm=e6534f3603e7d4706f85146a7a040b6876abe8f45b684cf16b891d7495f4b8ad&
d
Have you tried it creating using Dashboard
m
It works perfect via dashboard but my Saas requires the ability to create assistants, create phone numbers, and auto-attatch them to the assistants.
c
Hi Mornz, To create a phone number using the API, make a POST request to
https://api.vapi.ai/phone-number
with the necessary headers and data. Here's a sample cURL command for creating a phone number:
Copy code
bash
curl -X POST https://api.vapi.ai/phone-number \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{
  "provider": "byo-phone-number",
  "credentialId": "string"
}'
Ensure you replace
<token>
with your actual authentication token and fill in the required fields such as
credentialId
. For more details, you can refer to the [Create Phone Number documentation](https://docs.vapi.ai/api-reference/phone-numbers/create).
m
my request looks like this, it still does not work.: curl -X POST https://api.vapi.ai/phone-number \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "provider": "vapi", }'
c
You will also need the credentialId from the SIP Trunk creation. Without the SIP Trunk association, you will not be able to create a phone number through the API
j
And how we can get that?
c
When creating a phone number through the API, use the /credential endpoint. An example payload is on this page: https://docs.vapi.ai/advanced/sip/sip-trunk#create-a-sip-trunk-credential-in-vapi The above instructions are for creating credentials for BYO SIP trunks. If you want to create a VAPI free number through the API, please just use the dashboard for now.
3 Views