Skip to content

Rate limits and errors

Read the quota headers on every API response, handle 429s correctly, understand the error format, and fix the refusals you are most likely to meet.

The public API limits how many requests you can make, and tells you how much you have left on every response. When something goes wrong, every error has the same shape, so your code can switch on one field.

Request quotas

Requests are counted in fixed windows per minute and per day, both per API key and per organisation. The organisation's limit is the ceiling: all your keys together can never exceed it, whatever a single key's own limit says.

The limits depend on your organisation's settings. Read them from the headers rather than hard-coding them. Most requests count as one; a media upload (POST /media) counts as five.

Headers on every response

HeaderMeaning
RateLimit-LimitThe quota of the window closest to running out
RateLimit-RemainingRequests left in that window
RateLimit-ResetSeconds until that window resets (a number of seconds, not a timestamp)
RateLimit-PolicyEvery window that applies, for example "key-minute";q=120;w=60, "key-day";q=100000;w=86400, …
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-ResetThe same numbers, under the names many client libraries look for

In RateLimit-Policy, q is the quota and w is the window length in seconds.

Two different 429s

codeWhat it meansWhat to do
quota_exceededYour quota for a window is used up. details.scope says whether it was the key's (key) or the organisation's (tenant).Wait for the number of seconds in Retry-After, which is when the window resets.
rate_limitedYou are sending bursts faster than the platform accepts. Retry-After is about 1 second. This answer has no RateLimit-* headers.Pause briefly and retry. Spread your requests out.

A media URL import can also give 429 rate_limited with details.reason: media_import_capacity when your organisation already has 2 imports running.

Tip: Watch RateLimit-Remaining and slow down before it reaches zero. You can see your usage over time in API usage.

Plan allowances (402)

Separately from these short windows, your plan may cap API requests or messages sent per billing period. When such an allowance is used up, requests are refused with 402 usage_limit_reached. details says which meter (api_requests or messages_sent), how much is used, the allowance and the period_end. Retrying does not help. A plan change does. See Usage.

The error format

Every error response has this body, never nested under an error key:

json
{
  "code": "template_required",
  "message": "This customer has never messaged this number, so only an approved template may be sent.",
  "fix": "This customer has never messaged this number: send an approved template (type template) to start the conversation.",
  "docs_url": "https://iconengage.com/docs/developers/limits-and-errors#template_required",
  "request_id": "01J9…",
  "details": {}
}
  • code: switch on this. It is a fixed list and won't change meaning.
  • message: for people. It may change between releases, so don't parse it.
  • fix: one sentence saying what to change, for the refusals in Fixing a refusal. It is not on every error. Like message, it is for people and may change, so show or log it, but don't parse it.
  • docs_url: a link to this page, at the explanation of the refusal. It is present exactly when fix is.
  • request_id: the same as the X-Request-Id response header. Quote it when you contact support.
  • details: extra context for some codes, such as the fields that failed validation, the permission that was missing, or the numbers you can send from.

Status codes

StatusCommon code valuesMeaning
200 / 201 / 202Success. 202 on a send means accepted for delivery, not yet delivered.
400validation_failed, invalid_field_value, consent_evidence_required, media_too_large, unsupported_message_typeSomething in the request is wrong. details.fields names each problem, or details.field the one contact field.
401unauthenticatedNo valid API key. See Authenticate API requests.
402plan_feature_unavailable, plan_limit_reached, subscription_restricted, usage_limit_reached, wallet_balance_lowYour plan, subscription or WhatsApp credit balance stops this. No key or permission can lift it.
403permission_deniedThe key lacks the permission this endpoint needs. details.permission names it.
404not_foundNo such item in your organisation. Items of other organisations give the same answer.
409window_expired, template_required, template_not_approved, contact_opted_out, duplicate_request, media_unavailable, conflictThe request is valid but the current state refuses it.
413request_too_largeThe request body is too large.
429quota_exceeded, rate_limitedToo many requests. See above.
503unavailableThe service could not answer right now. Retry.
codeMeaningUseful details
plan_feature_unavailableYour plan does not include this feature.feature, plan, upgrade_plan
plan_limit_reachedA count limit of your plan is reached.entitlement, limit, used
subscription_restrictedYour subscription is restricted or cancelled, so template sends are paused. Replies inside the 24-hour window still work.status, action
usage_limit_reachedA plan allowance is used up for the billing period.meter, used, allowance, period_end
wallet_balance_lowYour WhatsApp credit balance cannot cover a template message of this category. Replies inside the 24-hour window are never refused for this.balance_minor, required_minor, wallet_category, top_up_path

See Plans and trial and WhatsApp credits.

Fixing a refusal

Many refusals carry two more fields beside message: fix, one sentence saying how to fix the request, and docs_url, a link to the heading below that explains it. Each heading is the anchor at the end of a docs_url. Like message, fix is for people, so don't parse it. Switch on code and details.reason.

from_required

400 validation_failed with details.reason: from_required. Your organisation has more than one WhatsApp number that can send, and the request didn't say which to use.

Fix: add from with the number to send from: one of details.numbers, by its id or its phone number. See Choose the sending number.

from_unknown

400 validation_failed on from, with details.reason: from_unknown. The from you sent isn't one of your organisation's numbers.

Fix: use one of details.numbers in from. GET /numbers lists your numbers.

idempotency_key

400 validation_failed on the Idempotency-Key header. A send must carry this header, 8 to 128 characters of letters, digits, ., _, : or -, starting with a letter or digit.

Fix: add an Idempotency-Key header with a value unique to this message, such as a UUID or your order id. Reuse it only to retry the same message.

template_required

409. The customer has never written to this number, so WhatsApp only lets a template start the conversation.

Fix: send an approved template ("type": "template"). See The 24-hour window and templates.

window_expired

409. The customer's 24-hour window is closed: their last message to you was more than 24 hours ago.

Fix: send an approved template ("type": "template"), or wait until they write to you again.

template_variables

400 validation_failed on template.variables, with details.reason: template_variables. The template is approved, but the values don't fit it: a list of the wrong length, a name the template doesn't have, or one of its names left out. details.expected lists the template's keys, names and accepted_counts; when you sent names, details.unknown and details.missing say which didn't fit. It never repeats your values.

Before version 1.5.0 a list of the wrong length came back as 409 template_not_approved with details.accepted_variable_counts, and that refusal links here too.

Fix: give every variable the template has, once. GET /templates/{template_id} lists them with their samples, and its example is a complete body you can copy. See Fill the variables by name.

template_header

400 validation_failed on template.header, with details.reason: template_header. The header you sent doesn't match the approved template's: it's of another format, or the template has no header to fill. details.expected_header says what the template takes: none, text, image, video, document or location.

Fix: give the header the template has: an image, video or document by link or media_id, a location, or the text header's value as text; or leave header out when it takes none. See Give the template's header.

template_not_approved

409. No approved template for this number has this name and language.

Fix: use a template that is approved for this number, with its exact name and language. GET /templates?status=approved lists them.

permission_denied

403. The key lacks the permission this request needs. details.permission names it.

Fix: give the key that permission by creating a new key that has it. A key made with the Send WhatsApp messages preset has everything a send needs. See Create and manage API keys.

key_number_not_allowed

403. The key is limited to some of your numbers, and this request would send from another one. details.phone_number_id is the number it refused, and details.allowed lists the key's numbers. It applies to POST /messages, to POST /flows/{flow_id}/runs, and when you schedule, launch or resume a campaign. A campaign can send from any number of its template's WhatsApp account, so a key limited to some numbers can start one only when every number of that account is the key's.

A send that names no number goes from the key's only number when it has exactly one that can send.

Fix: send from one of the key's numbers (GET /numbers lists only those), or ask an Owner, Admin or Developer to change the key's numbers in Settings › Developers › API keys.

unauthenticated

401. The request has no key, a mistyped key, or a key that has been revoked or whose creator has left.

Fix: send Authorization: Bearer with a key that has not been revoked. Keys are created in Settings › Developers › API keys. See Authenticate API requests.

no_connected_phone_number

409 conflict with details.reason: no_connected_phone_number. Your organisation has no WhatsApp number that can send.

Fix: connect a WhatsApp number in Settings › WhatsApp before sending. See Numbers and accounts.

phone_number_not_connected

409 conflict with details.reason: phone_number_not_connected. The number you named can't send right now. details.status is its status.

Fix: reconnect this number in Settings › WhatsApp, or send from another one (GET /numbers).

contact_opted_out

409. This customer has opted out of your messages.

Fix: message them again only after they opt back in. See Opt-outs and consent.

duplicate_request

409. You reused an Idempotency-Key with a different body.

Fix: use a new Idempotency-Key for a different message. Reuse a key only to retry the same request.

quota_exceeded

429. A request quota for the key or the organisation is used up for the current window. See Request quotas.

Fix: wait the Retry-After seconds, then retry. Watch RateLimit-Remaining to slow down before the quota runs out.

rate_limited

429. You are sending bursts faster than the platform accepts.

Fix: pause about a second and retry, and spread your requests out.

media_unavailable

409. The media object you named isn't ready to send. details.state says where it is.

Fix: wait until the media is ready (GET /media/{media_id}), or upload it again.

contact_field_required

400 invalid_field_value with details.reason: required. Your organisation has made the contact field in details.field required, and a contact you created with POST /contacts would be left without it, or a request tried to clear it with null. The message names the field.

A send never needs it. POST /messages to a new number creates the contact without your required fields, and so do a flow run and POST /contacts/consent. An update of a contact you already have, with POST /contacts or PATCH /contacts/{contact_id}, checks only the fields you send. No request can clear a required field with null, though.

Fix: give attributes.<field> a value (GET /contact-fields marks each required field), or make the field optional in Contacts › Fields and tags. See Custom fields and tags.

invalid_field_value

400 invalid_field_value with details.reason: unknown_field or invalid_value. With unknown_field, the key in details.field isn't one of your organisation's contact fields. With invalid_value, the field exists but the value doesn't fit it: text in a number field, a date that isn't a date, or a choice that isn't one of the field's options. The message says which. It never repeats your value.

This can come from attributes on POST /contacts, PATCH /contacts/{contact_id}, or the contact of a send. A send refused this way sends nothing.

Fix: use only your organisation's contact fields, each with a value of its type. GET /contact-fields lists every field's key, type and options.

to_needs_country_code

400 validation_failed on to, with details.reason: to_needs_country_code. The number has no + and country code, so it can't be read safely: 98XXX XXXXX would be read as Iran's +98.

Fix: write it in international format, with + and the country code, for example +91 XXXXX XXXXX.

Good habits

  • Retry safely. On a timeout or a 503, retry with backoff. For POST /messages, reuse the same Idempotency-Key so the customer never gets a message twice.
  • Don't retry 4xx answers unchanged, except 429 after waiting Retry-After.
  • Log request_id with every error, and fix when there is one.

If a message was accepted but never arrived, see Messages not delivered.

Still need help?

Write to us at [email protected] and tell us what you were trying to do. Already a customer? Sign in to IconEngage — the same articles are under Help in the app.