POST /v1/projects/{projectId}/agents/{agentId}/dispatch-call asks an agent to call one phone number. The request returns as soon as the number is being dialed, with the id of the conversation the call will be recorded under. To call a list of numbers with per-contact variables, retries and calling hours, use a campaign instead.
Before you start
-
The agent is published. Outbound calls always run the agent’s published version. An agent that has never been published is refused with
409 AGENT_NOT_PUBLISHED. -
The agent is a voice agent. A Voice Assist agent listens to calls a person handles and cannot place calls (
422 AGENT_TYPE_NOT_DISPATCHABLE). -
There is a number to call from. Clarity picks the caller ID in this order:
- the
fromnumber in your request; - the outbound caller ID set for the agent in Clarity;
- the number routed to the agent for inbound calls;
- the platform’s default outbound route, when your deployment has one.
fromnumber must be registered in the project and enabled for outbound calls. Numbers and their outbound trunks are set up in Clarity. - the
Dispatch the call
1
Find the project and agent ids
2
Ask the agent to call
3
Keep the conversation id
conversationId is the id you use to read the call afterwards. status is always dialing: a successful response means the call was placed, not that anyone answered.Request body
string
required
The number to call. Use E.164 format, for example
+14155550123. An invalid number is refused with 400.string
The caller ID to present. Must be a number of this project that is enabled for outbound calls, or the request is refused with
422 and nothing is dialed. Omit it to use the agent’s own caller ID (see the order above).string
An
https:// URL. When the call ends, Clarity sends the call’s vCon document to it with a POST. See Call-ended webhook.Dispatch takes no per-call variables. If your agent’s prompt uses variables such as a customer name or an order number, place the call through a campaign, whose items carry
custom_vars.Errors
The
503 body uses message, not error. It means the call has nowhere to go out from: give the agent an outbound caller ID in Clarity, or pass from.
Follow the call
You have two options. Use the webhook when you want to react the moment a call ends; poll when you cannot receive inbound HTTPS requests.- Webhook
- Poll
Pass
on_call_ended_url when you dispatch. Clarity posts the call’s vCon document there after the call ends. See Call-ended webhook for the payload and the delivery rules.The webhook is best-effort. Keep a fallback that polls conversations you have not heard back about.status, hangup_reason and hangup_sip_code), list the conversation’s calls: