How do i set the server URL for a phone number?
# support
s
How do i set the server URL for a phone number?
v
@slickVik To set the server URL for a phone number, you'll need to provide the URL that will handle the incoming calls for that number. This URL should be a server endpoint that is prepared to receive and process the call object and other relevant information. If you have the server URL ready, you can update the settings for your phone number with that URL. If you're using an API or a specific platform to manage your phone numbers, there would typically be an option or a method to set or update the server URL. Could you please provide me with the server URL you wish to set for your phone number? Once I have that information, I can assist you further.
You can continue this conversation by mentioning me in the message.
s
@slickVik You have to make a UPDATE /phone-number/:id request and assign server url to it using the following url
Example Curl Request
Copy code
sh
curl -X PATCH https://api.vapi.ai/phone-number/insert-phone-number-id-here \
     -H "Authorization: Bearer insert-token-here" \
     -H "Content-Type: application/json" \
     -d '{
  "provider": "twilio",
  "server": {
    "url": "insert-your-server-url-here",
    "timeoutSeconds": 0,
    "secret": "",
    "headers": {}
  }
}'
Reference: https://docs.vapi.ai/api-reference/phone-numbers/list?playground=%2Fapi-reference%2Fphone-numbers%2Fupdate
s
@Shubham Bajaj It looks like it uses the organization server url even if it set this. Is that expected?
s
@slickVik Org level server url is only used if you don't set the phone-number server url, could you share the call id?
s
462910e9-90b8-450f-aada-5d5f5eaa5a6b
@Shubham Bajaj
I am getting a 502 error for some reason
{"message":{"timestamp":1737475104361,"type":"status-update","status":"ended","endedReason":"call-start-error-neither-assistant-nor-server-set","inboundPhoneCallDebuggingArtifacts":{"error":"Couldn't Get Assistant. Either Set The Assistant I D On The Phone Number. Or, To Debug Your Assistant Request, Check The Debugging Artifacts That Were Just Sent To Your Server.","assistantRequestError":"Couldn't Start Call. Need Assistant ID Or Server URL Set."},"call":{"id":"a528ffaa-0167-433a-8456-a82e446648a1","orgId":"0e718d64-ce03-43ca-8b08-2f38bd383ef3","createdAt":"2025-01-21T15:58:24.230Z","updatedAt":"2025-01-21T15:58:24.230Z","type":"inboundPhoneCall","status":"ringing","phoneCallProvider":"twilio","phoneCallProviderId":"CAb3311bdb2833b854ab99484ed5c7ca96","phoneCallTransport":"pstn","phoneNumberId":"c79c0558-9bca-4780-84a9-f29bc9b68913","assistantId":null,"squadId":null,"customer":{"number":"+17753609450"}},"phoneNumber":{"id":"c79c0558-9bca-4780-84a9-f29bc9b68913","orgId":"0e718d64-ce03-43ca-8b08-2f38bd383ef3","assistantId":null,"number":"+15128557039","createdAt":"2025-01-20T18:06:26.312Z","updatedAt":"2025-01-20T18:22:33.029Z","stripeSubscriptionId":null,"twilioAccountSid":"AC3cff006beb9767752d8e58846123d5b1","twilioAuthToken":"0b495d52d75b0c6db5c1c56139fde145","stripeSubscriptionStatus":null,"stripeSubscriptionCurrentPeriodStart":null,"name":"Demo","credentialId":null,"serverUrl":null,"serverUrlSecret":null,"twilioOutgoingCallerId":null,"sipUri":null,"provider":"twilio","fallbackForwardingPhoneNumber":null,"fallbackDestination":null,"squadId":null,"credentialIds":null,"numberE164CheckEnabled":null,"authentication":null,"server":{"url":"https://6f87-2603-8080-2700-ef3-927-ac9a-6a2b-1b5f.ngrok-free.app/api/agent","secret":"","headers":{},"timeoutSeconds":20}},"customer":{"number":"+17753609450"}}}
I am seeing the error is "Couldn't Start Call. Need Assistant ID Or Server URL Set."
@malik
s
@slickVik You need to pass either a phone number, server URL, or assistant ID to start the calls, otherwise they will fail. You can view debugging artifacts in the ngrok tracing dashboard on port 4040 or 4000.
s
So i set the server URL in the assistant with the curl request above, I am seeing that its hitting the endpoint.
@Shubham Bajaj
The endpoint is returning 200, but still the same message as above
Do I need to set it anywhere else?
s
@slickVik First, you need to set the server URL for your phone number. After that, Vapi will send a request asking which assistant should be used. At that point, you need to return the assistant ID you want to use. You are currently doing this in the opposite order. Correct me if wrong.
s
const response: ServerMessageResponseAssistantRequest = { assistant: VOX_AGENT(agentContext, transferNumber), }; return { status: 200, body: JSON.stringify(response), };
I am returning the assistant itself
I've already set the server url for the phone number via the curl request
@Shubham Bajaj
s
Hey are there any updates on this? I am getting the same issue.
s
@slickVik @santi_racca I understand that you might be sending the wrong assistant, which is causing this error. To identify the exact issue, please check your server URL where we send the debugging artifacts. These artifacts contain self-explanatory information about what's missing in your assistant or why your response was incorrect. I cannot check this for you because I don't have access, so please review the debugging artifacts yourself. At most, I can look at your assistant JSON to verify if it's valid. Please let me know your thoughts on this.
s
Hey @Shubham Bajaj the debugging artifact shows that I have set the server url to the right endpoint. I am returning a correct assitant because when I use the org level server url it works fine. It seems there is an issue with setting the server url with the new schema
s
@santi_racca Could you send me a copy of debugging artifacts and your orgId so I can share this with the team and get it resolved? Also, could you rephrase or help me understand the meaning of "issue with setting the server URL with the new schema"? I couldn't understand it completely.
s
Yes the thing is it works if I add the url at the org level, but once I remove it, it stops working. @shubham.bajaj
Looks like @santi_racca is facing the same issue
s
@slickVik @santi_racca can you both guys can share the debugging artifacts let me investiage.
@slickVik @santi_racca Refrain from publicly sharing your credentials and tokens, as this could compromise your security. I have removed your message for the time being. Please exercise caution in the future. cc: @John George
j
you should also revoke your old Twilio Auth Token and use a new one in case it was compromised
s
Hey Shubham, which credentials were leaked? @Shubham Bajaj
j
your Twilio auth token
s
Was this recent or when was it sent?
@John George we rotate every 14 days, but was the initial message sent a few months ago ago?
j
good practice, yes it would have been in Jan
k
checking if this is resolved/solved for you?
3 Views