Skip to content

Make your first call

This walkthrough places a call to your phone and reads a message to you. You need:

  • an account and its Auth ID and Auth Secret (Authentication);
  • a SIPRTC number, or a verified caller ID, to call from;
  • a phone to call to.
Terminal window
export SIPRTC_AUTH_ID=MA0000000000000000AB # yours
export SIPRTC_AUTH_SECRET=your-auth-secret

The quickest way to try voice is to send the call’s instructions with the request. TinyML is SIPRTC’s XML call-control language; this document speaks a sentence and hangs up.

Terminal window
curl -u "$SIPRTC_AUTH_ID:$SIPRTC_AUTH_SECRET" \
-H 'Content-Type: application/json' \
"https://api.siprtc.io/v1/Accounts/$SIPRTC_AUTH_ID/Calls" \
-d '{
"From": "+15550100001",
"To": "+15550100002",
"TinyML": "<Response><Say>Hello from SIPRTC. Goodbye.</Say><Hangup/></Response>"
}'

The response is the new call resource. Keep its call SID: you use it to change or end the call, and every callback about the call carries it.

Real applications decide what to do at the moment the call connects. Instead of TinyML, pass Url: SIPRTC requests that URL when the call is answered and executes the TinyML your server returns.

Terminal window
curl -u "$SIPRTC_AUTH_ID:$SIPRTC_AUTH_SECRET" \
-H 'Content-Type: application/json' \
"https://api.siprtc.io/v1/Accounts/$SIPRTC_AUTH_ID/Calls" \
-d '{
"From": "+15550100001",
"To": "+15550100002",
"Url": "https://example.com/voice/answer",
"StatusCallback": "https://example.com/voice/status"
}'

A minimal answer handler in Node.js:

import http from 'node:http';
http.createServer((req, res) => {
if (req.url.startsWith('/voice/answer')) {
res.writeHead(200, { 'Content-Type': 'application/xml' });
res.end(`<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather action="https://example.com/voice/menu" numDigits="1">
<Say>Press 1 for sales, or 2 for support.</Say>
</Gather>
</Response>`);
return;
}
res.writeHead(204).end();
}).listen(8080);

To handle calls to your number, create an application whose voice URL points at your answer handler, and attach it to the number. SIPRTC then fetches TinyML from that URL for every inbound call.