API reference
Schedule a call
POST /v1/scheduled-calls
The request POST /v1/calls takes, placed later: at dial_at, or at the first moment its call_window is open at or after it. Checked now, so a mistake is said now, and checked again when it is placed. Answers with the scheduled call; once placed, its conversation_id names the conversation, which sends the usual events. Needs calls:write and an Idempotency-Key.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key |
header | string | Yes | Your own id for this request, 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. |
dial_at |
string (date-time) or null | No | The earliest the call may be placed. Now unless you say; with a call_window, the window's first opening at or after it. At most 30 days ahead. |
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 ScheduledCall.
Errors
Every error is a problem document with a stable code.
| Status | When |
|---|---|
400 |
No Idempotency-Key. |
401 |
The key is missing, mistyped, unknown, revoked or expired. |
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, its project is frozen, or the number is on the do-not-call list. |
422 |
A field, a variable, the window or the number does not fit, the time is more than 30 days ahead — or the Idempotency-Key was used for another 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. |
Examples
#!/bin/sh
# Schedule a call inside calling hours. It is placed at the first moment the window is open at or after dial_at.
curl -sS --fail-with-body -X POST "https://api.aigently.ai/v1/scheduled-calls" \
-H "Authorization: Bearer $AIGENTLY_API_KEY" \
-H "Idempotency-Key: reminder-20931" \
--json '{
"agent_id": "8a1f3c2e-0b6d-4f5e-9a7c-2d4e6f8a0b1c",
"to_number": "+12025550100",
"dial_at": "2026-10-12T13:00:00Z",
"call_window": {
"timezone": "America/New_York",
"start": "09:00",
"end": "17:00",
"days": [
"mon",
"tue",
"wed",
"thu",
"fri"
]
},
"variables": {
"first_name": "Sara"
},
"external_id": "reminder-20931"
}'
Try it
Sends this request to the API from your browser, with a test key. Nothing it does rings a phone.