# Integrate with an AI assistant (/docs/ai-assistants) Our docs are written to be read by AI assistants. Paste this prompt into yours, fill in the brackets, and it can write the whole integration: ```text Integrate CallHuman into this project. Docs for AI assistants: https://www.callhuman.es/llms-full.txt OpenAPI: https://www.callhuman.es/openapi.json Goal: when , call the person at , read , offer these options: , and handle the answer in a webhook endpoint that verifies the CallHuman-Signature header. Use the API key from the CALLHUMAN_API_KEY environment variable and the webhook secret from CALLHUMAN_WEBHOOK_SECRET. ``` ## Machine-readable resources [#machine-readable-resources] | Resource | What it contains | |---|---| | [`/llms.txt`](/llms.txt) | Index of every docs page with a one-line description and a link to its Markdown. | | [`/llms-full.txt`](/llms-full.txt) | All the docs in a single Markdown file. Best for pasting into a chat. | | `/docs/.md` | Any docs page as Markdown, e.g. [`/docs/webhooks.md`](/docs/webhooks.md). | | [`/openapi.json`](/openapi.json) | OpenAPI 3.1 spec with descriptions and examples for every field and error. | Docs pages also answer `Accept: text/markdown` with Markdown, and every page has **Copy Markdown** and **Open in ChatGPT / Claude** buttons. ## What a correct integration looks like [#what-a-correct-integration-looks-like] Ask your assistant to check its code against this list: 1. `POST https://api.callhuman.es/v1/calls` with `Authorization: Bearer ` and a JSON body. 2. `to` in international format (`+34600111222`), `message`, and `options` as objects: `{ "label": "...", "reply": "..." }` — not plain strings. 3. A `webhook_url` endpoint that reads the **raw body**, verifies `CallHuman-Signature` (hex HMAC-SHA256 with the webhook secret) and returns `2xx` quickly. 4. Decide using `status` and `option_label` (or `option_path` for submenus), and find your record with `metadata`. 5. Handle `not_answered`: decide what happens when nobody picks up. 6. Send an `Idempotency-Key` header if the request may be retried. ## Copy-paste starter (Node.js) [#copy-paste-starter-nodejs] ```js // 1) Create the call const res = await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": `booking-${booking.id}-confirmation`, }, body: JSON.stringify({ to: booking.phone, language: "en", message: `Hi! This is La Plaza about your table for ${booking.people} tonight at ${booking.time}.`, options: [ { label: "Confirm", reply: "Perfect, see you tonight!" }, { label: "Cancel", reply: "No problem, your booking is cancelled." }, ], webhook_url: "https://laplaza.example/hooks/callhuman", metadata: { booking_id: booking.id }, }), }); if (!res.ok) throw new Error((await res.json()).error.message); ``` Then receive the answer as shown in [Webhooks](/docs/webhooks#verify-the-signature). # API reference (/docs/api-reference) | Endpoint | What it does | |---|---| | [`POST /v1/calls`](/docs/api-reference/createCall) | Create a call | | [`GET /v1/calls/{id}`](/docs/api-reference/getCall) | Get a call and its result | | [Webhook `callResult`](/docs/api-reference/callResult) | Sent to your `webhook_url` when the call ends | **Authentication:** `Authorization: Bearer ch_live_xxxxxxxxxxxx`. Create keys in the dashboard under **API keys**. **Spec:** download [`/openapi.json`](/openapi.json) (OpenAPI 3.1) to generate clients or give it to your AI assistant. **Errors:** every error is `{ "error": { "code", "message", "docs_url" } }`. See [Errors](/docs/errors). # Changelog (/docs/changelog) ## 2026-11-25 — Docs published [#2026-11-25--docs-published] - Public documentation, OpenAPI 3.1 spec and machine-readable docs (`/llms.txt`, `/llms-full.txt`, Markdown for every page). - API v1 design: `POST /v1/calls` and `GET /v1/calls/{id}`, options with optional `reply`, submenus up to 3 levels, keypress and voice answers, signed webhooks. The API is versioned (`/v1`). A published version is never broken: new fields may be added, nothing is removed or renamed. # CallHuman vs Slack & email approvals (/docs/comparisons/slack-email-approvals) **Messages wait; a ringing phone doesn't.** Slack, email and human-in-the-loop tools (gotoHuman, HumanLayer…) are great for approvals that can wait. When the answer matters within minutes, or the person isn't in your workspace, call them. | | CallHuman | Slack / email / HITL tools | |---|---|---| | Gets attention right now | Yes, the phone rings | Only if they look at the app | | Reaches customers and people outside your team | Anyone with a phone | Needs the app or an account | | Works for non-technical people | Press 1 or say it | Yes | | Structured answer | One of your options | Buttons, forms | | Best for | Same-day confirmations, urgent approvals, alerts | Reviews that can wait hours | ## Use both [#use-both] Many teams send a message first and **call only if there's no answer in time**. With n8n: send the Slack message, wait 15 minutes, and if nobody approved, use the CallHuman node. # CallHuman vs Twilio (/docs/comparisons/twilio) **Twilio is a toolbox; CallHuman is the finished tool for one job**: call a person, ask something, get the answer back. ## The same booking confirmation [#the-same-booking-confirmation] With **CallHuman**, one request and one webhook: ```json { "to": "+34600111222", "message": "Hi! This is La Plaza about your table for 4 tonight at 8:30 pm.", "options": [ { "label": "Confirm", "reply": "Perfect, see you tonight!" }, { "label": "Cancel", "reply": "No problem, your booking is cancelled." } ], "webhook_url": "https://laplaza.example/hooks/callhuman" } ``` With **Twilio** you build it: buy and register a number, write the call flow (TwiML or Studio), gather keypresses and speech, match free speech to options, repeat the menu, detect voicemail, schedule retries, expire stale calls, and send yourself the result. ## Side by side [#side-by-side] | | CallHuman | Twilio | |---|---|---| | Time to first call | Minutes | Days of development | | Keypress **and** voice answers | Built in, matched by meaning | Build it (Gather + speech + your own matching) | | Retries, voicemail, expiry | Built in | Build it | | Phone number | Included, assigned instantly | Rent it, plus regulatory paperwork per country | | n8n node with one branch per option | Yes | No | | Pricing | Flat monthly, only answered calls | Per minute, per number, per feature | | Flexibility | Fixed, opinionated behaviour | Anything you can program | ## When to choose Twilio [#when-to-choose-twilio] - You need inbound call centers, call transfers, conferences, recordings or a fully custom IVR. - You have engineers to build and maintain telephony. ## When to choose CallHuman [#when-to-choose-callhuman] - You want a **decision or a notification** delivered by phone, today, with no telephony work. - You use n8n or an AI agent and want answers as branches or tool results. - You prefer a predictable monthly price. # CallHuman vs AI voice agents (/docs/comparisons/voice-ai-agents) **AI voice agents talk; CallHuman asks and returns a decision.** If the outcome you need is one of a few known options, you don't need a conversation — you need a reliable answer. ## The difference in one call [#the-difference-in-one-call] | | CallHuman | AI voice agents (Vapi, Retell, Bland…) | |---|---|---| | What the person hears | Your exact message and options | Text generated by an LLM | | Result | Always one of your options, or none | Free text you have to interpret | | Voice answers | Matched by meaning to your options | Open conversation | | Setup | One request, no prompts | Prompts, voices, tools and testing | | Risk of saying something wrong | None: we only read your text | Possible hallucinations | | Pricing | Flat monthly, only answered calls | Per minute (LLM + speech + telephony) | | Own phone number | Included | Bring or rent one | ## When to choose an AI voice agent [#when-to-choose-an-ai-voice-agent] - The call needs real back-and-forth: qualifying leads, support, scheduling with many constraints. - You accept per-minute costs and maintaining prompts. ## When to choose CallHuman [#when-to-choose-callhuman] - The answer is one of a few options: confirm/cancel, approve/reject, acknowledge. - You want the same behaviour on every call, and a result your code can trust. - You need it to be cheap, fast to set up and easy to explain to your team. People still answer naturally: “yes, we'll be there, don't cancel it” is understood as *Confirm*. Many options? Use [submenus](/docs/options#submenus). # Errors (/docs/errors) Every error has the same shape. `message` explains what is wrong and how to fix it, and `docs_url` links to this page: ```json { "error": { "code": "message_too_long", "message": "Your message, labels and replies are 612 characters; your plan allows 500. Remove 112 characters or upgrade.", "docs_url": "https://www.callhuman.es/docs/errors#message_too_long" } } ``` Use `code` in your code (it never changes); show `message` to humans. When a request has several problems, we return the first one in this order: `401` → `402` → `403` → `429` → `422`. | Code | HTTP | When | |---|---|---| | [`invalid_api_key`](#invalid_api_key) | 401 | API key missing, revoked or expired | | [`subscription_required`](#subscription_required) | 402 | The project has no active plan | | [`project_suspended`](#project_suspended) | 403 | Calls paused for a security review | | [`rate_limit_exceeded`](#rate_limit_exceeded) | 429 | More than 30 requests/min or 300/hour | | [`quota_exceeded`](#quota_exceeded) | 429 | No answered calls left this cycle | | [`invalid_request`](#invalid_request) | 422 | Missing or invalid fields | | [`message_too_long`](#message_too_long) | 422 | Message + labels + replies over your plan's limit | | [`destination_not_allowed`](#destination_not_allowed) | 422 | Invalid number, unsupported country or blocked prefix | | [`call_not_allowed`](#call_not_allowed) | 422 | The content isn't transactional (sales, marketing, scam) | | [`call_not_found`](#call_not_found) | 404 | `GET /v1/calls/{id}` with an unknown ID | ## invalid_api_key [#invalid_api_key] **HTTP 401.** The `Authorization` header is missing, or the key was revoked or has expired. **Fix:** send `Authorization: Bearer `. Create a new key in the dashboard under **API keys** if needed. Keys can expire after 30 days, 90 days or 1 year, or never — check the one you use. ## subscription_required [#subscription_required] **HTTP 402.** The project has no active plan, or the last payment failed. **Fix:** choose a plan in the dashboard (**Settings → Choose a plan**), or update your card in **Manage billing**. API keys work as soon as the plan is active. ## rate_limit_exceeded [#rate_limit_exceeded] **HTTP 429.** More than **30 requests per minute** or **300 per hour** for the project. **Fix:** wait the seconds shown in the message and retry. Spread large batches over time. Use an `Idempotency-Key` header so retries never create duplicate calls. ## quota_exceeded [#quota_exceeded] **HTTP 429.** You have used all the answered calls included in this billing cycle. **Fix:** upgrade your plan from the dashboard — it applies immediately. Otherwise calls reset at the start of your next cycle. Unanswered calls never count. ## invalid_request [#invalid_request] **HTTP 422.** A required field is missing or a value is invalid. The message names the exact field, for example: - `to is required` / `to must be in international format, e.g. +34600111222` - `options[2].options has 12 items; the maximum per menu is 9 (keys 1–9). Group the rest into a submenu.` - `options[1] has both reply and options; use one of them` - `options are nested 4 levels deep; the maximum is 3` **Fix:** correct the field named in the message. See [Options, replies & submenus](/docs/options#rules) for the menu rules. ## message_too_long [#message_too_long] **HTTP 422.** `message` plus every `label` and `reply` (submenus included) is longer than your plan allows. The message says how many characters to remove. **Fix:** shorten the text, or upgrade to a plan with a higher limit. We check before calling, so a call is never cut halfway. ## destination_not_allowed [#destination_not_allowed] **HTTP 422.** The number is not valid, its country is not supported, or it uses a blocked prefix (premium-rate and other high-risk destinations). **Fix:** use the international format with country code (`+34…`, `+1…`). Check that the country is supported in [Phone numbers](/docs/phone-numbers). ## project_suspended [#project_suspended] **HTTP 403.** New calls are paused for this project because too many recent calls looked like marketing, sales or other unsolicited messages (10% warns, 25% — or 3 blocked calls in a row — pauses). **Fix:** reply to the email we sent, or write to hello@callhuman.es. We review it and lift the pause if it was a mistake. ## call_not_allowed [#call_not_allowed] **HTTP 422.** CallHuman only places **transactional** calls: confirmations, reminders and updates about something the person already has with you, verification codes, security alerts and approvals. Before every call we check what the person will hear; this one looked like marketing, sales, a scam or another unsolicited message, so we didn't call and it doesn't count. ```json { "error": { "code": "call_not_allowed", "message": "This call looks like marketing or sales. CallHuman only places transactional calls (confirmations, codes, approvals, alerts). Remove the promotional part and try again.", "docs_url": "https://www.callhuman.es/docs/errors#call_not_allowed" } } ``` **Fix:** keep the message about the person's booking, order, account or code. Offers, discounts and sales pitches aren't allowed, even as a side note. ## call_not_found [#call_not_found] **HTTP 404.** No call with that ID exists in the project of your API key. **Fix:** check the ID returned by `POST /v1/calls`, and use an API key of the same project. # Introduction (/docs) CallHuman is an API that **calls a phone number, reads your message out loud and returns the option the person chooses**. They answer by pressing a key or by saying it in their own words. You get the answer in a webhook, through the API, or as a branch in n8n. ```bash curl https://api.callhuman.es/v1/calls \ -H "Authorization: Bearer $CALLHUMAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": "+34600111222", "message": "Hi! This is La Plaza about your table for 4 tonight at 8:30 pm.", "options": [ { "label": "Confirm", "reply": "Perfect, see you tonight!" }, { "label": "Cancel", "reply": "No problem, your booking is cancelled." } ], "webhook_url": "https://laplaza.example/hooks/callhuman" }' ``` A few seconds later the phone rings. When the person answers, your webhook receives: ```json { "id": "call_x9f2k", "status": "answered", "option_path": [1], "option_label": "Confirm", "metadata": {} } ``` ## How a call works [#how-a-call-works] 1. **You create a call** with `POST /v1/calls`: the phone number (`to`), the text to read (`message`) and, if you want an answer, the `options`. 2. **We call from your own phone number** and read the message in the `language` you choose (English by default). 3. **The person answers** by pressing a key (1–9) or by saying the option in their own words. We understand the meaning: “yes, we'll be there” counts as *Confirm*. 4. **We read the option's `reply`** if you gave one, and hang up. 5. **You get the result** in your `webhook_url`, with `GET /v1/calls/{id}` or in your n8n flow. ## Key concepts [#key-concepts] | Concept | What it is | |---|---| | **Call** | One request to phone one person. Has an `id` and a `status`. | | **Message** | The text we read out loud. | | **Options** | What the person can choose, up to 9 per menu. Each has a `label`, and optionally a `reply` or a submenu (`options`). See [Options, replies & submenus](/docs/options). | | **One-way message** | A call with no options: we read the text once and hang up. Perfect for codes. See [One-way messages](/docs/one-way-messages). | | **Result** | `status`, plus `option_path` and `option_label` of the chosen option. See [Webhooks](/docs/webhooks). | | **Answered call** | The unit your plan counts. Unanswered calls are free. See [Limits & billing](/docs/limits-and-billing). | ## Fixed behaviour [#fixed-behaviour] CallHuman has no settings to tune. Every call follows the same rules: | Behaviour | Value | |---|---| | Time to answer each menu | 10 seconds | | Menu repeated if there is no valid answer | 2 times | | Retries if nobody answers or the line is busy (with options) | 2, 5 minutes apart | | Call expires (with options) | 1 hour after creation | | Attempts for one-way messages | 1, no retries | | Voicemail | We hang up without leaving a message | | Default language | English (`en`) | ## Next steps [#next-steps] # Limits & billing (/docs/limits-and-billing) You pay one flat monthly or yearly price that includes a number of **answered calls**. Unanswered calls are free and there are no per-minute fees. | Plan | Monthly | Yearly | Answered calls / cycle | Max length (message + labels + replies) | |---|---|---|---|---| | Starter | $19 | $190 | 150 | 500 characters | | Pro | $49 | $490 | 600 | 1,000 characters | | Business | $149 | $1,490 | 2,500 | 1,000 characters | Prices in USD, excluding VAT. Prices are in **US dollars and exclude VAT**. VAT is added at checkout when it applies: Spanish customers pay Spanish VAT, EU businesses with a valid VAT number pay no VAT (reverse charge), EU consumers pay their country's VAT. Yearly plans cost 10 months (2 months free). Every plan includes your own phone number, keypress and voice answers, replies and submenus, signed webhooks, the n8n node and automatic retries. ## What counts [#what-counts] | Situation | Counts? | |---|---| | The person answers (with or without choosing an option) | **Yes, 1 call** | | No answer, busy line, voicemail | No | | Invalid number or technical error | No | | Retries of the same call | Only the attempt that is answered | ## Billing cycle [#billing-cycle] - A cycle runs from the day you subscribed (day *N*) to day *N − 1* of the next month. In shorter months it ends on the last day. - **Unused calls don't roll over.** On yearly plans the calls reset every month on day *N*. - When you run out, new requests return [`quota_exceeded`](/docs/errors#quota_exceeded) and we email you. There are no top-ups or automatic charges: upgrade to keep calling. - **Usage alerts by email**: by default at 80% and 100% of your calls. Change the thresholds and recipients in **Settings**. ## Changing plan [#changing-plan] - **Upgrade: immediate.** Your cycle restarts today with the new plan's calls. You get credit for the unused part of your current plan — the smaller of the share of time left and the share of calls left — so the change is always fair. - **Downgrade: at the end of the cycle.** You keep your current plan until then. If your messages are longer than the new plan allows, they will be rejected with `message_too_long` from that date. - Invoices, cards and cancellation: **Manage billing** in Settings (Stripe customer portal). ## Failed payments [#failed-payments] If a renewal fails, new calls stop immediately ([`subscription_required`](/docs/errors#subscription_required)) and we email you. Your phone number is kept for **7 days**; update your card in **Manage billing** to resume. ## API limits [#api-limits] | Limit | Value | |---|---| | Requests | 30 per minute and 300 per hour, per project | | Options per menu | 9 | | Menu levels | 3 (main menu + 2) | | Message length | Your plan's limit (message + all labels + all replies) | | Idempotency | `Idempotency-Key` header, remembered for 24 hours | | Call data | `message`, `options` and the answer are deleted after 30 days; usage records are kept | # MCP guide (coming soon) (/docs/mcp) The CallHuman MCP server is not available yet. Until then, any agent can use the [REST API](/docs/quickstart) directly — see [Integrate with an AI assistant](/docs/ai-assistants). The MCP server will let agents like Claude, ChatGPT or Cursor **phone a human before taking an important action** — a refund, a deploy, a deletion — and continue with the answer. ## Planned tools [#planned-tools] | Tool | What it does | |---|---| | `call_human` | Calls a person, reads the message with options and **waits for the answer**. Returns the chosen option. | | `notify_human` | Calls a person and reads a one-way message (no answer expected). | | `get_call` | Returns the status and result of a call. | ## Planned configuration [#planned-configuration] ```json { "mcpServers": { "callhuman": { "url": "https://api.callhuman.es/mcp", "headers": { "Authorization": "Bearer ch_live_xxxxxxxxxxxx" } } } } ``` ## Example [#example] > **Agent:** I'm about to refund 1,240 euros to Acme Ltd. I'll ask Laura first. > > *(calls `call_human` with options Approve / Reject — Laura's phone rings, she presses 1)* > > **Agent:** Laura approved it. Refund sent. # n8n guide (/docs/n8n) The **CallHuman** node calls a person, waits for the answer and continues down **one output per option**: ```text [New booking] → [CallHuman: Call and wait] ─┬─ 1 · Confirm → [Mark booking as confirmed] ├─ 2 · Cancel → [Free the table] └─ No answer → [Send an email] ``` You don't need to configure webhooks, Wait nodes or Switch nodes. ## 1. Install the node [#1-install-the-node] In n8n go to **Settings → Community nodes → Install** and enter: ```text n8n-nodes-callhuman ``` ## 2. Connect your API key [#2-connect-your-api-key] Add the node to a workflow, open **Credential → Create new** and paste your CallHuman API key (dashboard → **API keys**). ## 3. Fill in the call [#3-fill-in-the-call] | Field | What to enter | |---|---| | **Phone number** | International format, e.g. `+34600111222`. You can map it from a previous node. | | **Message** | What we read when they answer: “Hi! This is La Plaza about your table for 4 tonight at 8:30 pm.” | | **Language** | `en` by default. Choose the language of the person. | | **Options** | Add one per answer. Each has a **Label** (what is offered) and an optional **Reply** (what we say after they choose it). | Each option can also have **sub-options** to build a submenu (up to 9 per menu, 3 levels). See [Options, replies & submenus](/docs/options). ## 4. Connect the outputs [#4-connect-the-outputs] The node shows one output per final option, plus **No answer**. Connect each one to what should happen next. Options inside submenus get their own output too, named like `3 › 1 Change time`. If you add no options, the node has two outputs: **Done** (the message was read) and **No answer**. ## 5. Test it [#5-test-it] Put your own phone number, run the workflow and answer the call. The execution pauses while the phone rings and continues down the branch you chose. ## Tips [#tips] - The workflow stays paused while the call is in progress, including retries (up to 1 hour). That's normal. - Use the person's language: a guest from France hears French with `fr`. - Data from the call (option chosen, call ID) is available in the next node as `$json`. # One-way messages (voice OTP) (/docs/one-way-messages) Send only `to` and `message`. We call, read the text and hang up: ```bash tab="curl" curl https://api.callhuman.es/v1/calls \ -H "Authorization: Bearer $CALLHUMAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{"to": "+14155552671", "message": "Your verification code is 4 8 2 9. Again, 4 8 2 9."}' ``` ```js tab="JavaScript" await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ to: "+14155552671", message: "Your verification code is 4 8 2 9. Again, 4 8 2 9.", }), }); ``` ```python tab="Python" import os import requests requests.post( "https://api.callhuman.es/v1/calls", headers={"Authorization": f"Bearer {os.environ['CALLHUMAN_API_KEY']}"}, json={ "to": "+14155552671", "message": "Your verification code is 4 8 2 9. Again, 4 8 2 9.", }, ) ``` ## How it behaves [#how-it-behaves] | | One-way message | Call with options | |---|---|---| | Fields needed | `to`, `message` | `to`, `message`, `options` | | Attempts | **1** — no retries, so a code is never read late | 1 + 2 retries, 5 minutes apart | | Voicemail or no answer | Ends at once as `not_answered` (free) | Retried, then `not_answered` (free) | | Webhook | Optional (only if you want delivery confirmation) | Recommended | | Counts towards your plan | Only if answered | Only if answered | ## Writing codes that are easy to hear [#writing-codes-that-are-easy-to-hear] - **Separate the digits with spaces**: `4 8 2 9`, not `4829` (otherwise it may be read as “four thousand…”). - **Repeat the code once**: “Your code is 4 8 2 9. Again, 4 8 2 9.” - **Keep it short**: say what the code is for in a few words. Long messages count towards your [length limit](/docs/options#length-limit). - Use the `language` of the person: `"language": "es"` reads the code in Spanish. Calls must not ask people to say or type passwords, card numbers or codes. Only read codes out to the person who requested them. See the [Terms](/terms). ## Delivery confirmation [#delivery-confirmation] Add `webhook_url` if you want to know whether the person picked up. The webhook receives `status: "answered"` or `status: "not_answered"`, with an empty `option_path`. # Options, replies & submenus (/docs/options) `options` is a list of what the person can choose. Each option has a `label` and, optionally, a `reply` that we read right after it is chosen: ```json { "to": "+34600111222", "message": "Hi! This is La Plaza about your table for 4 tonight at 8:30 pm.", "options": [ { "label": "Confirm", "reply": "Perfect, see you tonight!" }, { "label": "Cancel", "reply": "No problem, your booking is cancelled." } ], "webhook_url": "https://laplaza.example/hooks/callhuman" } ``` What the person hears: ## Option fields [#option-fields] | Field | Required | Description | |---|---|---| | `label` | Yes | What is offered: “Press 1 or say *label*”. The first option is key 1, the second key 2, and so on. | | `reply` | No | Read right after the person chooses this option, then the call ends. Without it, the call ends as soon as they choose. | | `options` | No | A submenu: choosing this option opens more options instead of ending the call. Cannot be combined with `reply`. | ## Keypress or voice [#keypress-or-voice] Both always work; there is nothing to enable. - **Keypress:** the person presses 1–9. - **Voice:** the person says the option in their own words. We match the **meaning**, not the exact words: “sure, go ahead” → *Yes*, “yes, we'll be there, don't cancel it” → *Confirm*. - If we are not sure what they meant, **we repeat the options instead of guessing**. After 2 repetitions with no valid answer, the call ends with nothing chosen (`option_path: []`). ## Replies [#replies] A `reply` tells the person their answer was received and what happens next. It is optional: for a simple yes/no you can leave it out and we hang up as soon as they choose. ```json "options": [ { "label": "Yes" }, { "label": "No" } ] ``` ## Submenus [#submenus] Nobody wants to hear eight options in a row. Put the main ones first and group the rest in a submenu: ```json { "to": "+34600555666", "message": "Hi! Your order 1042 for 45 euros, cash on delivery, ships tomorrow.", "options": [ { "label": "Confirm", "reply": "Great, it ships tomorrow." }, { "label": "Cancel", "reply": "Your order is cancelled." }, { "label": "Change something", "options": [ { "label": "Change the address", "reply": "We'll text you a link to change it." }, { "label": "Deliver another day", "reply": "We'll call you to pick a day." } ] } ], "webhook_url": "https://shop.example/hooks/callhuman" } ``` The result tells you the full path: ```json { "id": "call_c55n1", "status": "answered", "option_path": [3, 2], "option_label": "Deliver another day", "metadata": {} } ``` ### Rules [#rules] | Rule | Value | |---|---| | Options per menu | Up to **9** (keys 1–9) | | Levels | Up to **3** in total (main menu + 2 submenu levels) | | Go back | In any submenu, **0** or saying “back” returns to the previous menu. Key 0 cannot be an option. | | `reply` and `options` together | Not allowed: an option either ends the call or opens a submenu | | Voice matching | Only against the options of the current menu (plus “back”) | | Retries | A retried call starts again from the message and the main menu | Breaking a rule returns [`invalid_request`](/docs/errors#invalid_request) with the exact menu to fix, for example: ```json { "error": { "code": "invalid_request", "message": "options[2].options has 12 items; the maximum per menu is 9 (keys 1–9). Group the rest into a submenu.", "docs_url": "https://www.callhuman.es/docs/errors#invalid_request" } } ``` ## Length limit [#length-limit] Your plan limits the total characters of `message` **plus every `label` and `reply`**, submenus included. Speech runs at about 800–900 characters per minute, so 500 characters is roughly 35 seconds. Too long returns [`message_too_long`](/docs/errors#message_too_long) before any call is made — we never cut a call halfway. # Phone numbers (/docs/phone-numbers) Every paid project gets **its own phone number**, shared with nobody. All your calls come from it, so people learn to recognise it and answer more often. It is never hidden and never rotates. ## Getting your number [#getting-your-number] 1. Choose a plan in the dashboard. 2. Pick the **country** (and city or region where it applies). 3. The number is assigned **instantly** and shown in **Overview**. No documents to send. One number per project. Need numbers in two countries? Create two projects. ## When someone calls it back [#when-someone-calls-it-back] People often call back a number they missed. They hear an automatic message with your project's name: > “This number belongs to La Plaza and is used for automated notifications.” Then the call ends. There is no voicemail. The message is read in the language of your last call to that person (or English). ## Supported countries [#supported-countries] We call countries in **Europe**, the **United States**, **Canada** and other countries with affordable call rates. Numbers outside the supported list are rejected before calling with [`destination_not_allowed`](/docs/errors#destination_not_allowed) — never charged extra. Premium-rate and other high-risk prefixes are always blocked. ## If you cancel or stop paying [#if-you-cancel-or-stop-paying] - **Failed payment:** the number is kept for 7 days. - **Cancellation:** the number is held for 3 months, then it may be reassigned. ## Good practices [#good-practices] - Use your number only for calls people expect: confirmations, codes, approvals and alerts. Marketing calls are not allowed. - Make the `message` start with who is calling: “Hi! This is La Plaza…”. # Quickstart (/docs/quickstart) Send one request and your own phone rings. Replace `+34600111222` with your mobile number in international format and run: ```bash tab="curl" curl https://api.callhuman.es/v1/calls \ -H "Authorization: Bearer $CALLHUMAN_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "to": "+34600111222", "message": "Hello from CallHuman. Do you like this?", "options": [ { "label": "Yes", "reply": "Great, have a nice day!" }, { "label": "No", "reply": "Thanks for trying anyway." } ] }' ``` ```js tab="JavaScript" const response = await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ to: "+34600111222", message: "Hello from CallHuman. Do you like this?", options: [ { label: "Yes", reply: "Great, have a nice day!" }, { label: "No", reply: "Thanks for trying anyway." }, ], }), }); const call = await response.json(); console.log(call); // { id: "call_x9f2k", status: "queued" } ``` ```python tab="Python" import os import requests response = requests.post( "https://api.callhuman.es/v1/calls", headers={"Authorization": f"Bearer {os.environ['CALLHUMAN_API_KEY']}"}, json={ "to": "+34600111222", "message": "Hello from CallHuman. Do you like this?", "options": [ {"label": "Yes", "reply": "Great, have a nice day!"}, {"label": "No", "reply": "Thanks for trying anyway."}, ], }, ) print(response.json()) # {"id": "call_x9f2k", "status": "queued"} ``` The API answers immediately with `202 Accepted` and the call `id`. Your phone rings a few seconds later. ## Step by step [#step-by-step] ### Create your account and project [#create-your-account-and-project] Sign in at [callhuman.es](https://www.callhuman.es/login) with your email, Google, Microsoft or GitHub. Create a project: its name is the business name people hear when they call your number back. ### Choose a plan [#choose-a-plan] Calls and phone numbers need an active plan. Until then the API answers [`subscription_required`](/docs/errors#subscription_required). After paying, pick the country of your phone number: it is assigned instantly. ### Create an API key [#create-an-api-key] In the dashboard go to **API keys → Create key**. Copy it now: it is shown only once. Save it as an environment variable: ```bash export CALLHUMAN_API_KEY="ch_live_xxxxxxxxxxxx" ``` ### Send the request [#send-the-request] Run the example above with your own number. Answer the phone, press 1 or say “yes”. ### Read the result [#read-the-result] ```bash curl https://api.callhuman.es/v1/calls/call_x9f2k \ -H "Authorization: Bearer $CALLHUMAN_API_KEY" ``` ```json { "id": "call_x9f2k", "status": "answered", "option_path": [1], "option_label": "Yes", "metadata": {} } ``` To get the result pushed to your server instead of polling, add a `webhook_url` to the request. See [Webhooks](/docs/webhooks). Use the [n8n node](/docs/n8n): fill in the phone, the message and the options, and connect one output per option. # Human approval for AI agents (/docs/recipes/agent-approval) Your agent wants to do something important — refund money, deploy, delete data. Before acting, it calls a human and waits. ## 1. The approval function [#1-the-approval-function] ```js const CALLHUMAN = "https://api.callhuman.es/v1/calls"; const headers = { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", }; /** Calls the approver and resolves to true (approved) or false. */ export async function askForApproval({ phone, action }) { const created = await fetch(CALLHUMAN, { method: "POST", headers, body: JSON.stringify({ to: phone, message: `Your agent wants to ${action}.`, options: [ { label: "Approve", reply: "Approved. Going ahead." }, { label: "Reject", reply: "Rejected. Nothing will happen." }, ], }), }).then((r) => r.json()); // Poll until the call ends (or use a webhook in production). for (;;) { await new Promise((r) => setTimeout(r, 5000)); const call = await fetch(`${CALLHUMAN}/${created.id}`, { headers }).then((r) => r.json()); if (["answered", "not_answered", "failed"].includes(call.status)) { return call.status === "answered" && call.option_label === "Approve"; } } } ``` ## 2. Use it as a tool [#2-use-it-as-a-tool] ```js const approved = await askForApproval({ phone: "+34600333444", action: "refund 1,240 euros to Acme Ltd for invoice 2231", }); if (!approved) throw new Error("Refund not approved by a human"); await refund(invoice); ``` ## Tips [#tips] - **Not answered means no.** Treat `not_answered` as a rejection, or escalate to a second approver. - Say exactly what will happen, with amounts and names: the person decides only from what they hear. - For agents that support MCP, a native server is [coming soon](/docs/mcp). # Confirm bookings by phone (/docs/recipes/booking-confirmation) A restaurant (or clinic, or workshop) calls guests a few hours before their booking. Guests confirm or cancel by keypress or voice, and your system updates the booking. ## 1. Create the call [#1-create-the-call] ```js await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": `booking-${booking.id}-reminder`, }, body: JSON.stringify({ to: booking.phone, language: booking.language ?? "en", message: `Hi! This is La Plaza about your table for ${booking.people} tonight at ${booking.time}.`, options: [ { label: "Confirm", reply: "Perfect, see you tonight!" }, { label: "Cancel", reply: "No problem, your booking is cancelled." }, ], webhook_url: "https://laplaza.example/hooks/callhuman", metadata: { booking_id: booking.id }, }), }); ``` ## 2. What the guest hears [#2-what-the-guest-hears] ## 3. Receive the answer [#3-receive-the-answer] ```js app.post("/hooks/callhuman", express.raw({ type: "application/json" }), async (req, res) => { if (!isValidSignature(req)) return res.sendStatus(401); // see /docs/webhooks const call = JSON.parse(req.body.toString("utf8")); const bookingId = call.metadata.booking_id; if (call.status === "answered" && call.option_label === "Confirm") await confirmBooking(bookingId); else if (call.status === "answered" && call.option_label === "Cancel") await cancelBooking(bookingId); else await flagForStaff(bookingId); // not answered, or nothing chosen res.sendStatus(200); }); ``` ## Tips [#tips] - Call **the same day**, 2–4 hours before: that's when no-shows can still be replaced. - Use the guest's language with `language`. - Unanswered calls are retried twice and never count towards your plan. # Confirm cash-on-delivery orders (/docs/recipes/cash-on-delivery) Cash-on-delivery orders get returned when the customer changes their mind. Confirm them before shipping, and keep extra choices in a submenu. ```json { "to": "+34600555666", "language": "es", "message": "Hola. Su pedido 1042 de 45 euros, contra reembolso, sale mañana.", "options": [ { "label": "Confirmar", "reply": "Perfecto, sale mañana." }, { "label": "Cancelar", "reply": "Su pedido queda cancelado." }, { "label": "Cambiar algo", "options": [ { "label": "Cambiar la dirección", "reply": "Le enviaremos un enlace por SMS para cambiarla." }, { "label": "Entregar otro día", "reply": "Le llamaremos para elegir el día." } ] } ], "webhook_url": "https://shop.example/hooks/callhuman", "metadata": { "order_id": "1042" } } ``` ## Handle every branch [#handle-every-branch] ```js switch (call.option_path.join(".")) { case "1": await shipOrder(call.metadata.order_id); break; case "2": await cancelOrder(call.metadata.order_id); break; case "3.1": await sendAddressChangeLink(call.metadata.order_id); break; case "3.2": await scheduleCallback(call.metadata.order_id); break; default: await holdOrder(call.metadata.order_id); // not answered or nothing chosen } ``` Using `option_path` instead of `option_label` keeps your code working if you reword the labels or translate them. See [Options, replies & submenus](/docs/options#submenus) for the submenu rules. # On-call alerts with acknowledgement (/docs/recipes/on-call-alerts) When an alert fires, call the on-call engineer. They acknowledge or pass it on; if nobody answers, you call the next person. ```js const people = ["+447700900123", "+447700900456", "+447700900789"]; export async function page(alert, index = 0) { if (index >= people.length) return notifyEveryoneByEmail(alert); await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ to: people[index], message: `${alert.title}. ${alert.summary}`, options: [ { label: "I'm on it", reply: "Thanks. The team knows you're on it." }, { label: "Pass to the next person" }, ], webhook_url: "https://ops.example/hooks/oncall", metadata: { alert_id: alert.id, index }, }), }); } // Webhook: escalate unless someone took it. export async function onCallResult(call) { const { alert_id, index } = call.metadata; if (call.status === "answered" && call.option_label === "I'm on it") return acknowledge(alert_id, index); return page(await getAlert(alert_id), index + 1); } ``` Calls with options are retried twice, 5 minutes apart, before ending as `not_answered`. For faster escalation, call the next person as soon as you get `not_answered` from the first. # Send verification codes by voice (/docs/recipes/voice-otp) Some users can't receive SMS (landlines, poor coverage, accessibility). Read the code to them instead, with just `to` and `message`. ```js export async function sendVoiceCode(phone, code) { const spaced = code.split("").join(" "); // "4829" → "4 8 2 9" const res = await fetch("https://api.callhuman.es/v1/calls", { method: "POST", headers: { Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ to: phone, message: `Your verification code is ${spaced}. Again, ${spaced}.`, }), }); if (!res.ok) throw new Error((await res.json()).error.message); return res.json(); // { id, status: "queued" } } ``` ## Why it fits codes [#why-it-fits-codes] - **One attempt, no retries**: a code is never read after it expired. - **No webhook needed**: your login flow just waits for the user to type the code. - Voicemail is never left, so codes don't end up stored on an answering machine. See [One-way messages](/docs/one-way-messages) for the details. # Webhooks (/docs/webhooks) When a call ends we send a `POST` with the result to the `webhook_url` of the call: ```json { "id": "call_x9f2k", "status": "answered", "option_path": [1], "option_label": "Confirm", "metadata": { "booking_id": "bk_1042" } } ``` The body is exactly what `GET /v1/calls/{id}` returns. ## Fields [#fields] | Field | Type | Description | |---|---|---| | `id` | string | Call ID returned when you created the call. | | `status` | string | `answered`, `not_answered` or `failed` (see below). | | `option_path` | integer[] | Keys leading to the chosen option. `[2]` = option 2 of the main menu; `[3, 1]` = option 1 of the submenu under option 3. Empty if nothing was chosen. | | `option_label` | string \| null | `label` of the chosen option, or `null`. | | `metadata` | object | The `metadata` you sent, unchanged. Use it to find your own record. | ## Statuses [#statuses] | `status` | Meaning | Counts towards your plan | |---|---|---| | `queued` | Waiting, or between retries | — | | `in_progress` | Ringing or on the call | — | | `answered` | The person picked up (with or without choosing an option) | Yes | | `not_answered` | No answer, busy or voicemail, after all retries | No | | `failed` | Invalid number or technical error | No | The webhook is sent once the call reaches a final status: `answered`, `not_answered` or `failed`. ## Verify the signature [#verify-the-signature] Every webhook is a `POST` with `Content-Type: application/json` and a `CallHuman-Signature` header: the **HMAC-SHA256 of the raw request body, as lowercase hex with no prefix**, using your project's **webhook secret** (dashboard → **Settings**). Compute it over the raw bytes you received — before parsing the JSON — and compare in constant time. ```js tab="Node.js (Express)" import crypto from "node:crypto"; import express from "express"; const app = express(); const secret = process.env.CALLHUMAN_WEBHOOK_SECRET; // Use the raw body: the signature is computed over the exact bytes we sent. app.post("/hooks/callhuman", express.raw({ type: "application/json" }), (req, res) => { const expected = crypto.createHmac("sha256", secret).update(req.body).digest("hex"); const received = req.get("CallHuman-Signature") ?? ""; const valid = received.length === expected.length && crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected)); if (!valid) return res.sendStatus(401); const call = JSON.parse(req.body.toString("utf8")); if (call.status === "answered" && call.option_label === "Confirm") { // markBookingConfirmed(call.metadata.booking_id); } res.sendStatus(200); }); app.listen(3000); ``` ```python tab="Python (Flask)" import hashlib import hmac import json import os from flask import Flask, abort, request app = Flask(__name__) SECRET = os.environ["CALLHUMAN_WEBHOOK_SECRET"].encode() @app.post("/hooks/callhuman") def callhuman_webhook(): raw = request.get_data() # raw bytes, before parsing expected = hmac.new(SECRET, raw, hashlib.sha256).hexdigest() received = request.headers.get("CallHuman-Signature", "") if not hmac.compare_digest(expected, received): abort(401) call = json.loads(raw) if call["status"] == "answered" and call["option_label"] == "Confirm": pass # mark_booking_confirmed(call["metadata"]["booking_id"]) return "", 200 ``` ## Retries [#retries] Respond with any `2xx` status **within 10 seconds** (do slow work after responding). If your server returns an error or times out, we retry **up to 5 times: after 1, 5, 15, 30 and 60 minutes**. The same result can therefore arrive more than once: make your handler **idempotent** and ignore duplicates by `id`. ## No webhook? [#no-webhook] `webhook_url` is optional. You can poll `GET /v1/calls/{id}` instead — useful for scripts and tests: ```bash curl https://api.callhuman.es/v1/calls/call_x9f2k \ -H "Authorization: Bearer $CALLHUMAN_API_KEY" ``` # Create a call (/docs/api-reference/createCall) `POST https://api.callhuman.es/v1/calls` Calls the person and reads the message. With `options`, the person answers by keypress or voice and you get the chosen option back. Only transactional calls are allowed: before calling we check what the person will hear and reject marketing, sales, scams and unsolicited messages (`call_not_allowed`). Validation order: 401 → 402 → 403 → 429 → 422. ## Parameters | Name | In | Required | Description | |---|---|---|---| | `Idempotency-Key` | header | No | Optional unique key, any string up to 255 characters (for example `booking-1042-confirmation` or a UUID). Repeating a request with the same key within 24 hours returns the original response — even if the body changed — and never places a second call. | ## Body fields | Field | Type | Required | Description | |---|---|---|---| | `to` | string | Yes | Phone number to call, in international E.164 format (with + and country code). Must be in a supported country. | | `message` | string | Yes | Text read out loud when the person answers. Your plan limits the total length of `message` plus every `label` and `reply`. | | `options` | Option[] | No | Options the person can choose, by keypress or by voice. Up to 9 per menu. Omit it for a one-way message: the text is read once and the call ends (one attempt, no retries). | | `language` | string | No | Language the message and menus are read in (ISO 639-1 code). Defaults to `en`. Common: en, es, fr, de, it, pt. An unsupported code returns `invalid_request` listing the supported ones. Default `en`. | | `webhook_url` | string | No | HTTPS URL (max 2,048 characters) that receives the result as a JSON POST (see the `callResult` webhook). Optional: you can also poll `GET /calls/{id}`. | | `metadata` | object | No | Any JSON object you want back (max 4 KB serialized), returned unchanged in the result. Typically your own record ID. | ### Option object One option offered to the person. The first option of a menu is key 1, the second key 2, and so on (up to 9). Give it a `reply` to say something back after it is chosen, or `options` to open a submenu instead. `reply` and `options` cannot be used together. | Field | Type | Required | Description | |---|---|---|---| | `label` | string | Yes | What is offered, read as “Press 1 or say