# Errors, rate limits and concurrency

> The error object and its types, request IDs, safe retries, request rate limits and their headers, and how many calls can run at once on each plan.

## The error object

Every error answers an HTTP status from `400` up and the same JSON body:

```json title="403 Forbidden"
{
  "error": {
    "type": "compliance_error",
    "code": "dnc_listed",
    "message": "050-123-4567 is on the do-not-call list (pressed the opt-out key, since 2026-10-12)",
    "doc_url": "https://docs.morevoice.ai/api/errors#dnc-listed",
    "details": {
      "verdict": {
        "allowed": false,
        "reason": "dnc",
        "purpose": "marketing",
        "phone": "+972501234567",
        "checks": [{ "kind": "dnc", "result": "block", "detail": "pressed the opt-out key" }]
      }
    },
    "request_id": "req_4fG7hK2mN9pQ1rS3"
  }
}
```

| Field | Meaning |
| --- | --- |
| `type` | The category. Decide what to do from it (below). |
| `code` | A stable, machine-readable reason, such as `parameter_missing` or `concurrency_limit`. Switch on it. The [error codes](#error-codes) list them all. |
| `message` | An explanation for people. It can change, so don't parse it. |
| `param` | The request field the error is about, such as `to` or `metadata[order_id]`. Present when there is one. |
| `doc_url` | A link to the code in the [list below](#error-codes). |
| `details` | Structured context for some codes: `required_scope`, the compliance `verdict`, the `preflight` checks of a campaign, the counts of a limit. Under a general code such as `resource_conflict`, `forbidden` or `admission_denied`, `details.reason` names the specific cause (for example `did_taken`). |
| `request_id` | The request's `X-Request-Id`. Log it, and quote it when you contact support. |

New codes are added as the API grows, so handle a code you don't know by its `type`.

### Types and what to do

| `type` | HTTP | What to do |
| --- | --- | --- |
| `invalid_request_error` | 400, 413, 415, 421, 422 | Fix the request: `param` names the field at fault. Sending it again unchanged fails the same way. |
| `authentication_error` | 401 | Check the key: sent as `Authorization: Bearer …`, not revoked or expired, and allowed from this IP address. |
| `permission_error` | 402, 403 | The key, the mode or the plan doesn't allow this: add the scope, use a key of the right mode, or change the plan. `402` is billing: a used-up balance, a spend cap or the trial. |
| `not_found` | 404 | No such object in this organisation and mode: a test key can't see live objects, and the other way round. |
| `conflict` | 409 | The object's state doesn't allow it now, for example a call that already ended. Read the object again before you decide. |
| `rate_limit_error` | 429 | Wait for `Retry-After`, then retry with the same `Idempotency-Key`. |
| `compliance_error` | 403 | The rules forbid this call: `details.verdict` says which one. Don't retry until the reason changes. |
| `idempotency_error` | 400, 409 | `request_in_progress`: retry shortly with the same key. `idempotency_mismatch`: use a new key for a different request. |
| `api_error` | 500, 501, 503 | Retry with backoff and the same `Idempotency-Key`. If it persists, contact support with the `request_id`. |

## Handle errors

The Node.js SDK throws an error class per type (`InvalidRequestError`, `PermissionError`, `ComplianceError`, `RateLimitError`…, all `MoreVoiceError`) with the fields above as `status`, `type`, `code`, `param`, `details` and `requestId`, and retries what can be retried. In other languages, read the body:

**cURL**

```sh
# -i shows the response headers: X-Request-Id, RateLimit-Policy and RateLimit on every response,
# Retry-After on a 429. Errors come back as {"error": {"type", "code", "message", …}}.
curl -i https://api.morevoice.ai/v1/calls \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: offer-$CONTACT_ID" \
  -d '{
    "to": "+972501234567",
    "assistant_id": "'"$ASSISTANT_ID"'",
    "purpose": "marketing"
  }'
```

**Node.js**

```ts title="handle-errors.ts"
import MoreVoice, { ComplianceError, MoreVoiceError, RateLimitError } from "@morevoice/sdk";

// The client retries network errors, 408, 429 and 5xx twice by default, with backoff and the
// same Idempotency-Key, so a retried call never dials twice.
const mv = new MoreVoice({ maxRetries: 2 });
const contactId = process.env.CONTACT_ID!;

try {
	const call = await mv.calls.create(
		{ to: "+972501234567", assistant_id: process.env.ASSISTANT_ID!, purpose: "marketing" },
		{ idempotencyKey: `offer-${contactId}` },
	);
	console.log(call.id);
} catch (err) {
	if (err instanceof ComplianceError) {
		// Not a failure to retry: the rules say this number may not be called now.
		console.warn(`Not called (${err.code}):`, err.verdict);
	} else if (err instanceof RateLimitError) {
		// Still limited after the retries (for example, every line of the plan is busy).
		console.warn(`Try again in ${err.retryAfterMs ?? 5000} ms (${err.code})`);
	} else if (err instanceof MoreVoiceError) {
		// Quote the request ID if you contact support.
		console.error(err.status, err.type, err.code, err.message, err.param, err.requestId);
	} else {
		throw err;
	}
}
```

**Python**

```python title="handle_errors.py"
import os
import time

import requests

API = "https://api.morevoice.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MOREVOICE_API_KEY']}"}


def create_call(body: dict, idempotency_key: str, attempts: int = 3) -> dict:
    """POST /v1/calls, retrying 429 and 5xx with the same Idempotency-Key (so it never dials twice)."""
    for attempt in range(attempts):
        response = requests.post(
            f"{API}/calls",
            headers={**HEADERS, "Idempotency-Key": idempotency_key},
            json=body,
            timeout=30,
        )
        if response.ok:
            return response.json()
        error = response.json()["error"]
        if response.status_code == 429 or response.status_code >= 500:
            time.sleep(float(response.headers.get("Retry-After", 2**attempt)))
            continue
        # 4xx: fix the request. Quote the request ID if you contact support.
        raise RuntimeError(f"{response.status_code} {error['type']}/{error['code']}: {error['message']} ({error['request_id']})")
    raise RuntimeError(f"Still failing after {attempts} attempts: {error['code']} ({error['request_id']})")


call = create_call(
    {"to": "+972501234567", "assistant_id": os.environ["ASSISTANT_ID"], "purpose": "marketing"},
    idempotency_key=f"offer-{os.environ['CONTACT_ID']}",
)
print(call["id"])
```

### When to retry

- **Retry** network errors, timeouts, `429` and `5xx`, with growing waits (or the `Retry-After` you were given), and with the **same** `Idempotency-Key`: MoreVoice then does the work only once, even if an earlier attempt got through. The SDK retries twice by default.
- **Don't retry unchanged** a `400`, `401`, `403`, `404` or `409` (other than `request_in_progress`): the same request fails the same way. A `compliance_error` in particular means the call may not be made now.
- A `5xx`, `409` or `429` answer doesn't use up the `Idempotency-Key`; any other answer is stored, and a retry with the key gets it back.

## Rate limits

Requests are counted per API key, in two buckets: reads (`GET`) and writes (every other method). Each bucket holds a burst of twice its per-second rate and refills continuously, so short bursts are fine. New calls (`POST /v1/calls`) are also counted per organisation and mode, in calls per second. Every response tells you where you stand, following the IETF `RateLimit` header draft:

```http
RateLimit-Policy: "write";q=40;w=2, "call_starts";q=5;w=1
RateLimit: "write";r=37;t=1, "call_starts";r=4;t=1
```

`q` is the burst a bucket holds and `w` the seconds it takes to refill; `r` is what is left now and `t` the seconds until the bucket is full again. When a bucket is empty the request answers `429` with the code `rate_limited`, a `Retry-After` header in seconds, and `details` with the `limit_type`, `limit`, `rate` and `retry_after_s`. A refused request costs nothing: it uses up no `Idempotency-Key` and starts nothing.

Test-mode keys get half the request and call rates of live keys.

## Calls in progress

Each plan allows a number of calls in progress at once. When the organisation is at its limit, `POST /v1/calls` answers `429` with the code `concurrency_limit` before anything is dialled, with `details.limit_type` (`concurrent_ai_calls` or `concurrent_calls`), `details.active` and `details.limit`, and `Retry-After`. Retry when a call ends, or let a [campaign](https://docs.morevoice.ai/guides/campaigns/) pace the calls for you: it keeps to its `max_concurrent` and waits for free lines on its own.

`capacity_exceeded` (also `429`) means no line is free for another reason: the SIP connection's channels or the platform's own capacity. It is short-lived; retry after `Retry-After`.

Test mode has its own quotas: test calls in progress at once (`concurrency_limit` with `limit_type: "test_concurrent_calls"`), and test calls in any 24 hours (`test_call_limit`).

## Limits per plan

| Limit | Trial | Starter | Growth | Business | Enterprise | Developer |
| --- | --- | --- | --- | --- | --- | --- |
| AI calls in progress at once | 2 | 5 | 20 | 60 | 100 | 20 |
| Calls in progress at once (all kinds) | 4 | 30 | 120 | 400 | No limit | 40 |
| New calls per second (`POST /v1/calls`) | 1 | 2 | 5 | 5 | 10 | 5 |
| Read requests per second, per key | 5 | 20 | 50 | 50 | 100 | 50 |
| Write requests per second, per key | 2 | 10 | 20 | 20 | 40 | 20 |
| Test calls in progress at once | 2 | 5 | 10 | 10 | 20 | 10 |
| Test calls per 24 hours | 50 | 100 | 500 | 1,000 | No limit | 1,000 |

Rates are per second; each request bucket holds a burst of twice its rate. An organisation without a plan gets 50 reads and 20 writes a second per key, 5 new calls a second, 10 test calls at once and 1,000 a day. Need more? Extra AI lines can be added to a plan, and limits can be raised per organisation: contact us.

> **Note:** These limits are the beta's starting values and may be tuned. Read the `RateLimit-Policy` header instead of hard-coding them.

## Billing limits

When billing doesn't allow new calls, `POST /v1/calls` answers `402` with a `permission_error` whose code says why, and `details.reason` repeats it: `balance_exhausted` (top up), `spend_cap` (the spend cap of the period is reached), `trial_limit` or `unverified_destination` (trial rules), `kyc_required` (business verification first), `fraud_hold` or `org_suspended` (contact support). `plan_limit` means another limit of the plan was reached.

## Error codes

Every code the API answers, by type. Codes are never renamed or removed, only added. Each error's `doc_url` opens its row here.

### Invalid request: `invalid_request_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `parameter_missing` | 400 | A required parameter is missing. |
| `parameter_invalid` | 400 | A parameter has the wrong type, format or value. |
| `parameter_unknown` | 400 | The request contains a parameter this endpoint does not accept. |
| `invalid_id` | 400 | An ID in the request body or query is malformed or has the wrong prefix. |
| `invalid_cursor` | 400 | The pagination cursor is malformed or belongs to another list. |
| `invalid_expand` | 400 | A field in expand[] cannot be expanded on this endpoint. |
| `unknown_version` | 400 | The MoreVoice-Version header names a version that does not exist. |
| `invalid_json` | 400 | The request body is not valid JSON. |
| `body_too_large` | 413 | The request body is larger than the endpoint accepts. |
| `unsupported_media_type` | 415 | The request body must be sent as application/json. |
| `bad_request` | 400 | The request could not be processed as sent. |
| `dial_rejected` | 400 | The call could not be placed with these parameters (connection, caller ID, number). |
| `unsupported_audio` | 415 | The audio file is not in a supported format (OGG/Opus, WebM/Opus, WAV, MP3, MP4/AAC), or it can't be decoded. |
| `audio_too_long` | 422 | The audio is longer than the request allows (max_duration_sec, at most 600 seconds); details.duration_sec is its length. |
| `no_speech` | 422 | No speech was found in the audio (silence or noise); details.duration_sec is its length. Nothing is billed. |
| `text_too_long` | 422 | The text is longer than the endpoint speaks in one request (details.max characters). |
| `wrong_cell` | 421 | The organisation (or the API key) is served from another cell: send the request to details.url (details.cell names the cell). |

### Authentication: `authentication_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `api_key_missing` | 401 | No API key was sent. Send `Authorization: Bearer mv_…`. Session cookies are not accepted on /v1. |
| `invalid_api_key` | 401 | The API key is malformed or does not exist. |
| `key_revoked` | 401 | The API key was revoked. |
| `key_expired` | 401 | The API key expired (for example, the old half of a rolled key). |
| `ip_not_allowed` | 401 | The request came from an IP address outside the key's allow-list. |
| `origin_not_allowed` | 401 | A publishable key was used from a website origin outside its allow-list. |
| `signature_invalid` | 401 | A signed request (a relayed WhatsApp event, a webhook) was refused: its signature is missing, malformed, expired, already used or wrong. Every such refusal is this same answer. |

### Permission: `permission_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `missing_scope` | 403 | The API key lacks a scope this endpoint needs (details.required_scope). |
| `publishable_key_not_allowed` | 403 | Publishable keys can only call endpoints meant for browsers; use a secret key. |
| `api_access_disabled` | 403 | API access is not enabled for this organisation. |
| `feature_unavailable` | 403 | The organisation's plan does not include this feature. |
| `plan_limit` | 402 | The organisation reached a limit of its plan. |
| `live_only` | 403 | This endpoint changes or reads live-only data (SIP connections, compliance lists); use a live key (mv_live_…). |
| `live_key_in_browser` | 403 | Live secret keys must stay on your server: a request from a browser (it sends an Origin header) needs a test key (mv_test_…). |
| `test_mode_only` | 403 | This endpoint simulates test-mode traffic (test helpers): use a test key (mv_test_…). |
| `livemode_mismatch` | 403 | Test-mode keys cannot touch live objects, and live keys cannot touch test objects. |
| `test_mode_disabled` | 403 | Test mode is not enabled for this organisation yet, so test keys (mv_test_…) are refused. |
| `not_child_org` | 403 | The Mv-Account header names an organisation that is not a client of the key's organisation. |
| `partner_role_required` | 403 | Mv-Account: the person who created the API key no longer holds a partner role that may act in client organisations (partner owner or admin). |
| `partner_inactive` | 403 | Mv-Account: the key's partner programme is not active, so it can't act in client organisations. |
| `partner_access_disabled` | 403 | Mv-Account: the client organisation has turned partner access off. |
| `acting_read_only` | 403 | Mv-Account: the key's access to client organisations is read-only (its creator is partner support staff), so only GET requests are allowed. |
| `forbidden` | 403 | The API key may not perform this action. |
| `balance_exhausted` | 402 | The organisation's prepaid balance is used up; top up to place calls. |
| `prepaid_exhausted` | 402 | The organisation's prepaid balance is used up; top up to place calls (same as balance_exhausted). |
| `spend_cap` | 402 | The organisation reached its spend cap for this period. |
| `trial_limit` | 402 | The trial's call allowance is used up. |
| `unverified_destination` | 402 | During the trial, calls may only go to verified numbers. |
| `fraud_hold` | 402 | Calling is on hold for this organisation pending a review. Contact support. |
| `org_suspended` | 402 | The organisation is suspended: calls are refused until it is reactivated. |
| `org_closed` | 403 | The organisation is closed: new calls and changes are refused. |
| `kyc_required` | 403 | The organisation must complete business verification (KYC) before it can call out. |
| `admission_denied` | 402 | Billing does not admit new outbound calls for the organisation right now (details.reason). |
| `assistant_not_public` | 403 | Publishable keys can only start web calls to assistants that are public (widget settings); mint a client token on your server instead. |
| `widget_origin_not_allowed` | 403 | The page's origin is not one of the assistant's widget origins. |

### Not found: `not_found`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `resource_missing` | 404 | No object with this ID exists (in this organisation and mode). |
| `route_not_found` | 404 | No endpoint matches this method and path. |
| `voice_not_found` | 404 | No voice with this voice_id is available to the organisation (see GET /v1/voices). |

### Conflict: `conflict`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `resource_conflict` | 409 | The request conflicts with the object's current state. |
| `call_not_active` | 409 | The call is not live: it ended, or it has not been answered yet. |
| `call_in_progress` | 409 | The call is still in progress; hang it up first. |
| `unsupported_for_call_mode` | 409 | This action is not available for this kind of call (details.call_type), e.g. hold on an AI call. |
| `transfer_failed` | 409 | The transfer could not be completed (details.detail says why); the call continues. |
| `summary_unavailable` | 409 | There is nothing to summarise yet (no customer speech in the transcript). |
| `flow_invalid` | 409 | The flow's draft has errors that block publishing (details.issues lists them, with the node of each). |
| `number_unavailable` | 409 | The phone number is not available any more (another organisation took it, or it left the stock): pick another one from GET /v1/phone_numbers/available. |
| `number_in_use` | 409 | The phone number is still used (details.uses: campaigns that present it as caller ID, caller-ID pools, desk phones, other inbound routes): change those first, or release it with force=true, which detaches it from all of them. |
| `caller_id_exists` | 409 | The number needs no verification: it is one of your own numbers (details.reason: owned), or already a verified caller ID (details.reason: verified, details.id). |
| `preflight_failed` | 409 | The campaign can't start yet: its pre-flight checks failed (details.preflight lists what to fix). |
| `whatsapp_no_pstn` | 409 | WhatsApp calls can't be connected to a phone number, a phone or an outside SIP address: only the AI and agents in the browser can take them. The call continues. |
| `permission_required` | 409 | The WhatsApp user has not given the business permission to call them (or it expired): ask them for a call permission first (details.permission; its callback_permission says whether the user's own call to the number grants one). |
| `whatsapp_unavailable` | 409 | The WhatsApp number can't place calls right now (details.reason: number_disabled, calling_disabled, token_invalid, not_authorized, no_token). |
| `recipient_unavailable` | 409 | WhatsApp refused the call to this user (they can't take calls, or a call with them is already in progress; details.reason). |

### Rate limit: `rate_limit_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `rate_limited` | 429 | Too many requests; retry after the Retry-After delay. |
| `capacity_exceeded` | 429 | No call capacity right now (concurrency, CPS or worker limits); retry later. |
| `concurrency_limit` | 429 | As many calls (or streams) are in progress as the plan allows (details.limit_type, details.active, details.limit); retry when one ends. |
| `test_call_limit` | 429 | The organisation used its test-mode calls for the last 24 hours (details.limit); retry after the Retry-After delay, or use a live key. |
| `limit_reached` | 429 | A WhatsApp calling limit was reached for this user or number, such as calls per user per day (details.limits: period, max_allowed, current_usage; details.resets_at: by when the limits have reset, ISO 8601, null when the limits don't say; details.permission_expires_at when the permission itself expires). |
| `daily_limit` | 429 | The organisation used today's allowance for this endpoint (details.limit, details.used, details.unit); retry after the Retry-After delay. |

### Compliance: `compliance_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `dnc_listed` | 403 | The number is on the organisation's do-not-call list. |
| `registry_listed` | 403 | The number is on the national do-not-call registry for this purpose. |
| `registry_unavailable` | 403 | The national registry could not be checked, so the marketing call was blocked. |
| `consent_missing` | 403 | There is no recorded consent for this marketing call. |
| `compliance_blocked` | 403 | The outbound compliance policy blocked the call (details.verdict). |
| `disclosure_required` | 403 | Marketing campaigns play the AI and recording disclosure; it can't be turned off through the API. |

### Idempotency: `idempotency_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `idempotency_key_invalid` | 400 | The Idempotency-Key header must be 1–255 printable ASCII characters. |
| `idempotency_mismatch` | 409 | The Idempotency-Key was already used with different parameters or another endpoint. |
| `request_in_progress` | 409 | A request with this Idempotency-Key is still being processed; retry shortly. |

### API error: `api_error`

| Code | HTTP | Meaning |
| --- | --- | --- |
| `internal_error` | 500 | Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. |
| `not_implemented` | 501 | This endpoint is not available yet. |
| `service_unavailable` | 503 | A dependency is temporarily unavailable; retry later. |
