Call disconnected
# support
v
Please check why for the SIP trunk "id": "e571def4-2e7e-447c-9753-02ffedaef962", Assiciated phone number with sip trunk "id": "74cfc695-9cbb-49cd-baae-5b9d3e7359da", "orgId": "289e9a2a-f610-4141-8aff-3c9ad3891cee", "number": "+98765432111", I am getting SIP 401 Unauthorized while calling as INVITE sip:+98765432111@sip.vapi.ai;transport=UDP SIP/2.0 Via: SIP/2.0/UDP 167.172.153.212:5060;branch=z9hG4bKdd46.12392504.0 Max-Forwards: 69 Contact: To: From: 77777777777777 ;tag=f43c8e53 Call-ID: Y05cpzN-jKKJcKHDzvJtbw.. CSeq: 1 INVITE Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE Content-Type: application/sdp Allow-Events: presence, kpml, talk Content-Length: 682
v
Hi there! I see you're getting a SIP 401 Unauthorized error when trying to make calls through your Vapi SIP trunk. Let me help you troubleshoot this 🔍 The 401 error is occurring because your initial INVITE request is missing the required authentication credentials. Looking at your INVITE message, I don't see an
Authorization
header, which is required by Vapi for SIP authentication. Here's how to resolve this: 1. **Understanding the authentication flow**: - When you send an initial INVITE without credentials, Vapi responds with a 401 Unauthorized - This response includes a
WWW-Authenticate
header with a
nonce
value - You need to resend your INVITE with a proper
Authorization
header that includes this nonce [source](https://discord.com/channels/1211482211119796234/1211483291191083018/1334238882660618250) 2. Add the Authorization header to your second INVITE request:
Copy code
Authorization: Digest username="YourUsername",
      realm="sip.vapi.ai",
      nonce="received_nonce_value",
      uri="sip:+98765432111@sip.vapi.ai",
      response="calculated_md5_hash"
3. Ensure your SIP trunk credentials are correctly configured in Vapi. Check that the username and password in your configuration match what you're using in the Authorization header [source](https://discord.com/channels/1211482211119796234/1211483291191083018/1333747605628391434). 4. **Verify network configuration**: Make sure your firewall allows SIP traffic and there are no NAT issues disrupting SIP messages [source](https://discord.com/channels/1211482211119796234/1211483291191083018/1334919245468799007). Let me know if you need more specific guidance on calculating the MD5 hash for the response value or if you continue to experience issues after implementing these changes! Sources: - [SIP 401 Unauthorized Error Discussion](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334238882660618250)
s
@Vladimir Marking this ticket as a duplicate and closing it.