Introducing the Sent Voice API
A short tour of inbound, outbound, and in-app calling, plus an example receptionist agent.

A short tour of inbound, outbound, and in-app calling, plus an example receptionist agent.


We've been running phone calls in beta since September. The version we launched this week isn't the one we built first. Here's why.

Send SMS, WhatsApp, or RCS as a step in any workflow, and start one when someone texts back.

If your product sends messages for other businesses, a Sender Profile holds the registration, numbers and channels for each one - so adding a new customer is one API call.
One API. Every channel.
Our Voice API is live today for inbound, outbound, and in-app calling.
It can place and answer calls on the numbers you already text from, and every call lands on the same contact record as that customer’s messages.
This post is a short tour of the API, and then a walkthrough of a sample receptionist agent that answers calls.
Turning on phone calls
Any US number you already text from can take calls, or you can request a new one. Voice is US-only for now.
Each voice number has a callback URL and a signing secret. The callback URL is an endpoint on your server that Sent asks what to do with each call. The signing secret is how your server checks that those requests came from Sent.
What the Voice API does
You can answer calls from your server, place them, make them from your app, or hand them to an agent. A number can do more than one.
{ "action": { "action": "playMenu", "prompt": { "text": "Press 1 for sales, 2 for support" }, "maxDigits": 1 } }@sentdm/voice-clientand callsclient.connect({ to }). These use the same number, logs, and webhooks as every other call.However a call is answered, Sent sends your server webhooks when it is answered, when it ends, and what it cost.
The receptionist agent
The agent is for a dental clinic. When the front desk is closed, it moves the caller's next appointment to an open slot, transfers emergencies to the dentist on call, and texts the caller a confirmation. For anything else it says the front desk opens at 8 AM.
It needs three things: a number with calls enabled, an agent record stored with Sent, and a program that holds a WebSocket. The program is one file, about 170 lines. You can see the full gist on our GitHub.
Sent handles everything else: the phone network, speech recognition, text-to-speech, and the webhooks.
Step 1: Create the agent record
An agent record tells Sent how your program wants to receive calls and what it is allowed to do. Only
nameandsession_typeare required.curl -X POST https://api.sent.dm/v3/voice/agents \ -H "x-api-key: $SENT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Front desk, after hours", "session_type": "text", "greeting": "Thanks for calling Northside Dental. I'\''m the clinic'\''s automated assistant and this call is transcribed. The front desk is closed, but I can move an appointment or reach the dentist on call. How can I help?", "tools": ["transfer", "hangup"], "transfer_targets": [{ "kind": "number", "value": "+12125550177" }], "fallback": { "kind": "number", "value": "+12125550177" }, "limits": { "max_call_seconds": 600, "max_concurrent_calls": 5 } }'session_type: "text"means Sent handles the audio. Your program receives what the caller said as text and replies with text for Sent to speak. The other value isaudio, which gives you the raw audio in both directions if you want to run your own speech model.greetingis spoken as soon as the call is answered, before your program has done anything.toolsis what the agent can do other than talk. The default is["hangup"]. This agent can also transfer, which requirestransfer_targets. Sent refuses a transfer to any number not on that list, so a caller can’t talk the model into dialing somewhere else. This list is on the record, not in your code.fallbackis who gets the call when your program isn’t connected. Without one, the call fails withagent_unreachable. It’s best to set one.limitscaps how long a call can last and how many can run at once. Sent enforces them.websocket_urlis left out of this example. If you set it, Sent connects to you for each call. If you leave it out, your program connects to Sent once and all calls arrive on that connection. The second is simpler for a program that is always running.The response includes the agent id and a
signing_secret. You only see the secret once - save it. An agent that connects to Sent doesn't use it, but if you later add awebsocket_url, Sent signs the handshake with it. This is a different secret from the number's callback secret.Step 2: Write the program
Sent and your program talk over one WebSocket by sending each other small JSON messages. Sent sends
session.startwhen a call is answered,user.saidfor each thing the caller says,tool.resultafter an action, andsession.endwhen the call ends. The program sendsagent.sayto speak andtool.callto act. There are SDKs for Python, TypeScript, .NET, Go, Rust, Java, and the browser, but the frames are small enough to handle directly.The program is Node 22 with two dependencies,
wsand the Anthropic SDK. It connects with the API key as a bearer token and thesent.voice.v1subprotocol:const ws = new WebSocket(`${VOICE_URL}?agent_id=${env.SENT_AGENT_ID}`, "sent.voice.v1", { headers: { Authorization: `Bearer ${env.SENT_API_KEY}` }, }); ws.on("message", async (data) => { const frame = JSON.parse(data.toString()); const id = frame.session_id; switch (frame.type) { case "ping": return send({ type: "pong", ts: frame.ts }); case "session.start": { const s = { caller: frame.from.value, appointment: null, history: [] }; s.queue = findAppointment(s.caller).then((a) => (s.appointment = a)); sessions.set(id, s); return; } case "user.said": { const s = sessions.get(id); if (!s) return; s.queue = s.queue .then(() => takeTurn(send, id, s, frame)) .catch(() => send({ type: "agent.say", session_id: id, text: "Sorry, could you say that again?" })); return; } } });When the call starts, Sent tells the program who is calling. The program uses that number to look up the caller's appointment before they've said anything.
The program handles one thing the caller says at a time, in order. Without that, if the caller says two things quickly, the model could be answering the second before it has finished with the first, and the replies would come back out of order.
Each time the caller says something, the model returns a small JSON object: what to say, and one of three actions. The code checks the action before acting on it:
const turn = await decide(s); // { say, action, slot } let say = turn.say; if (turn.action === "move") { const moved = await moveAppointment(s.caller, turn.slot); if (moved) { s.appointment = moved; await textConfirmation(s.caller, moved.when); } else { say = "Sorry, that time was just taken. Shall I read you the open slots again?"; } } send({ type: "agent.say", session_id: id, text: say }); if (turn.action === "hangup") { send({ type: "tool.call", session_id: id, call_ref: `hangup-${Date.now()}`, name: "hangup", arguments: {} }); }The model never writes to the calendar. If it proposes a slot that doesn't exist,
moveAppointmentreturns nothing, no text is sent, and the caller is told so.The confirmation text is one request to the messages API, from the same process that is on the call:
await fetch(`${API_URL}/v3/messages`, { method: "POST", headers: { "x-api-key": env.SENT_API_KEY, "Content-Type": "application/json" }, body: JSON.stringify({ to: [to], template: { id: env.CONFIRM_TEMPLATE_ID, parameters: { when } } }), });It uses a template rather than free text, because the first message to someone who has never texted you must be a template. Submit the template for review before you need it. A message that uses a template still in review is accepted and then blocked.
Three things to know about this protocol:
tool.call, not a socket close. If you close the socket, Sent assumes the connection dropped.Step 3: Bind the number
Turning on voice for a number takes the agent id, so one request does both:
curl -X POST https://api.sent.dm/v3/channels/voice \ -H "x-api-key: $SENT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "number": "+12125550100", "agent_id": "agent_eeac3a63-c61b-4060-a352-e612f68b88f4" }'The response says
"routes_to": "agent_pending". Sent records the binding immediately, but the phone network takes up to about an hour to start sending calls to the new destination.Until then, calls may still go to the old one. Bind the number before you need it, and confirm with a real call.
Step 4: Call it
I called the number and asked to move Thursday's appointment. I asked for Friday at 8 PM (where there aren’t any slots available) and was offered three available slots. I took Friday at 8 AM. The confirmation text actually arrived before the call ended.
Most of the pause before the agent replies is the model thinking. Sent’s side of the latency is <100 ms, so if the agent feels slow, look at the model first. When I talked over the agent, it stopped. Sent handles that - your program doesn't have to.
The call appears in Activities next to the text it sent: one minute eleven seconds, about three cents. The backend received three webhooks:
{ "event": "call.answered", "call_id": "call_8a1f...", "mode": "agent", "agent_id": "agent_eeac..." } { "event": "call.agent_connected", "call_id": "call_8a1f...", "mode": "agent", "agent_id": "agent_eeac..." } { "event": "call.completed", "call_id": "call_8a1f...", "duration_seconds": 71, "price": "0.03" }Failure modes
agent_unreachableand you get acall.failedwebhook.max_concurrent_calls, the next call fails withagent_busy. It doesn’t go to the fallback. The fallback is for when the agent is absent, not when it is busy. If you want overflow to ring a person, the agent should transfer.tool.resultcomes back failed. The program has to say something, and this one says the team will call in the morning.Two more things
session_typetoaudioand the socket carries raw audio instead of text. Sent stops doing speech recognition and text-to-speech, and thegreetingandvoicefields no longer apply. This skips the text step, which is where most of the latency is.chat-voice-agent-openai-sentsample runs one agent across SMS, WhatsApp, RCS, and phone calls on one number. It replies to texts, answers and places calls, and hands over to a person. All of this is on the same contact record.Try it out
The agent is a gist. The other samples are on GitHub. The docs cover the voice SDKs (browser, iOS, Android), the agent SDKs, and how to connect an agent.
Email support@sent.dm to enable phone calls for your account.