Skip to content
POST
https://api.voice213.com/api/agents/public/{publicId}/call
curl -X POST https://api.voice213.com/api/agents/public/k3x9m2p7q4wz/call
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhaWQiOiI2YWMyYWFi…",
  "wsUrl": "wss://api.voice213.com/ws/agent"
}

Returns a single-use ticket for one call to a published agent: a token, and the address of the call socket to open with it. The SDK asks for it when you call start(). You only need this endpoint for a client of your own. See Realtime Protocol.

It needs no key. Calls are paid from the agent owner's call minutes, so the endpoint is protected in two ways:

  • Allowed websites. If the agent has a list, a request from a browser on a site that isn't on it is refused with 403 ORIGIN. The list is checked through the Origin header browsers send. The Voice213 public page is always allowed. With an empty list, any site, and any client without an Origin (a server or an app), can start calls.
  • A rate limit. Each IP address can ask for 20 tickets an hour.

The ticket is valid for two minutes and opens one call. A ticket requested with an Origin only opens a socket from that same origin. Asking for a ticket is free. Minutes count from the moment the call connects, and a call under 3 seconds isn't counted.

Path

publicIdstringrequired

The agent's public id, from its Publish page.

Body

application/json
visitstring

Optional. The visit token from an earlier answer (a call or a chat on the public page). The agent then starts the call knowing what this visitor already said in the visit. Without one, or with an expired one, a new visit starts.

Response

application/json
tokenstringrequired

The ticket. Pass it as the token query parameter when you open the socket.

wsUrlstringrequired

The call socket to open: wss://api.voice213.com/ws/agent.

visitstringrequired

The visit token, valid for a day. Send it with the next call to keep one memory across the visitor's calls.

Errors

StatusErrorWhen
403ORIGIN (in code)The request came from a website that isn't in the agent's Allowed websites
404This agent is not availableNo agent has this id, the agent is a draft, or its link and widget are turned off
429RATE_LIMITEDThis IP address asked for 20 tickets in the last hour
503MAINTENANCE (in code)Voice213 is down for maintenance

Whether the account has minutes and free lines is checked when the socket opens. See the error codes.

Was this page helpful?