SIP Direct endpoint responds 401 Unauthorized to i...
# support
e
Issue: SIP Direct endpoint responds 401 Unauthorized to inbound INVITE We have a Free SIP endpoint sip:lidia-pbx@sip.vapi.ai assigned to assistant Lidia. Our PBX (Asterisk/MirtaPBX at IP 172.104.244.8) sends a clean INVITE to sip.vapi.ai:5060/UDP. Vapi responds: SIP/2.0 100 Trying SIP/2.0 401 Unauthorized WWW-Authenticate: Digest realm="sip.vapi.ai", algorithm=MD5, qop="auth", nonce="..." We also created a BYO SIP Trunk credential with our IP whitelisted (172.104.244.8, no username/password), but it does not affect SIP Direct behavior. We need to preserve the original caller ID (From/PAI/RPID) from the transferred call, which is why we cannot use a BYO Phone Number. Please advise: How do we authenticate against SIP Direct? Is there a username/password we should use? Can our IP be whitelisted so the 401 challenge is skipped? Is there another way to route inbound SIP to an assistant while preserving caller ID? Attached: pcap file showing the full SIP exchange. https://cdn.discordapp.com/attachments/1497665407488753738/1497665408147390546/vapi.pcap?ex=69ee591a&is=69ed079a&hm=64cf3369921fbd7c11197d56c636fad7e930943b93c66757f9e4e1f5af8472a3&
m
That 401 is expected SIP Direct on Vapi requires Digest authentication, so your PBX needs to resend the INVITE with proper auth headers (username/password tied to the SIP endpoint). IP whitelisting alone won’t bypass the challenge. To preserve caller ID, you can still pass PAI/RPID headers once authenticated, no need for a phone number if configured correctly. I’ve handled similar Asterisk setups and can help you get this working cleanly. Quick one: are you currently retrying the INVITE with auth after the 401, or is it stopping there? @Estefan
c
Hi, Here’s an example to clarify the correct SIP URI format: Incorrect:
lidia-pbx@sip.vapi.ai
Correct:
lidia-pbx@<your_credential_id>.sip.vapi.ai
Why this matters: The generic
sip.vapi.ai
endpoint doesn’t reliably map requests to your specific credentials, which can lead to intermittent or inconsistent behavior. Using
<your_credential_id>.sip.vapi.ai
ensures the request is routed through your exact configuration every time, making it stable and predictable. ref: https://docs.vapi.ai/advanced/sip/sip-trunk