API reference
Place a call
POST /v1/calls
Call a phone number with one of your outbound agents. Answers 201 with the conversation, pending until the phone is answered. Needs calls:write and an Idempotency-Key: the same request sent again with the same key returns the same conversation instead of calling twice.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key |
header | string | Yes | Your own id for this call, up to 120 characters. Required. |
Body
Sent as JSON. A field this operation does not take is refused, so a typo fails loudly.
| Field | Type | Required | Description |
|---|---|---|---|
agent_id |
string (uuid) | Yes | The outbound agent that makes the call. |
agent_version |
integer or null | No | Answer with this published version of the agent rather than what is live now — its number from GET /v1/agents/{id}/versions. Its values and languages are that version's, and every turn of the conversation keeps it. |
call_window |
CallWindow or null | No | Only start the call within these hours. Outside them it is refused with outside_call_window, which says when the window opens — schedule it for then with POST /v1/scheduled-calls. |
external_id |
string or null | No | |
from_number |
string or null | No | One of the agent's numbers to call from. Or send phone_number_id, never both; with neither, the agent's own number. |
language |
string or null | No | One of the agent's language versions, like ar. |
metadata |
object | No | Your own data, returned on every read and event. The agent never sees it. |
phone_number_id |
string (uuid) or null | No | One of the agent's numbers to call from, by its id. |
to_number |
string | Yes | The number to call, in international format, like +966501234567. |
variables |
object | No | Values for the agent's {{placeholders}} — text, numbers or true/false. See the agent's variables_schema. |
Answer
201 with Conversation.
Errors
Every error is a problem document with a stable code.
| Status | When |
|---|---|
400 |
No Idempotency-Key, or one longer than 120 characters. |
401 |
The key is missing, mistyped, unknown, revoked or expired. |
402 |
The organization's credit is used up. |
403 |
The key lacks a permission, a live key was sent from a browser, or the organization is frozen and the request would change something. |
404 |
This key reaches no such agent. |
409 |
The agent does not place calls or is not published, or its project is frozen. |
413 |
The request is larger than 64 KB. |
422 |
A field, a variable, the number to call or the number to call from does not fit — or the Idempotency-Key was already used for a different request. |
429 |
Too many requests for this key or its organization; see Retry-After. |
500 |
Something went wrong on our side. Quote the request_id to support. |
501 |
This deployment does not place phone calls. |
502 |
The call could not be placed. Try again shortly. |
Examples
#!/bin/sh
# Place a call. With a test key this calls a test number and rings nobody.
curl -sS --fail-with-body -X POST "https://api.aigently.ai/v1/calls" \
-H "Authorization: Bearer $AIGENTLY_API_KEY" \
-H "Idempotency-Key: lead-20931" \
--json '{
"agent_id": "8a1f3c2e-0b6d-4f5e-9a7c-2d4e6f8a0b1c",
"to_number": "+12025550100",
"variables": {
"first_name": "Sara"
},
"metadata": {
"crm_lead_id": "L-20931"
},
"external_id": "lead-20931"
}'
Try it
Sends this request to the API from your browser, with a test key. Nothing it does rings a phone.