# Benerra AI developer docs > Integrator documentation for Benerra AI voice agents (https://app.benerra.ai). Source: https://docs.benerra.ai/ . Version 1.0, December 2026. Integrator documentation Connect your CRM, lead sources and phone system to Benerra voice agents. Push contacts in, receive call results out, read calls and statistics, and route SIP calls into an agent. ## Overview Benerra AI runs voice agents that make and answer phone calls. An agent talks to the client in a natural voice, follows the conversation plan you configure, records the result as an [outcome](https://docs.benerra.ai/#outcomes) and extracts the fields you asked for. Everything is managed in the cabinet at [app.benerra.ai](https://app.benerra.ai). This page covers what you need to connect your own systems. There are four integration points: - [**Contacts in:** Send each new lead to a source URL. Benerra queues it in a campaign and calls it.](https://docs.benerra.ai/#contact-intake) - [**Results out:** Receive a signed JSON webhook after every call with the outcome, summary, fields and recording.](https://docs.benerra.ai/#webhooks) - [**Read API:** Read calls, contacts, campaigns and statistics with a project API key.](https://docs.benerra.ai/#calls) - [**SIP:** Dial through your own trunk, or transfer calls from your PBX into an agent with SIP headers.](https://docs.benerra.ai/#sip) ### Base URL and formats - **Base URL:** `https://app.benerra.ai/api/v1` - **Format:** JSON in and out, UTF-8. - **Times:** ISO 8601 in UTC with a trailing `Z`, for example `2026-12-01T09:30:00Z`. Parameters named `date_from` and `date_to` take calendar days (`YYYY-MM-DD`) in your organization time zone (UTC unless set otherwise). - **Phone numbers:** International format with country code, digits only or with a leading `+`. - **Machine-readable spec:** `GET https://app.benerra.ai/api/v1/openapi-external.json` describes every method available with an API key. No authentication needed. ## Quick start A typical lead-calling integration takes five steps. 1. **Create an agent and a campaign.** In the cabinet, build the agent in a project, then create a campaign (shown as a wave in the cabinet) that uses it. Set calling hours, attempts and the retry plan on the campaign. 2. **Create a contact source.** In Integrations, add a source, choose the campaign it delivers to and copy the source URL and secret. Turn on delivery when you are ready. 3. **Push a test contact.** Send one request with `"test": true` to check authentication and field mapping without calling anyone. ```bash curl -X POST "https://app.benerra.ai/api/v1/intake/hook/YOUR_SOURCE_TOKEN" \ -H "Content-Type: application/json" \ -H "X-Webhook-Secret: YOUR_SOURCE_SECRET" \ -d '{"test": true, "phone": "+15550100123", "external_id": "lead-1001", "variables": {"client_name": "John", "city": "Austin"}}' ``` 4. **Add a webhook.** In Webhooks, add an API webhook with your URL (for example `https://YOUR_DOMAIN/benerra/webhook`), a secret, and the events `call_completed` and `lead_detected`. Press Test to receive a sample payload and check the [signature](https://docs.benerra.ai/#webhook-signature). 5. **Issue an API key** in API keys with the permissions you need (for example `calls_read` and `stats`) and read results: ```bash curl "https://app.benerra.ai/api/v1/calls/?project_id=YOUR_PROJECT_ID&limit=20" \ -H "X-API-Key: YOUR_API_KEY" ``` Then send real contacts without the `test` flag. Each contact is called according to the campaign schedule, and each finished call produces one webhook. ## Concepts | Term | Meaning | |---|---| | Organization | Your account (cabinet). Holds users, projects, phone trunks and billing. Has a time zone used for daily reports. | | Project | A container inside the organization for agents, campaigns, calls and webhooks. API keys are bound to one or several projects. Identified by `project_id`. | | Agent | A configured voice agent: role, voice, language, conversation plan, outcomes and fields to extract. Has an internal `agent_id` and a short `agent_code` used in SIP headers and API calls. Codes are unique inside an organization. | | Campaign | An outbound calling run (called a wave in the cabinet): one or several agents, a contact list, calling hours, an attempt limit and a retry plan. Identified by `campaign_id`. | | Contact source | A URL that accepts leads from your system and delivers them to a campaign. See [Contact intake](https://docs.benerra.ai/#contact-intake). | | Contact | A phone number with optional data (name, city, order number, custom variables). A contact accepted from a source gets a `contact_id` you can track. | | Call | One phone call: outbound from a campaign, inbound, a transfer from your PBX, or a test. Identified by `call_id`. Holds the transcript, summary, outcome, extracted fields and recording link. | | Outcome | The business result of a call, for example `client_apruv` (lead) or `voicemail_detected`. See [Outcomes](https://docs.benerra.ai/#outcomes). | | Extracted fields | Structured data the agent collected during the call (for example name, preferred time, comments). You define them on the agent. | | Trunk | A SIP connection used to place or receive calls. See [SIP integration](https://docs.benerra.ai/#sip). | | Webhook | A destination that receives call results: your HTTP endpoint, Telegram, email or a Google Sheet. | Typical flow: your system sends a contact to a source, the source delivers it to a campaign, the dialer calls it during calling hours, the agent talks, the call ends with an outcome, and Benerra sends the result to your webhook. If the outcome allows another attempt, the contact is called again later according to the retry plan. ## Authentication and API keys Server integrations authenticate with an API key in the `X-API-Key` header. Keys are issued in the cabinet in API keys by an organization admin. A key looks like `mk_live_` followed by 48 hex characters. It is shown once at issue time; Benerra stores only a hash, so keep it in your secret store. ```http GET /api/v1/calls/count?project_id=YOUR_PROJECT_ID HTTP/1.1 Host: app.benerra.ai X-API-Key: YOUR_API_KEY ``` The text test API and the MCP endpoint also accept `Authorization: Bearer YOUR_API_KEY`. ### Key scope - **One project** or **several projects** of the same organization. Requests for any other project get `403`. - **Whole organization.** Issued by Benerra staff on request, read-only, with the `calls_read` permission only. It cannot be used for call control. A key stops working when it is revoked, when all of its projects are deleted, or when the organization is archived. The cabinet shows when and from which IP each key was last used and keeps a log of key changes. ### Permissions Each key carries a set of permissions. A request without the needed permission gets `403` with code `permission_denied` and the field `permission`. | Permission | Grants | |---|---| | `calls_read` | Calls: `GET /calls/`, `/calls/count`, `/calls/{call_id}`, `/calls/by-order/{id_order}`, `/calls/contacts-report`, `/contacts/{contact_id}`, `/contacts/{contact_id}/calls`, campaign list, the text test API and the MCP endpoint. | | `contacts` | Contact lists: `GET /contacts/` and `/contacts/count`. Needs `calls_read` as well. | | `stats` | Call statistics: `GET /stats/calls`. | | `deliveries` | Webhook deliveries of a call and redelivery: `GET /calls/{call_id}/deliveries`, `POST /calls/{call_id}/redeliver`. | | `demo_links` | Create, list, extend and revoke public demo links to agents: `/demo-links`. | | `call_control` | Lead gate for your CRM: `/call-control/external/agents-status`, `gate-check`, `record-lead`. Project keys only. | | `agents_read` | Agent configuration and versions (`/external/agents/...`). Granted by Benerra on request, not in the cabinet. | Keys created before permissions existed and keys with an empty permission list behave as `call_control` plus `calls_read`. Read routes are read-only: a key cannot change agents, campaigns or calls. ## Errors and rate limits Every error returned to a request with an API key has a human-readable `detail` and a machine `code`. Some errors add fields such as `permission` or `project_id`. ```json {"detail": "Key has no permission: stats", "code": "permission_denied", "permission": "stats"} ``` | HTTP | code | When | |---|---|---| | 400 | `bad_request`, `period_too_long` | Invalid parameter or a period longer than allowed. | | 401 | `unauthorized`, `invalid_key` | Missing key, or the key is unknown or revoked. | | 403 | `permission_denied` | The key lacks the permission named in `permission`. | | 403 | `forbidden`, `key_scope_inactive` | Project outside the key scope, or all key projects or the organization are inactive. | | 404 | `not_found` | Unknown call, contact or agent, or one outside the key scope. | | 409 | `conflict`, `ambiguous_project`, `already_delivered` | Conflicting state, for example an agent code found in several key projects (pass `project_id`). | | 422 | `validation_error`, `redeliver_not_allowed` | Body or query did not validate, or the action is not allowed. | | 429 | `too_frequent` | A per-method limit was hit. Wait for `Retry-After` seconds. | | 503 | `rate_limited` | The per-key rate limit was hit. Wait for `Retry-After` seconds. | | 503 | `unavailable` | The platform is busy or the query took too long. Retry later or narrow the filter. | ### Rate limits | Scope | Limit | |---|---| | Any request with a key | 20 requests per second on average, bursts up to 60. Exceeding it returns `503` with `rate_limited` and `Retry-After`. | | `GET /stats/calls` | 20 requests per minute per key (`429 too_frequent`). | | `POST /calls/{call_id}/redeliver` | Once per minute per call. | | Agent configuration | 60 requests per minute per key. | | Text test sessions | 20 new sessions per 10 minutes per key, plus a cap on open sessions. | | MCP endpoint | 60 tool calls per minute per key; heavy reports are limited per organization. | Always honor `Retry-After`. For bulk reads, page with `skip` and `limit` and filter by time instead of re-reading everything. ## Contact intake A contact source is a URL that accepts leads from your system and delivers them to a campaign. Create it in the cabinet in Integrations. You get a source URL with a private token and a secret. `POST https://app.benerra.ai/api/v1/intake/hook/{endpoint_token}` ### Authentication - Send the source secret in the `X-Webhook-Secret` header. The header name can be changed on the source. - Optionally restrict the source to an IP allow list (up to 50 addresses or subnets). With an allow list, a request from an allowed IP is accepted with or without the secret; a wrong secret is still rejected. - After you rotate the secret, the old one keeps working for a grace period of up to 72 hours so you can switch without losing leads. A wrong token, a disabled source or a wrong secret returns `401`. ### Request body JSON is recommended; URL-encoded form bodies are also parsed. The body may be up to 1 MB. The source finds the fields in one of two ways, chosen on the source: - **Automatic detection** (default). The phone is taken from a key such as `phone`, `phone_number`, `telephone`, `tel`, `mobile`, `cell`, `msisdn`, `customer_phone` or `lead_phone`, at any depth. The value must look like a phone number with 10 to 15 digits. Your lead id is taken from `external_id`, `id`, `lead_id` or `uuid`; a comment from `comment`, `note` or `message`. - **Explicit paths.** You point each field to a path in your body (for example `lead.contact.phone`) and confirm the mapping in the cabinet. Data for the conversation goes into a `variables` (or `fields`) object next to the phone. These values fill [prompt variables](https://docs.benerra.ai/#variables) such as `{CLIENT_NAME}` and `{CITY}`. If the source variable mode is set to automatic, plain keys such as `name`, `first_name`, `city`, `product`, `age` and `gender` are picked up as well. ```json { "external_id": "lead-1001", "phone": "+15550100123", "comment": "Requested a call back from the pricing page", "variables": { "client_name": "John Smith", "city": "Austin", "offer": "Annual plan", "price": "199 USD", "plan_tier": "gold" } } ``` - Variable keys: lowercase letters, digits and underscores, up to 32 characters. Values: plain text up to 120 characters; braces and angle brackets are removed. - Built-in keys are recognized in several spellings, for example `name`, `client_name` and `first_name` all mean the client name. - Any other key (such as `plan_tier` above) becomes a custom variable the agent can use as `{plan_tier}`. - Send `"test": true` to submit a test event. It runs authentication and parsing and shows in the source journal, but nobody is called. ### One contact or a list By default one request carries one contact. If the source has Split lists enabled, a JSON array of 2 to 200 objects is accepted and each object becomes its own contact. In the detailed response mode a request that contains several contacts is rejected with `multiple_contacts`; send them one at a time. ### Response The response format is a source setting. **Simple mode** answers `200` with `{"status": "ok"}` once the request is stored. Processing continues in the background; check the result with the [Contacts API](https://docs.benerra.ai/#contacts-api) or the `contact_delivery` [webhook event](https://docs.benerra.ai/#webhook-events). **Detailed mode** answers with the decision for the contact: ```json { "status": "ok", "contact": { "phone": "15550100123", "contact_id": "6f1c2a9e-3b7d-4d55-9a0e-2c8f4b1e7a10", "status": "accepted", "delivery": "queued", "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11" } } ``` | delivery | Meaning | |---|---| | `queued` | The contact is in the campaign queue and will be called. | | `waiting` | Accepted, but not delivered yet. `waiting_reason` and `message` say why; it is delivered automatically once the cause is resolved. | | `processing` | Accepted, the decision is still being made. | A rejected contact comes back as `"status": "rejected"` inside `contact`, with `reason` and `message`. For duplicates, `contact_id` points to the earlier contact. ```json { "status": "ok", "contact": { "phone": "15550100123", "status": "rejected", "reason": "duplicate_phone", "message": "duplicate_phone", "contact_id": "6f1c2a9e-3b7d-4d55-9a0e-2c8f4b1e7a10" } } ``` | Rejection reason | Meaning | |---|---| | `no_phone` | No phone number found in the body. | | `multiple_contacts` | Several contacts in one request (detailed mode). | | `missing_group_field` | The source routes by a group field and it is missing. | | `duplicate_phone` | The number is already in the campaign. | | `repeat_too_frequent` | The same contact was sent again too soon. | | `country_not_allowed` | The number does not match the allowed country prefixes of the source. | | `phone_blocked`, `do_not_call` | The number is on a block list or a do-not-call list. | | `own_number` | The number is one of your own caller numbers. | | `delivery_limit` | The hourly or daily limit of the source is reached. | | Waiting reason | Meaning | |---|---| | `delivery_off` | Delivery to a campaign is turned off on the source. | | `setup_pending` | The field mapping is not confirmed yet. | | `no_wave` | No campaign is assigned for this contact or its group. | | `no_project` | The contact group is not assigned to a project yet. | | `project_paused` | Delivery to the project is paused. | | `wave_draft`, `wave_completed` | The campaign is a draft or completed; the contact is delivered when it starts or resumes. | | `too_old` | The event is older than the source allows (72 hours by default). | | `delivery_limit` | The source delivery limit is reached. | Errors in detailed mode use `{"status": "error", "code": "...", "message": "..."}`: `invalid_body` and `empty_body` (`400`), `body_too_large` (`413`), `temporary_error` (`503`, resend the request). A source disabled by Benerra answers with code `source_disabled`. **Retries on your side.** Resend only on network errors, `5xx` or `temporary_error`. A repeated request with the same `external_id` is safe: duplicates are detected and reported as `duplicate_phone` or `repeat_too_frequent` rather than called twice. ## Contacts API Track contacts accepted from sources, files and manual adds. `GET /api/v1/contacts/` (permission: contacts + calls_read) | Parameter | Description | |---|---| | `received_from`, `received_to` | ISO 8601 UTC. Default: the last 7 days. At most 31 days. | | `source_id`, `group_id`, `campaign_id` | Filter by source, source group or campaign. | | `delivery` | `queued`, `waiting`, `rejected`, `processing`, comma-separated. | | `reason` | Waiting or rejection reason code. | | `intake_external_id` | Your lead id. | | `phone` | Phone number. | | `skip`, `limit` | Paging; `limit` default 500, max 1000. | ```json [ { "contact_id": "6f1c2a9e-3b7d-4d55-9a0e-2c8f4b1e7a10", "received_at": "2026-12-01T14:02:11Z", "phone": "15550100123", "intake_external_id": "lead-1001", "source_id": "a91e0c33-5d2b-4f8e-b6a7-0e4d9c2f1b58", "origin": "intake", "group_id": null, "group_name": null, "client_id": null, "client_name": null, "delivery": "queued", "reason": null, "message": null, "delivery_changed_at": "2026-12-01T14:02:12Z", "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "calls": 2, "last_call_outcome": "client_apruv" } ] ``` `GET /api/v1/contacts/count` (permission: contacts + calls_read) Same filters, returns `{"total": 42}`. `GET /api/v1/contacts/{contact_id}` (permission: calls_read) The contact card: `status`, `reason`, `message`, `phone`, `campaign_id`, `external_id`, `group_id`, `group_name`, `accepted_at`, `delivery`, `delivery_changed_at` and, while waiting, `waiting_reason`. `GET /api/v1/contacts/{contact_id}/calls` (permission: calls_read) The contact card plus `calls`: every call made to this contact, newest first (up to 500). Add `last=1` to get only the latest call. Organization-wide keys also receive `intake_payload`, the parsed body you originally sent. ## Campaigns API Campaigns are created and launched in the cabinet. With a key you can list them and read their progress. `GET /api/v1/campaigns/?project_id={project_id}` (permission: calls_read) | Parameter | Description | |---|---| | `project_id` | Required. | | `status` | Filter by [campaign status](https://docs.benerra.ai/#statuses). | | `folder_id` | Campaign folder, or `none` for campaigns without a folder. | | `archived` | `all` (default for keys), `only` or `hide`. | | `skip`, `limit` | Paging; `limit` default 100, max 500. The response has `next_skip`, or `null` on the last page. | ```json { "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "skip": 0, "limit": 100, "next_skip": null, "waves": [ { "id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "name": "December leads", "folder_id": null, "folder_name": null, "status": "active", "lifecycle_status": "active", "waiting_contacts": false, "stop_reason": null, "archived": false, "is_template": false, "created_at": "2026-11-28T10:00:00Z", "started_at": "2026-11-28T10:05:00Z", "completed_at": null, "archived_at": null, "agent_ids": ["0d7e9a1c-4b2f-4e8a-a3c6-5f1b2d9e7c40"], "total_contacts": 1840, "contacts_called": 1215 } ], "templates": [], "folders": [], "statuses": {"draft": "draft, never launched", "pending": "waiting for launch"} } ``` The `statuses` object in the live response explains every status value. Templates are listed separately: they do not call anyone and do not accept contacts. `GET /api/v1/campaign-folders/?project_id={project_id}` (permission: calls_read) Campaign folders of the project: `id`, `name`, `sort_order`, `waves_count`, `archived_count`. ### Per-contact campaign results `GET /api/v1/calls/contacts-report?project_id=&campaign_id=` (permission: calls_read) One row per contact of the campaign. The contact result is its last call in the campaign; `finished: true` means no more calls will be made to it (final outcome or attempt limit reached). Parameters: `date_from`, `date_to`, `finished_only`, `skip`, `limit` (max 1000). Page with `next_skip`. ```json { "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "skip": 0, "limit": 100, "next_skip": 100, "items": [ { "contact_id": "6f1c2a9e-3b7d-4d55-9a0e-2c8f4b1e7a10", "phone": "15550100123", "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "added_at": "2026-12-01T14:02:12Z", "attempts": 2, "first_call_at": "2026-12-01T14:05:40Z", "last_call_at": "2026-12-01T16:31:02Z", "finished": true, "state": "finished", "last_call": { "id": "3e8b1f42-7c6d-4a9e-b0f1-2d5c8a7e6b93", "started_at": "2026-12-01T16:31:02Z", "outcome": "client_apruv", "outcome_label": "Agreed", "duration_seconds": 148, "wave_call_attempt": 2, "wave_is_last_call": true, "extracted_fields": {"call_comments": "Wants a demo on Friday"} } } ] } ``` A related method, `GET /api/v1/calls/contacts-added?project_id=&campaign_id=`, returns how many numbers were added to the campaign per day (`tz` sets the day time zone, default `UTC`). ## Calls API `GET /api/v1/calls/?project_id={project_id}` (permission: calls_read) Calls of a project, newest first. Each item is a [call record](https://docs.benerra.ai/#call-record). | Parameter | Description | |---|---| | `project_id` | Required. | | `campaign_id`, `ai_agent_id` | Filter by campaign or agent. | | `call_status`, `call_outcome`, `call_type` | Filter by [status](https://docs.benerra.ai/#statuses), [outcome](https://docs.benerra.ai/#outcomes) or type (`inbound`, `outbound`, `test`). | | `started_from`, `started_to` | Call start time, ISO 8601 UTC (`started_to` is exclusive). | | `date_from`, `date_to` | Calendar days `YYYY-MM-DD` in the project time zone. | | `updated_since` | Only calls changed at or after this moment (ISO 8601 UTC). Use it for incremental sync; the start window is at most 2 days. | | `search` | Phone number or part of it. | | `country` | Country code of the number, for example `US`, `GB`, `FR`. | | `intake_contact_id`, `intake_external_id` | Calls of one contact by its `contact_id` or by your lead id. | | `last_per_contact`, `finished_only` | Only the last call of each campaign contact; optionally only finished contacts. | | `skip`, `limit` | Paging; `limit` default 500, max 1000. | ```python import requests BASE = "https://app.benerra.ai/api/v1" HEADERS = {"X-API-Key": "YOUR_API_KEY"} def calls_since(project_id, since_iso): skip = 0 while True: r = requests.get(f"{BASE}/calls/", headers=HEADERS, timeout=60, params={ "project_id": project_id, "updated_since": since_iso, "skip": skip, "limit": 500}) r.raise_for_status() page = r.json() yield from page if len(page) < 500: break skip += 500 ``` `GET /api/v1/calls/count?project_id={project_id}` (permission: calls_read) Same filters, returns `{"total": 1215}`. `GET /api/v1/calls/{call_id}` (permission: calls_read) One call record. For campaign calls it also includes the calling plan fields (see [wave plan fields](https://docs.benerra.ai/#webhook-payload)). `GET /api/v1/calls/by-order/{id_order}` (permission: calls_read) All calls for your lead or order number (the value you passed as `X-Lead-ID` or as the contact order id), oldest first, up to 50, with the dialog turn by turn. `format=text` returns plain text, `format=log` the full call log; `with_log=true` adds the log to the JSON. ```json { "id_order": "ORD-48213", "total": 1, "calls": [ { "call_id": "3e8b1f42-7c6d-4a9e-b0f1-2d5c8a7e6b93", "id_order": "ORD-48213", "phone_number": "15550100123", "call_type": "inbound", "started_at": "2026-12-01T16:31:02Z", "started_at_local": "2026-12-01 10:31:02", "timezone": "America/Chicago", "duration_seconds": 148, "call_outcome": "client_apruv", "outcome_final": true, "agent_code": "101", "agent_name": "Emma", "recording_url": "https://app.benerra.ai/recordings/...", "external_call_id": "crm-call-7781", "call_direction": "in", "wave_call_attempt": null, "dialog": [ {"time": "10:31", "role": "bot", "text": "Hello, this is Emma from Acme."}, {"time": "10:31", "role": "client", "text": "Hi, yes."} ] } ] } ``` `outcome_final` is `false` while field extraction is still running right after the call; read again a few seconds later. ## Call record fields A call record returned by `GET /calls/` and `GET /calls/{call_id}`. Fields without a value may be `null` or missing. | Field | Type | Description | |---|---|---| | `id`, `_id` | string | Call id (both keys carry the same value). | | `project_id` | string | Project of the call. | | `campaign_id` | string | Campaign, for campaign calls. | | `contact_id` | string | Campaign contact card. | | `intake_contact_id` | string | The `contact_id` from contact intake, when the contact came from a source. | | `ai_agent_id` | string | Agent that handled the call. | | `call_type` | string | `outbound`, `inbound` or `test`. | | `call_direction` | string | `in` or `out` as reported by your PBX in `X-Call-Dir`. | | `phone_number` | string | Client number. | | `caller_number` | string | Number the call came from or was placed with. | | `id_country` | string | Country code of the client number. | | `id_order` | string | Your lead or order number (`X-Lead-ID` or contact data). | | `external_call_id` | string | Your call id from `X-Call-ID`. | | `client_name`, `offer_name` | string | From `X-Client-Name` and `X-Offer-Name`. | | `sip_headers` | object | All `X-*` SIP headers received with the call. | | `call_status` | string | Technical status, see [Statuses](https://docs.benerra.ai/#statuses). | | `call_outcome` | string | Business outcome, see [Outcomes](https://docs.benerra.ai/#outcomes). | | `started_at`, `answered_at`, `ended_at` | string | UTC times. `answered_at` is empty when nobody answered. | | `duration_seconds` | integer | Talk time in seconds. | | `hangup_by` | string | Who ended the call. | | `transcript` | string | Conversation text. | | `call_summary` | string | Short summary of the call. | | `key_points`, `action_items` | array | Highlights and follow-ups, when produced. | | `sentiment`, `sentiment_score` | string, number | `positive`, `negative` or `neutral`; score from -1 to 1. | | `extracted_fields` | object | Fields the agent collected, keyed by the field names you configured. | | `recording_url` | string | Link to the call recording. | | `contact_vars` | object | Variables the call was made with (from a source, file or SIP headers). | | `sip_status_code`, `sip_status` | integer, string | Final SIP response of a failed dial attempt. | | `attempt_no`, `wave_call_attempt`, `wave_is_last_call` | integer, boolean | Attempt number of the contact in the campaign, and whether no more calls will follow. | | `trunk_id` | string | Trunk the call went through. | | `created_at` | string | Record creation time. | Fields that may hold special-category personal data are removed from `extracted_fields` for keys and users below organization admin. ## Call statistics `GET /api/v1/stats/calls` (permission: stats) A summary, not a list: totals and optional groups for a period of up to 31 days. The default period is the last 7 days in the organization time zone. | Parameter | Description | |---|---| | `project_id` | Projects, comma-separated. Default: all projects of the key. | | `date_from`, `date_to` | Organization-local days, inclusive. | | `started_from`, `started_to` | ISO 8601 UTC instead of days (`started_to` exclusive). | | `campaign_id` | One campaign. | | `ai_agent_id` | Agent ids, comma-separated. | | `group_by` | One or two of `day`, `project`, `campaign`, `agent`, `outcome`. | ```json { "period": {"from": "2026-11-25T06:00:00Z", "to": "2026-12-02T06:00:00Z", "from_date": "2026-11-25", "to_date": "2026-12-01", "timezone": "America/Chicago"}, "group_by": ["day"], "totals": {"calls": 3120, "answered": 1904, "minutes": 4410, "billed_minutes": 4022, "outcomes": {"client_apruv": 214, "client_reject": 388, "voicemail_detected": 702}}, "groups": [ {"day": "2026-11-25", "calls": 402, "answered": 251, "minutes": 590, "billed_minutes": 541, "outcomes": {"client_apruv": 31, "client_reject": 47}} ] } ``` `minutes` rounds each call up to a whole minute. `billed_minutes` applies your organization billing rule: test calls and calls ending as silence (and voicemail, unless your plan bills voicemail) are not billed. Groups by agent also carry `agent_code` and `agent_name`; by project and campaign, their names. ## Deliveries and redelivery `GET /api/v1/calls/{call_id}/deliveries` (permission: deliveries) All webhook deliveries of a call to webhooks visible to the key, grouped by webhook and event. Request and response bodies are not returned. ```json [ { "webhook_id": "9d3f6a20-1c4e-4b7a-8e52-6f0a1b3c9d71", "webhook_name": "CRM", "webhook_type": "api", "event": "lead_detected", "result": "delivered", "attempts": [ {"at": "2026-12-01T16:33:41Z", "status": "timeout", "http_code": null, "duration_ms": 10012, "retry": false, "log_id": "..."}, {"at": "2026-12-01T16:34:45Z", "status": "delivered", "http_code": 200, "duration_ms": 184, "retry": true, "log_id": "..."} ] } ] ``` Attempt `status`: `delivered`, `failed`, `timeout`, `pending`, `skipped` (filtered out by the webhook settings). Group `result`: `delivered`, `pending` (an automatic retry is scheduled), `skipped` or `failed`. `POST /api/v1/calls/{call_id}/redeliver` (permission: deliveries) Sends the result again with the same body as the first time, the same as manual resend in the cabinet. Body (optional): `{"webhook_id": "..."}` to redeliver to one webhook. Only API webhooks are redelivered, and deliveries that already succeeded are not repeated. ```json {"status": "queued", "call_id": "3e8b1f42-7c6d-4a9e-b0f1-2d5c8a7e6b93", "queued": [{"webhook_id": "9d3f6a20-1c4e-4b7a-8e52-6f0a1b3c9d71", "event": "lead_detected"}]} ``` Status `202` means queued; check the outcome with `deliveries`. Other answers: `409 already_delivered`, `422 redeliver_not_allowed`, `404 not_found`, `429 too_frequent` (once per minute per call). ## Call control A lead gate for CRMs that route leads to agents themselves. Daily lead limits and on or off switches per agent are set in the cabinet in Call control. Requires a project key with `call_control`. If the key covers several projects, pass `project_id` or an `agent_code` that exists in one of them. `GET /api/v1/call-control/external/agents-status` (permission: call_control) Parameters: `agent_code`, `project_id`, `include_inactive`. ```json { "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "project_name": "Sales US", "inbound_enabled": true, "outbound_enabled": true, "agents": [ { "agent_code": "101", "agent_id": "0d7e9a1c-4b2f-4e8a-a3c6-5f1b2d9e7c40", "name": "Emma", "enabled": true, "max_leads_day": 100, "leads_today": 47, "remaining": 53, "accepting_leads": true, "state": "active" } ] } ``` `remaining` is `-1` when the agent has no daily limit. `state` is `active`, `archived` or `deleted`. `GET /api/v1/call-control/external/gate-check?agent_code=101&lead_id=ORD-48213` (permission: call_control) A quick yes or no before you send a call. Returns `{"result": "allow", "reason": "gate_open"}` or `{"result": "reject", "reason": "limit_reached"}`. Reject reasons: `inbound_disabled`, `agent_disabled`, `limit_reached`. When the agent has a limit and you pass `lead_id`, an allowed lead is counted at once. An unknown agent code is allowed (fail-open) with reason `agent_not_found_failopen`. `POST /api/v1/call-control/external/record-lead` (permission: call_control) ```json {"project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "agent_code": "101", "lead_id": "ORD-48213"} ``` Counts a lead for the agent (`agent_id` or `agent_code`). The same `lead_id` is counted once. Answer: `{"status": "accepted", "is_new_lead": true, "leads_today": 48, "max_leads_day": 100, "remaining": 52, "accepting_leads": true}`, or `"status": "rejected"` with reason `agent_disabled` or `limit_reached`. ## Agent configuration Read-only access to an agent setup, for audits and for keeping your own copy of scripts in version control. Requires the `agents_read` permission, which Benerra grants on request. `GET /api/v1/external/agents/{agent_code}/config` (permission: agents_read) Returns `agent_code`, `name`, `project_id`, `updated_at`, `created_at`, `prompt` (the role text), `voice` (`tts_engine` as a public tier name such as Premium or Standard+, and `language`), `behavior` (conversation plan, rules, outcomes in `actions`, fields to extract in `lead_transfer_fields`, greetings, silence and callback settings, and `model` as a public tier name), `skills` attached to the agent, `versions_total` and `last_version`. `GET /api/v1/external/agents/{agent_code}/versions` (permission: agents_read) Saved versions, newest first: `version`, `changed_at`, `changed_by`, `change_summary`, `change_comment`. Paging with `skip` and `limit` (max 200). `GET /api/v1/external/agents/{agent_code}/versions/{version}` (permission: agents_read) The configuration as it was before that save, in the same shape as `config`. ## Text test API Talk to an agent in text instead of voice, for automated regression tests of your scripts. The agent runs the same logic as on a call: conversation plan, outcomes and field extraction. Requires `calls_read`. Base path `/api/v1/testing/text`. `GET /api/v1/testing/text/agents` (permission: calls_read) Agents available to the key: `agent_id`, `agent_code`, `name`. `POST /api/v1/testing/text/sessions` (permission: calls_read) Body: `agent_id` or `agent_code`, and optional `start_stage_index` to start from a later stage of the plan. Returns the session. `POST /api/v1/testing/text/sessions/{session_id}/messages` (permission: calls_read) Body: `{"text": "Hi, yes, I can talk", "wait_sec": 50}`. Waits up to `wait_sec` (1 to 55 seconds) for the agent reply and returns the session. Send only when `can_send` is `true`; while the agent is still replying the answer is `409`. `GET /api/v1/testing/text/sessions/{session_id}?since=0` (permission: calls_read) The session state; `since` skips transcript lines you already have. After the session ends, `result` holds the final call result. `GET /api/v1/testing/text/sessions` (permission: calls_read) Open sessions of the key projects. `DELETE /api/v1/testing/text/sessions/{session_id}` (permission: calls_read) Closes the session. Close sessions you no longer need: the number of open sessions per key is capped. ```json { "session_id": "test-7c41a2", "agent_id": "0d7e9a1c-4b2f-4e8a-a3c6-5f1b2d9e7c40", "agent_name": "Emma", "status": "ready", "close_reason": "", "can_send": true, "stage": {"index": 2, "total": 5, "title": "Qualify"}, "outcome": "", "outcome_label": "", "fields": {}, "transcript": [ {"role": "bot", "text": "Hello, this is Emma from Acme. Is now a good time?", "t": 1.8}, {"role": "client", "text": "Hi, yes, I can talk", "t": 6.2}, {"role": "bot", "text": "Great. Which city are you in?", "t": 7.9} ], "transcript_total": 3, "notes": [], "age_sec": 9, "idle_close_in_sec": 290 } ``` Session `status`: `connecting`, `ready`, `replying`, `ended`, `closed`, `failed`. ## Demo links A demo link is a public page where anyone with the link talks to one agent live in the browser, by voice, without a cabinet account. Use it to show an agent to a prospect, a client or a colleague. Links are created in the cabinet (Testing or the agent menu, Share demo link) or through this API. Requires `demo_links`. Base path `/api/v1/demo-links`. The cabinet session token (`Authorization: Bearer`) works too. Every conversation is saved as a test call with the transcript and recording in the Testing area of the cabinet, apart from production statistics. Test calls are not sent to your webhooks. `POST /api/v1/demo-links` (permission: demo_links) Creates a link. Body fields: | Field | Type | Description | |---|---|---| | `agent_id` | string, required | The agent. It must be active and in a project of the key. | | `ttl_hours` | integer, required | How long the link works, 1 to 720 hours (30 days). | | `title` | string | Headline shown to the guest, up to 120 characters. Without it the page says "Talk to" and the agent name. | | `max_call_minutes` | integer | Length limit of one conversation, 1 to 30 minutes, default 10. The call ends by itself at the limit. | | `max_sessions` | integer | Total number of conversations after which the link stops working. Empty means no limit. | ```bash curl -X POST "https://app.benerra.ai/api/v1/demo-links" \ -H "X-API-Key: YOUR_API_KEY" -H "Content-Type: application/json" \ -d '{"agent_id": "YOUR_AGENT_ID", "ttl_hours": 72, "title": "Book a table with our assistant", "max_call_minutes": 5}' ``` ```json { "id": "7a2cb29a-6298-41ac-8ddf-325e26ac8af2", "url": "https://app.benerra.ai/d/zKyOnzv79B6ukWPZo-_mMnLD0hRHCYKd", "agent_id": "3969fe41-f33e-4eb7-967b-176e39656eda", "agent_name": "Emma", "project_id": "4754d564-2c45-4503-a545-e299151d4247", "title": "Book a table with our assistant", "created_at": "2026-12-02T19:23:41Z", "created_by": "apikey:CRM", "expires_at": "2026-12-05T19:23:41Z", "revoked": false, "status": "active", "max_call_minutes": 5, "max_sessions": null, "sessions_used": 0, "live_sessions": 0, "last_used_at": null } ``` Send `url` to the guest. The token in the link is the only secret: anyone who has the link can use it until it expires or is revoked. `GET /api/v1/demo-links?agent_id=&project_id=&limit=100` (permission: demo_links) Links of the key projects, newest first, as `{"links": [...]}`. Filter by `agent_id` or `project_id`. `POST /api/v1/demo-links/{id}/extend` (permission: demo_links) Body `{"ttl_hours": 24}`. The link works for that many hours counted from now. A revoked link cannot be extended (`409`); create a new one. `POST /api/v1/demo-links/{id}/revoke` (permission: demo_links) Stops the link at once and ends conversations in progress. ### Link status `status`: `active`, `expired`, `revoked`, `limit` (the `max_sessions` count was reached). A guest opening a link that no longer works sees a page that says so, without details about your account. ### Limits - Up to 3 conversations at the same time on one link; a fourth guest is asked to try again in a few minutes. - Up to 10 conversation starts per hour from one IP address on one link. - The guest needs a browser with microphone access (Chrome, Safari, Edge, Firefox; desktop or mobile). A VPN that switches during the call can drop it. ## Analytics over MCP AI assistants that support the Model Context Protocol can read your calls and statistics directly. The server uses Streamable HTTP without sessions and answers in JSON. It is read-only and requires a key with `calls_read`; it sees the projects of the key. `POST https://app.benerra.ai/api/v1/mcp` (permission: calls_read) Send the key in `X-API-Key` or `Authorization: Bearer`. For clients that cannot set headers, put the key in the path: `POST /api/v1/mcp/k/YOUR_API_KEY` (the key is masked in access logs). `GET` returns `405`. | Tool | What it does | |---|---| | `list_projects` | Projects available to the key, their agents (code and name), outcome labels and outcome groups. Call it first. | | `calls_report` | Summary for up to 31 days grouped by one or two of `day`, `hour`, `weekday`, `outcome`, `agent`, `country`, `campaign`, `attempt`, `call_type`, `project`. | | `search_calls` | Calls by lead number (`id_order`) or phone over all time, or over a period with filters. `include_dialog` adds the conversation text. | | `get_call` | One call: outcome, stages, who hung up, extracted fields, summary, recording link and the dialog. | Common filters: `project_id`, `date_from`, `date_to`, `agent_code`, `outcome`, `outcome_group` (`dozvon`, `nedozvon`, `tech`, `apruv`, `non_target`, `reject`, `other`), `country`, `call_type`, `answered_only`. Supported protocol versions: `2025-06-18`, `2025-03-26`, `2024-11-05`. ```json { "mcpServers": { "benerra-analytics": { "type": "http", "url": "https://app.benerra.ai/api/v1/mcp", "headers": {"X-API-Key": "YOUR_API_KEY"} } } } ``` ## Webhooks overview A webhook sends call results to your system. Webhooks are created per project in the cabinet in Webhooks; an organization admin can also create an organization-wide webhook that covers several or all projects. Each webhook has: - a type: `api` (your HTTP endpoint), `telegram`, `email` or `google_sheets`; - the URL and method (`POST` by default, or `PUT`) and optional custom headers, for example `Authorization`; - a secret used to [sign](https://docs.benerra.ai/#webhook-signature) the body; - the events it subscribes to; - optional filters by outcome, agent and contact source; - options: send dial failures, send SIP headers, include the original intake body (all or selected paths), include wave plan fields, remove special-category personal data, number of automatic retries. Every API webhook request has these headers: | Header | Value | |---|---| | `Content-Type` | `application/json` | | `User-Agent` | `Benerra-Webhook/1.0` | | `X-Webhook-Event` | The event name, for example `call_completed`. | | `X-Webhook-Signature` | `sha256=`, when the webhook has a secret. | | Your custom headers | As configured on the webhook. | Answer with any `2xx` within 10 seconds. Process the payload asynchronously if your work takes longer. ## Events | Event | When | |---|---| | `call_completed` | A call ended with any outcome that is not a lead and not a failure. | | `lead_detected` | A call ended with `client_apruv` or `call_connected`. A webhook subscribed to `call_completed` but not to `lead_detected` receives leads as `call_completed`, so it never misses one. | | `call_failed` | The call failed technically: no answer, carrier rejection, error. | | `contact_delivery` | A contact from a source was queued in a campaign, started waiting or was rejected. Sent on each change of its delivery state. API webhooks only. | | `test` | Sent by the Test button in the cabinet with a sample payload. | Each call produces exactly one of `call_completed`, `lead_detected` or `call_failed`. The cabinet also lists `campaign_started` and `campaign_completed`; they do not carry call data, so do not build logic on them. ### What is not sent - Test calls are not sent to API, email or Google Sheets webhooks. - Dial failures `carrier_rejected` and `number_invalid` reach only API webhooks that enable Send dial failures or list that outcome in their outcome filter. - `call_failed` with outcome `timeout` (no answer) is sent only to API webhooks, or to webhooks whose outcome filter includes `timeout`. - Outcome, agent and source filters skip calls that do not match; a skipped delivery shows as `skipped` in the delivery log. ## Payload fields The body is a JSON envelope. Call fields are inside `data`. Text fields without a value are empty strings, not `null`. | Field | Type | Description | |---|---|---| | `event` | string | Event name. | | `timestamp` | string | Send time, UTC ISO 8601. | | `webhook_id` | string | The webhook that sent this request. | | `project_id` | string | Project of the webhook. | | `external_call_id` | string | Copy of `data.external_call_id` for convenience. | | `data.call_id` | string | Call id. Use it with `event` as your idempotency key. | | `data.phone_number` | string | Client number. | | `data.id_order` | string | Your lead or order number. | | `data.call_type` | string | `outbound` or `inbound`. | | `data.call_outcome` | string | [Outcome](https://docs.benerra.ai/#outcomes) code. | | `data.call_status` | string | [Call status](https://docs.benerra.ai/#statuses). | | `data.duration_seconds` | integer | Talk time. | | `data.agent_id`, `data.agent_code`, `data.agent_name` | string | The agent. | | `data.agent_folder_id`, `data.agent_folder_name` | string | Agent folder. | | `data.contact_id`, `data.contact_name` | string | Campaign contact card. | | `data.campaign_id`, `data.campaign_name` | string | Campaign. | | `data.campaign_folder_id`, `data.campaign_folder_name` | string | Campaign folder. | | `data.call_url` | string | Link to the call in the cabinet (sign-in required). | | `data.intake_source_id`, `data.intake_group_id`, `data.intake_group_name`, `data.intake_external_id`, `data.intake_client_id`, `data.intake_client_name` | string | Where the contact came from: source, group and your lead id. | | `data.call_summary` | string | Short summary. | | `data.transcript` | string | Conversation text. | | `data.sentiment`, `data.sentiment_score` | string, number | Sentiment, when computed. | | `data.key_points`, `data.action_items` | array | Highlights and follow-ups. | | `data.recording_url` | string | Recording link. | | `data.started_at`, `data.ended_at` | string | UTC times with `Z`. | | `data.external_call_id` | string | Your id from `X-Call-ID`. | | `data.extracted_fields` | object | Fields the agent collected, keyed by your field names. | | `data.wave_call_attempt`, `data.wave_is_last_call` | integer, boolean | Campaign calls: attempt number of this contact, and whether this is the last call to it. | | `data.sip_status_code`, `data.sip_status`, `data.dial_failure`, `data.attempt_no`, `data.attempts_charged` | mixed | Dial details, present only when known. | | `data.will_retry`, `data.next_retry_at` | boolean, string | For `carrier_rejected` only: whether and when the dialer tries again. | | `data.sip_headers` | object | All `X-*` SIP headers of the call, when the call had them and the webhook sends SIP headers. | | `data.intake_payload` | object | The body you sent to the source, whole or the selected paths, when enabled on the webhook. | | `data.call_project_id`, `data.call_project_name` | string | Organization-wide webhooks: the project of the call. | ### Wave plan fields With Wave plan fields enabled, campaign calls also carry where the contact is in the calling plan. Values that do not apply are `null`. | Field | Description | |---|---| | `wave_attempts_limit` | Total attempts allowed per contact. | | `wave_attempts_per_day` | Attempts allowed per day. | | `wave_days_limit` | Number of calling days per contact. | | `wave_day_number`, `wave_day_attempt` | Calling day of this call and attempt number within that day. | | `wave_next_call_at` | Earliest UTC time of the next call, once the dialer has decided. | | `wave_last_call_reason` | On the last call only: `final_result` or `attempts_exhausted`. | ### contact_delivery payload `data` holds `contact_id`, `status`, `delivery`, `reason`, `message`, `campaign_id`, `phone`, `external_id`, `intake_source_id`, `intake_group_id`, `intake_group_name`, `project_id`, `changed_at`, `previous` (the prior `status`, `reason` and `delivery`, or `null`) and, while waiting, `waiting_reason`. ## Payload examples ### Lead from a campaign call ```json { "event": "lead_detected", "timestamp": "2026-12-01T16:33:40.512331", "webhook_id": "9d3f6a20-1c4e-4b7a-8e52-6f0a1b3c9d71", "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "external_call_id": "", "data": { "call_id": "3e8b1f42-7c6d-4a9e-b0f1-2d5c8a7e6b93", "phone_number": "15550100123", "id_order": "lead-1001", "call_type": "outbound", "call_outcome": "client_apruv", "call_status": "completed", "duration_seconds": 148, "agent_id": "0d7e9a1c-4b2f-4e8a-a3c6-5f1b2d9e7c40", "agent_name": "Emma", "agent_code": "101", "agent_folder_id": "", "agent_folder_name": "", "contact_id": "b51d7e0a-6c3f-4a29-9e84-1f2c7d0b5a36", "contact_name": "", "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "campaign_name": "December leads", "campaign_folder_id": "", "campaign_folder_name": "", "call_url": "https://app.benerra.ai/c/3e8b1f42", "intake_source_id": "a91e0c33-5d2b-4f8e-b6a7-0e4d9c2f1b58", "intake_group_id": "", "intake_group_name": "", "intake_external_id": "lead-1001", "intake_client_id": "", "intake_client_name": "", "call_summary": "John from Austin is interested in the annual plan and wants a demo on Friday.", "transcript": "Agent: Hello, this is Emma from Acme...\nClient: Hi, yes...", "sentiment": "", "sentiment_score": null, "key_points": [], "action_items": [], "recording_url": "https://app.benerra.ai/recordings/...", "started_at": "2026-12-01T16:31:02Z", "ended_at": "2026-12-01T16:33:30Z", "external_call_id": "", "extracted_fields": { "client_name": "John Smith", "call_comments": "Wants a demo on Friday afternoon" }, "wave_call_attempt": 2, "wave_is_last_call": true } } ``` ### No answer ```json { "event": "call_failed", "timestamp": "2026-12-01T14:06:31.004912", "webhook_id": "9d3f6a20-1c4e-4b7a-8e52-6f0a1b3c9d71", "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "external_call_id": "", "data": { "call_id": "e1b7c2d4-0f3a-4e6b-9c58-7a2d1f4e8b60", "phone_number": "15550100123", "call_type": "outbound", "call_outcome": "timeout", "call_status": "failed", "duration_seconds": 0, "campaign_id": "c2a4e7f0-91b3-4c1e-8f5d-7b6a3e9d2c11", "campaign_name": "December leads", "sip_status_code": 480, "attempt_no": 1, "wave_call_attempt": 1, "wave_is_last_call": false, "extracted_fields": {} } } ``` The example is shortened: the remaining text fields are present as empty strings. ### Call transferred from your PBX ```json { "event": "call_completed", "timestamp": "2026-12-01T18:12:07.220145", "webhook_id": "9d3f6a20-1c4e-4b7a-8e52-6f0a1b3c9d71", "project_id": "5b0f8f7e-2a41-4c3a-9a51-0d1e6c7b8a90", "external_call_id": "crm-call-7781", "data": { "call_id": "7a0c9e13-2b5d-4f81-a6e4-3c9b0d2e1f75", "phone_number": "15550100456", "id_order": "ORD-48213", "call_type": "inbound", "call_outcome": "client_callback", "call_status": "completed", "duration_seconds": 61, "agent_code": "101", "agent_name": "Emma", "call_summary": "The client asked to be called back tomorrow after 5 pm.", "external_call_id": "crm-call-7781", "extracted_fields": {"callback_time": "tomorrow after 5 pm"}, "sip_headers": { "X-Agent-ID": "101", "X-Lead-ID": "ORD-48213", "X-Call-ID": "crm-call-7781", "X-Client-Name": "Maria", "X-Customer-Tier": "gold" } } } ``` ## Signature verification When the webhook has a secret, Benerra computes HMAC-SHA256 of the exact request body bytes with the secret as the key and sends it as `X-Webhook-Signature: sha256=`. Verify it against the raw body before parsing JSON; re-serializing the parsed JSON changes the bytes and breaks the check. Compare in constant time. ```python import hashlib import hmac from flask import Flask, abort, request app = Flask(__name__) SECRET = b"YOUR_WEBHOOK_SECRET" seen = set() # use a database table in production @app.post("/benerra/webhook") def benerra_webhook(): raw = request.get_data() # raw bytes, before JSON parsing expected = "sha256=" + hmac.new(SECRET, raw, hashlib.sha256).hexdigest() got = request.headers.get("X-Webhook-Signature", "") if not hmac.compare_digest(expected, got): abort(401) body = request.get_json() key = (body["event"], body.get("data", {}).get("call_id")) if key in seen: return "", 200 # duplicate delivery, already processed seen.add(key) # queue the work and answer fast return "", 200 ``` ```javascript const crypto = require("crypto"); const express = require("express"); const app = express(); const SECRET = "YOUR_WEBHOOK_SECRET"; app.post("/benerra/webhook", express.raw({ type: "application/json" }), (req, res) => { const expected = "sha256=" + crypto.createHmac("sha256", SECRET).update(req.body).digest("hex"); const got = req.get("X-Webhook-Signature") || ""; const ok = got.length === expected.length && crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected)); if (!ok) return res.sendStatus(401); const body = JSON.parse(req.body.toString("utf8")); // dedupe on body.event + body.data.call_id, then queue the work res.sendStatus(200); }); app.listen(3000); ``` The body is compact JSON (no spaces after separators) in UTF-8, with non-ASCII characters written as is. ## Retries and idempotency Automatic retries apply to API webhooks. A delivery is retried when: - your server could not be reached (connection error or connect timeout), or - it answered `429`, `502`, `503` or `504`. Other `4xx` and `5xx` answers are not retried. A read timeout after the request was sent is not retried either, because your server may already have processed it; check the delivery log and use redelivery if needed. Retries follow this schedule after the first failure: 1 minute, 5 minutes, 30 minutes, 2 hours, then every 6 hours. The webhook setting Retries sets how many (0 to 10, default 5). A retry is cancelled if the webhook is disabled or its URL changes. You can also redeliver by hand in the cabinet or with [`POST /calls/{call_id}/redeliver`](https://docs.benerra.ai/#deliveries). ### Idempotency - Each call is dispatched once, but retries and redeliveries can bring the same result again. Deduplicate on `event` plus `data.call_id`. - `timestamp` is the send time of each attempt, so a retry has a new timestamp and a new signature. Do not use them for deduplication. - Answer `2xx` to a duplicate you already processed, otherwise it will be retried. ## Other destinations - **Telegram:** A message to a chat or a topic of a group with the outcome, summary, extracted fields, a link to the call and the recording when available. Use the platform bot or your own bot token. - **Email:** A message to one or more addresses with a configurable subject. - **Google Sheets:** One row per call appended to your spreadsheet. Share the sheet with the service account email shown in the form as an Editor; column headers are written to an empty sheet on save. A spreadsheet can be connected to one organization only. These destinations use the same events and filters. Signature, retries and redelivery apply to API webhooks only. ## SIP integration Benerra agents can use phone lines in three ways: | Mode | Who dials | Typical use | |---|---|---| | [Our dialer, your trunk](https://docs.benerra.ai/#sip-dialer) | Benerra | Campaigns call your contacts through your own carrier account and caller numbers. | | [Transfer from your PBX](https://docs.benerra.ai/#sip-transfer) | Your dialer or PBX | Your system places or receives the call and hands the live call to an agent with SIP headers. | | [Inbound line](https://docs.benerra.ai/#sip-inbound) | The client | Clients call a number and reach an agent. | Trunks are added in the cabinet in Telephony. A trunk connects either by **registration** (username and password) or **by IP** (an allow list of your signaling addresses), and can be inbound, outbound or both. Benerra support gives you the SIP address, port and the addresses to allow on your side when the trunk is set up. In the examples below `sip.benerra.ai` stands for that address. **Codecs.** Offer G.711 (PCMU and PCMA) as in the example below. A trunk can carry its own codec list, for example `ulaw,alaw`, if your carrier needs a specific order. ## Our dialer, your trunk 1. Add an outbound trunk with your carrier host, port and credentials (or IP mode) and an optional dial prefix. 2. Set the caller numbers: one fixed number or a pool that rotates, with an optional hourly cap per number. 3. Choose which projects may use the trunk, and pick it on the campaign (or let the campaign split traffic between several trunks). Dial results are recorded on each call: `sip_status_code` and `sip_status` keep the final SIP response of a failed attempt. A carrier rejection gives outcome `carrier_rejected`, a number that does not exist gives `number_invalid`, no answer gives `timeout`. ## Transfer from your PBX Your PBX or dialer sends the call (a new INVITE, or a transfer of an answered call) to the Benerra SIP address. The agent is chosen by the `X-Agent-ID` header, which carries the `agent_code`. Other headers pass client data that the agent uses in the conversation and that come back in the webhook. ```sip INVITE sip:+15550100999@sip.benerra.ai SIP/2.0 Via: SIP/2.0/UDP pbx.YOUR_DOMAIN:5060;branch=z9hG4bK776asdhds Max-Forwards: 70 From: "Maria" ;tag=1928301774 To: Call-ID: a84b4c76e66710@pbx.YOUR_DOMAIN CSeq: 314159 INVITE Contact: X-Agent-ID: 101 X-Lead-ID: ORD-48213 X-Call-ID: crm-call-7781 X-Client-Name: Maria X-Offer-Name: Annual plan X-Client-Address: 12%20Main%20St%2C%20Austin%2C%20TX X-Client-Age: 42 X-Client-Gender: f X-Call-Dir: in X-Customer-Tier: gold Content-Type: application/sdp Content-Length: 142 v=0 o=pbx 2890844526 2890844526 IN IP4 pbx.YOUR_DOMAIN s=- c=IN IP4 203.0.113.10 t=0 0 m=audio 49170 RTP/AVP 0 8 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 ``` - If `X-Agent-ID` is missing, the call goes to the trunk default agent when one is set in Telephony, otherwise it is rejected. An unknown or inactive agent code is always rejected. - Calls over the trunk concurrent-call limit, or while calls of the organization are stopped, are rejected. - Every inbound attempt, accepted or rejected, is recorded in the trunk journal in the cabinet with the reason, the headers received and any warnings. | Rejection reason | Meaning | |---|---| | no X-Agent-ID | No agent code and no default agent on the trunk. | | unknown agent code | No agent with this code in the organization. | | agent inactive | The agent is archived or deleted. | | IP not in the allow list | The INVITE came from an address not allowed on the trunk. | | wrong login or password | Registration credentials did not match. | | concurrent calls limit exceeded | Too many calls at once on this trunk. | | organization calls are stopped | Calling is paused for the organization. | | platform overloaded | No capacity at this moment; retry. | ## SIP headers Header names are case-insensitive. Values are plain text unless noted; keep them under 2000 characters. | Header | Where it goes | Description | |---|---|---| | `X-Agent-ID` | agent choice | The `agent_code` that takes the call. | | `X-Lead-ID` | `id_order`, `{ORDER_NUMBER}` | Your lead or order number. Lets you find all calls with `GET /calls/by-order/{id_order}`. | | `X-Call-ID` | `external_call_id` | Your call id for correlation. Returned in the webhook at the top level and in `data`. | | `X-Client-Name` | `client_name`, `{CLIENT_NAME}` | Client name, plain ASCII. | | `X-Con-Name` | `{CLIENT_NAME}` | Client name URL-encoded as UTF-8 (for names with accents). Used when `X-Client-Name` is empty. | | `X-Offer-Name` | `offer_name`, `{OFFER}` | Product or offer the call is about. | | `X-Client-Address` | `{CLIENT_ADDRESS}` | Client address, URL-encoded UTF-8. | | `X-Client-Age` | `{AGE}` | Age as an integer. | | `X-Client-Gender` | agent context | `m` or `f` (also `male`, `female`). Helps the agent address the client correctly. | | `X-Call-Dir` | `call_direction` | `in` or `out`: whether the original call on your side was inbound or outbound. `X-CALL_DIR` is also accepted. | | Any other `X-*` | `sip_headers`, custom variables | Stored on the call and sent in `data.sip_headers`. Map a header to a prompt variable in the trunk settings to use it in the agent text. | - Up to 40 `X-*` headers are kept per call; extra ones are dropped with a warning in the trunk journal. - The header map of a trunk (up to 30 entries) turns a custom header into a variable, for example `X-Customer-Tier` into `{customer_tier}`. - `X-Org-ID`, `X-Route` and `X-Room-Sid` are reserved for the platform. Do not send them. - A value that is not valid UTF-8 after URL decoding, an unrecognized gender or a non-numeric age is ignored and reported as a warning in the trunk journal; the call still goes through. ## Inbound line To let clients call an agent directly, Benerra support attaches your inbound numbers to a trunk. Calls to those numbers go to the trunk default agent, or, on a shared line, the caller is asked to enter the agent code by tone. Inbound calls produce the same call records and webhooks as outbound calls, with `call_type` set to `inbound`. In Call control you can switch inbound calls off for the whole project or for a single agent; switched-off agents are reported by [gate-check](https://docs.benerra.ai/#call-control) as `agent_disabled`. ## Outcomes `call_outcome` is the business result of a call. Five system outcomes exist on every agent; their codes never change, although you can rename their labels. Agents can also have custom outcomes with your own codes; those appear in the same field. ### System outcomes | Code | Label | Meaning | |---|---|---| | `client_apruv` | Lead | The client is interested and agreed to the next step. Sends `lead_detected`. | | `client_reject` | Refusal | The client explicitly declined the offer. | | `cant_talk` | Can't talk | The client cannot or does not want to talk now, no decision. Not a refusal. | | `voicemail_detected` | Voicemail | Voicemail, an answering robot, a secretary or a voice assistant answered. | | `silence_hangup` | Silence | Nobody spoke; the call ended in silence. | ### Other common outcomes | Code | Meaning | |---|---| | `call_connected` | Transferred to a human operator. Counts as a lead and sends `lead_detected`. | | `client_callback` | The client asked to be called back. | | `call_dropped` | The conversation broke off and needs an urgent callback. | | `no_request` | The client says they never asked to be contacted. | | `timeout` | No answer. | | `carrier_rejected` | The carrier rejected the call. | | `number_invalid` | The number does not exist. | | `technical_error` | A technical failure; there was no conversation. | ### Outcome groups Reports and the MCP endpoint group outcomes like this: | Group | Outcomes | |---|---| | `dozvon` (reached) | A human answered: `client_apruv`, `client_reject`, `cant_talk`, `client_callback`, `call_dropped`, `no_request` and custom outcomes. | | `nedozvon` (not reached) | `voicemail_detected`, `silence_hangup`. | | `tech` | `timeout`, `carrier_rejected`, `number_invalid`, `technical_error`. | | `apruv` | `client_apruv`. | | `reject` | `client_reject`. | | `non_target` | `no_request`. | For a contact with several calls, a lead stays a lead: a later voicemail or callback does not undo it; only an explicit refusal does. ## Statuses ### Call status `call_status` is the technical state of the call, separate from the outcome. | Value | Meaning | |---|---| | `initiated` | Created, dialing has started. | | `ringing` | The phone is ringing. | | `answered` | The call is in progress. | | `completed` | The call ended normally. | | `failed` | The call failed; sends `call_failed`. | | `no_answer` | Nobody answered. | ### Campaign status | Value | Meaning | |---|---| | `draft` | Created, never launched. | | `pending` | Waiting for launch. | | `active` | Running: calls are placed during calling hours. | | `paused` | Paused by a user or automatically; `stop_reason` says why. | | `completed` | All contacts are processed. | | `stopped` | Stopped before completion. | In the API list, `lifecycle_status` is `archived` for archived campaigns and equals `status` otherwise. ### Contact delivery See [Contact intake responses](https://docs.benerra.ai/#intake-response): `queued`, `waiting`, `processing`, `rejected`. ## Prompt variables The agent role, greeting and phrases can contain variables in braces. They are replaced with contact data at the start of each call. Names are case-insensitive. | Variable | Also written as | Filled from | |---|---|---| | `{CLIENT_NAME}` | `{NAME}`, `{FIRST_NAME}`, `{CLIENT}` | `client_name` or `name` in contact data, `X-Client-Name`, `X-Con-Name`. | | `{ORDER_NUMBER}` | `{ORDER_ID}`, `{ORDER}` | `order_id` in contact data, `X-Lead-ID`. | | `{OFFER}` | `{PRODUCT}` | `offer` or `product`, `X-Offer-Name`. | | `{PRICE}` | `{COST}` | `price` or `cost` in contact data. | | `{CITY}` | | `city` in contact data. | | `{AGE}` | `{CLIENT_AGE}` | `age` in contact data, `X-Client-Age`. | | `{CLIENT_ADDRESS}` | | `client_address` in contact data, `X-Client-Address`. | | `{LANGUAGE}` | `{LANG}` | The agent language code. | | `{your_key}` | | Any custom key from contact data, a campaign file column or a mapped SIP header. | - Contact data comes from the source `variables` object, campaign file columns or SIP headers. Translated column names are understood too, for example `nombre`, `ciudad`, `prix`. - If a built-in variable has no value, a neutral word in the agent language is used, for example "customer" for the name and "your city" for the city; for the order number and price the variable is left empty. - Agents can declare their own variables with default values. A declared variable without a value is removed together with its surrounding spaces, so the client never hears braces. ## Languages Each agent speaks one configured language and keeps it for the whole call unless you allow switching. | Code | Language | |---|---| | `en` | English | | `es` | Spanish | | `fr` | French | | `de` | German | | `it` | Italian | | `pl` | Polish | | `pt` | Portuguese | | `ro` | Romanian | Voices come in tiers: **Premium voice** and **Standard+ voice**, with more tiers depending on your plan. The language model is chosen per agent by tier as well (Advanced, Fast, Economy). The API and webhooks report only these public tier names. ## FAQ ### Can I start a single call through the API? Send the contact to a [contact source](https://docs.benerra.ai/#contact-intake) that delivers to an active campaign. The campaign calls it within its calling hours. For calls your own system places, use [transfer from your PBX](https://docs.benerra.ai/#sip-transfer). ### How do I match a call to my lead? Send your lead id as `external_id` in the source body (it comes back as `data.intake_external_id`) or as `X-Lead-ID` on SIP calls (it comes back as `data.id_order`). On SIP calls you can also pass your own call id in `X-Call-ID`. ### Where do the extracted fields come from? You define them on the agent, each with a name and an instruction. After the call they are filled from the conversation and sent in `data.extracted_fields` under those names. ### Why did the outcome change a few seconds after the call? Right after hangup the call is analyzed once more and fields are extracted. Webhooks are sent after this step; when reading through the API immediately, wait until `outcome_final` is `true` in `by-order`, or re-read the call a little later. ### I did not get a webhook for a call. Check the call delivery log in the cabinet or with [`GET /calls/{call_id}/deliveries`](https://docs.benerra.ai/#deliveries). Common causes: the event is not subscribed, an outcome or agent filter skipped it, it was a test call, or your server answered with an error that is not retried. ### Is the recording link public? Treat `recording_url` as sensitive and do not publish it. Download the file to your storage if you need to keep it. ### Which IP addresses do webhooks come from? Ask Benerra support for the current list if your firewall needs an allow list, and verify the signature in any case. ## Changelog ### Version 1.0, December 2026 - First public release of the Benerra AI integrator documentation. - Demo links: public pages to talk to an agent in the browser, created in the cabinet or with the `demo_links` permission. - API keys with project scope and permissions, uniform error codes and rate limits. - Contact intake with simple and detailed responses, Contacts API and `contact_delivery` event. - Calls, campaigns, statistics, deliveries and redelivery, call control, agent configuration, text test API and analytics over MCP. - Signed webhooks with automatic retries; Telegram, email and Google Sheets destinations. - SIP integration: own trunks, transfer from your PBX with headers, inbound lines. Benerra AI developer documentation, version 1.0[app.benerra.ai](https://app.benerra.ai) · [Manager guide](https://docs.benerra.ai/manager/) · [llms.txt](https://docs.benerra.ai/llms.txt)