how to add bring my own phone numbers(multiple pho...
# support
k
how to add bring my own phone numbers(multiple phonenumbers) using SIP trunking on vapi using api docs like create phonumber
v
Hi there! šŸ‘‹ I found information on how to add multiple phone numbers using SIP trunking on Vapi through their API. Here's how you can add your own phone numbers using SIP trunking on Vapi: ## Step 1: Create a SIP Trunk Credential First, you need to create a SIP Trunk Credential using the Vapi API:
Copy code
bash
curl -X POST https://api.vapi.ai/credential \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "provider": "byo-sip-trunk",
  "name": "My SIP Trunk",
  "gateways": [
    {
      "ip": "your.sip.provider.ip", 
      "port": 5060,
      "inboundEnabled": true,
      "outboundEnabled": true
    }
  ],
  "outboundAuthenticationPlan": {
    "authUsername": "your_outbound_username",
    "authPassword": "your_outbound_password",
    "sipRegisterPlan": {
      "realm": "your.sip.provider.domain",
      "username": "your_register_username",
      "domain": "your.sip.provider.domain",
      "publicIpInContactEnabled": false
    }
  }
}'
The response will return a credential ID that you'll need for the next step:
Copy code
json
{
  "id": "credential_id",
  "provider": "byo-sip-trunk",
  "name": "My SIP Trunk",
  ...
}
## Step 2: Add Phone Numbers to the SIP Trunk After creating the SIP trunk credential, you can add phone numbers by making API calls to the
/phone-number
endpoint. For each phone number you want to add, you'll need to make a separate API call:
Copy code
bash
curl -X POST https://api.vapi.ai/phone-number \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "provider": "byo-phone-number",
  "name": "Telnyx SIP Number",
  "number": "your-sip-phone-number",
  "numberE164CheckEnabled": false,
  "credentialId": "your-new-trunk-credential-id-which-you-got-from-previous-step"
}'
To add multiple phone numbers, simply repeat this API call for each phone number, using the same
credentialId
from Step 1 but different
number
values. ## Important Considerations
- When configuring SIP trunking, ensure your PBX is configured to handle SIP REFER messages, as Vapi uses these to transfer calls. - The transport protocol should be UDP and the hostname is
sip.vapi.ai
. - Vapi primarily supports US-based numbers, so check compatibility if you're using international numbers. - Make sure your telephony provider supports SIP trunking before attempting to configure it with Vapi. Is there anything specific about this process you'd like me to explain further? Sources: - [Discord Thread](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1341469652366266408) - [Vapi API Documentation](https://docs.vapi.ai/api-reference/phone-numbers/create) - [Vapi SIP Documentation](https://docs.vapi.ai/advanced/sip)
k
checking if this is resolved/solved for you?
i
Hi, we are also having trouble connecting to a BYO SIP Trunk. We have reviewed content of this support ticket but still getting 404 error.
Error logs:
This is request: curl -X POST "https://api.vapi.ai/api/v1/credential" \ -H "Authorization: Bearer XXXXXX" \ -H "Content-Type: application/json" \ -d '{"name":"Voxhero","provider":"core1-aus-bne.yabbit.com.aus","gateways":[{"ip":"43.247.67.73","port":5060,"inboundEnabled":true,"outboundEnabled":true}],"outboundLeadingPlusEnabled":true,"outboundAuthenticationPlan":{"authUsername":"XXX","authPassword":"XXXXXX}}' This is response: Vapi API error (POST /credential): Error [AxiosError]: Request failed with status code 404 •⁠ ⁠Theres some issues in how to sent the object data
can you please help @Kings_bigšŸ’« @Gilang
k
The 404 error you're seeing is likely due to using the wrong endpoint in your request— it should be "/credential" instead of "/api/v1/credential". Also, the authPassword value is missing a closing quotation mark in your JSON. Let me know if updating both of these fixes the problem.
i
Thank you so much, let me try that
curl -X POST "https://api.vapi.ai/credential" \ -H "Authorization: Bearer XXXX" \ -H "Content-Type: application/json" \ -d '{"name":"Testing","provider":"Voxhero","gateways":[{"ip":"43.247.67.73","port":5060,"inboundEnabled":true,"outboundEnabled":true},{"ip":"43.247.67.81","port":5060,"inboundEnabled":true,"outboundEnabled":true}],"outboundLeadingPlusEnabled":true,"outboundAuthenticationPlan":{"authUsername":"xxx","authPassword":"xxx","sipRegisterPlan":{"realm":"","username":"","domain":"sip*@yabbit.pstn.twilio.com","publicIpInContactEnabled":false}}}' Vapi API error (POST /credential): Error [AxiosError]: Request failed with status code 403
So we have a 403 error would that be due to client?
k
This can happen if you use the wrong key (such as a public key instead of a private key, or vice versa) or if the token is invalid or missing "Bearer" in the header. Make sure you are using the correct private key, formatted as "Bearer YOUR_VAPI_PRIVATE_KEY" in the Authorization header. Let me know. That should be the issue for 403. If not, let me know what happens.
g
If use PublicKey: Error 403 If use PrivateKey: Error 400 @Mason Doberstein @ivy . Private key is correct. I think issues is in body requests
Just want to check, is this Create a SIP Trunk Credential request is working? I always got error 400 Bad Request without feedback what wrong or what missing ? @Mason Doberstein @ivy
k
This ticket has been marked as solved, and as a result, you will no longer receive any further responses. Kindly create a new support ticket to escalate your inquiry.Ā