How to place a call right away through the API
One request places an outbound call from the agent to one number, right away. To send many leads, use a dial list filled through the API instead.
Create an API key with the "Place calls" permission
Copy the agent's ID
The ID is in the address of the agent page, after
agents/.Send a POST request with the agent ID and the phone number
Example request
curl -X POST 'https://platform.direnium.com/api/v1/calls' \
-H 'Authorization: Bearer <API-KEY>' \
-H 'Content-Type: application/json' \
-d '{
"agentId": "<AGENT-ID>",
"to": "+9725XXXXXXXX",
"variables": { "first_name": "Dana", "car_model": "Mazda 3" },
"idempotencyKey": "lead-48213-call-1"
}'| Field | Description |
|---|---|
agentId | The ID of the agent that makes the call. |
to | The customer's phone number, preferably in international format. |
variables | Values for the variables in the script, by variable name. |
idempotencyKey | Your own ID for the request. A repeated request with the same ID returns the same call and does not dial again. |
Response: 201
{
"id": "<CALL-ID>",
"status": "dialing",
"to": "+9725XXXXXXXX",
"createdAt": "<ISO-TIME>"
}Which responses and errors can I get?
202with statusnot_dialed: the agent is in test mode and the number is not a test number. No call goes out.400: a field is missing, or the phone number is invalid or to an unsupported destination.401: the key is missing or wrong.403: the key lacks the scope, the agent is off, the minutes ran out, or the customer opted out.404: the agent was not found, or it has no outbound calls.409: this number was dialed a moment ago.422: outside the agent's calling hours. The response includesnextOpenAt, the next time a call is possible.429: too many requests in a minute.
How do I know what happened on the call?
Keep the id you got back. When the call ends, the voice.call_completed event is sent to your webhook, and you can also fetch the call, its transcript and its recording.