Bug with API and SIP Trunking
# support
k
Cost me whole day to figure out. When I create a SIP connection in VAPI and add a number to it. It works. If I delete the number from VAPI and add it again it keeps throwing 400 error. I have to create a new SIP connection and add that number there before it works again. Am I doing something wrong or is this really a bug
v
Hi there! Based on the documentation I've found, what you're experiencing appears to be a known issue with VAPI's SIP Trunking functionality 🔍 There are indeed documented bugs within VAPI that affect SIP Trunk operations, particularly causing 400 Bad Request errors in scenarios similar to what you're describing. This isn't necessarily something you're doing wrong. The issue might be related to how VAPI handles the deletion and re-addition of numbers to existing SIP connections. Several users have reported similar problems with 400 errors when modifying SIP trunk configurations. Your workaround of creating a new SIP connection and adding the number there is actually in line with what others have found to work. This suggests there may be some state persistence issue with deleted numbers in the VAPI system. Some potential causes for these 400 errors include: 1. Malformed payload in the API request (such as including properties that shouldn't be there) 2. Incorrect SIP URI formatting 3. Issues with how VAPI handles previously deleted resources If you need to continue working with this setup, I'd recommend: 1. Following your current workaround of creating a new SIP connection 2. Ensuring your API requests don't include unnecessary properties (like
credentials
if not required) 3. Double-checking the formatting of your SIP URIs Would you like me to provide more specific configuration recommendations to help minimize these issues in the future? Sources: - [Discord discussion about SIP Trunking issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333747605628391434) - [Discord discussion about API limitations](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1334060872087375872) - [Discord discussion about SIP connection management](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333687712399680801)
k
@Vapi Support Bot the urls dont work so what is best way to make sure this doesnt happen
v
I understand those URLs aren't working for you. Let me share the best practices to prevent this issue from happening again 🛠️ Based on the documentation I've found, here are specific steps to minimize 400 errors when managing SIP connections in VAPI: 1. **Proper SIP Trunk Configuration**: - When creating a SIP trunk, use this recommended JSON format:
Copy code
json
   {
     "provider": "byo-sip-trunk",
     "name": "BYOC Trunk",
     "gateways": [
       {
         "ip": "YourStaticIP",
         "port": YourStaticPort,
         "netmask": 32,
         "inboundEnabled": true,
         "outboundEnabled": true,
         "outboundProtocol": "udp"
       }
     ]
   }
2. **Avoid Including Unnecessary Properties**: - A common cause of 400 errors is including properties that shouldn't be there - Specifically, don't include the
credentials
property if not required 3. **Correct SIP URI Formatting**: - When setting up the
sipUri
attribute in the
forwardingPhoneNumbers
array, ensure it's properly formatted:
Copy code
json
   {
      "forwardingPhoneNumbers": [
         {
            "sipUri": "sip:user@domain.com"
         }
      ]
   }
4. **Continue Using Your Workaround**: - Your approach of creating a new SIP connection when re-adding numbers is currently the most reliable solution - This suggests there's a state persistence issue with deleted numbers in VAPI 5. **Network Configuration**: - Ensure your firewalls allow SIP traffic to your VAPI trunk - Use VAPI's relevant IP addresses for SIP traffic, avoiding direct IP routing These steps should help minimize the occurrence of 400 errors when managing your SIP connections in VAPI 👍 Sources: - [Discord discussion about SIP Trunking issues](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/1333747605628391434) - [Discord discussion about API limitations](https://discord.com/channels/1211482211119796234/1211483291191083018/threads/2342587463456567)
n
@kitkat Can you provide cURL based samples? I'm not a VAPI employee, but have extensive experience in this tool, so I may be able to shed some light on the matter.
k
Hello Kitkat, thank you for bringing this to our attention. Could you do me a favor and report this bug over at: