Voice API with SIP routing and carrier registration
Back to Articles
VoIP SIP Routing API Javascript Howto

Voice API with SIP routing and carrier registration

May 8, 2018 2 min
Aivis Olsteins

Aivis Olsteins

In previous API post we discussed how to send automated voice call and play prerecorded or text to speech messages to multiple recipients at once and get results report. Now we will discuss how to set some more advanced SIP attributes in case they are required.

Let's start with setting some default parameters by carrier. In our sample case we will have Carrier1 which should be set with following attributes:

  1. Hostname: sip.carrier1.com
  2. Prefix: 8888
  3. Codecs accepted: G711 ulaw and alaw
  4. Registration not required

And Carrier2 with these attributes:

  1. IP address: 10.2.2.22
  2. Prefix: None
  3. Codecs accepted: G711 ulaw and alaw, G.729 and G.723
  4. Registration required.
  5. Registration username: client1
  6. Registration password: password1

Here is the request to set up carrier1:

POST /carriers
{
"name" : "carrier 1",
"host" : "sip.carrier1.com",
"protocol" : "SIP",
"prefix" : "8888",
"codecs" : ["mulaw", "alaw"],
"register" : false
}

Response will be like:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "63afc352-21ce-4a42-8b70-7ed8f994d5b7",
"carrier_id": "d49d1f1e"
}

As this carrier does not require registration, there is no action taken on the SIP level, so we do not need to have any further action.

Setting up Carrier2 now:

POST /carriers
{
"name" : "carrier 2",
"host" : "10.2.2.2",
"protocol" : "SIP",
"codecs" : ["mulaw", "alaw", "g729", "g723"],
"register" : true,
"username" : "client1",

}

Response:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "ddb8cefc-e310-4784-b8ac-aacfb1b79f1d",
"carrier_id": "74445609"
}

This carrier requires registration. We may want to check if the registration was successful or not. We will take carrier ID from the system and check if registration succeeded.

GET /status/carrier/74445609

will respond:

{
"code": 0,
"status": 200,
"data": "accepted",
"request_id": "ddb8cefc-e310-4784-b8ac-aacfb1b79f1d",
"result" : {
"sip_registration": "registered"
}
}

We can and perhaps should perform this action on the regular basis if we want to be sure that SIP registration still exists.

 

Now, when we have several carriers set up, our call requests become a bit simpler. Instead of full SIP URL in the destination field, we can just send called party number (numerical part only) and the system will create proper SIP URI before making SIP call. We should include Carrier ID returned to us in carrier setup API calls.

POST /voice/call/play

{
"to": "123456",
"from": "me",
"playlist":
[
{
"play": "http://server.domain.com/voices/hello.wav"
},
{
"play": "http://server.domain.com/voices/main-message.wav"
},
{
"play": "http://server.domain.com/voices/goodbye-thanks.wav"
}
]
"carrier_id" : "74445609"
}

Therefore we have now functional routing set up, we are able to send calls to the carrier of our choice. Next we will discuss how to offload decision of routing from our application and set up more advanced routing scenario.

Share this article

Aivis Olsteins

Aivis Olsteins

An experienced telecommunications professional with expertise in network architecture, cloud communications, and emerging technologies. Passionate about helping businesses leverage modern telecom solutions to drive growth and innovation.

Related Articles

How Voice AI Reduces Agent Burnout and Boosts Satisfaction

How Voice AI Reduces Agent Burnout and Boosts Satisfaction

Reduce Burnout with Voice AI: Offload Repetitive Calls, Real‑Time Agent Assist, 40–80% Less ACW, Calmer Escalations, Healthier Occupancy, Proactive Deflection & PCI‑Safe Flows—Happier Agents, Faster Resolutions, Better Coaching, Faster Ramp

Read Article
Seamless Voice AI Integrations: Salesforce, HubSpot, and ERP Systems

Seamless Voice AI Integrations: Salesforce, HubSpot, and ERP Systems

Seamless Voice AI Integrations with Your Stack: Salesforce & HubSpot CRM + SAP/Oracle/NetSuite/Dynamics ERP; OAuth2 & mTLS Security; Real‑Time Read/Write (Cases, Orders, Payments, Scheduling); Warm Transfers, Context; Audit Logs, SLAs, iPaaS Support

Read Article
Measuring Voice AI Success: The KPIs That Matter—CSAT, Containment, Speed, Accuracy, Reliability, and ROI

Measuring Voice AI Success: The KPIs That Matter—CSAT, Containment, Speed, Accuracy, Reliability, and ROI

Voice AI KPI Scorecard: CSAT/NPS, FCR & Containment, Time‑to‑First‑Word & p95 Latency, Intent/Slot Accuracy & ASR WER, Groundedness, Tool Success (Payments/IDV/Scheduling), Warm Xfers, Uptime/Reliability, Consent/Redact, Cost per Resolution & ROI

Read Article
Sensitive Data in Voice AI: PCI‑Safe Payments, HIPAA‑Compliant PHI, Redaction & Tokenization

Sensitive Data in Voice AI: PCI‑Safe Payments, HIPAA‑Compliant PHI, Redaction & Tokenization

Managing Sensitive Data in Voice AI: PCI‑Safe Payments (DTMF Masking, Tokenization), HIPAA‑Compliant PHI Segregation, Redaction/De‑Identification, End‑to‑End Encryption, Zero‑Trust Access, Residency/Retention, DSAR Deletion, SIEM‑Audited Trails

Read Article

SUBSCRIBE TO OUR NEWSLETTER

Stay up to date with the latest news and updates from our telecom experts