Skip to content

    Arabic or English · ↑↓ to move · Enter to open · Esc to close

    العربية
    On this page

    Messages

    Send a template

    POST/v2/messages
    • Scope:messages:send
    • Idempotency-Key:required
    • number key ok— Also accepts the legacy per-number x-api-key, for its own number.
    • changes settings

    An approved WhatsApp template (Templates page / Meta review) can start a conversation at any time, also outside the 24-hour window. template: {name, language, params | components}: params fill the body variables {{1}}, {{2}}… in order; components (Graph API format) are for header media, buttons and named variables. Meta bills templates per message by category (marketing, utility, authentication).

    Request

    curl -X POST "https://mursilat.com/api/v2/messages" \
      -H "Authorization: Bearer $WASLA_API_KEY" \
      -H "Idempotency-Key: order-1042-confirm" \
      -H "Content-Type: application/json" \
      -d '{
      "numberId": "cm1abcd2345efgh6789ijkl",
      "to": "201001234567",
      "type": "template",
      "template": {
        "name": "order_shipped",
        "language": "ar",
        "params": [
          "منى",
          "1042"
        ]
      },
      "reference": "order-1042"
    }'
    Request — JSON
    {
      "numberId": "cm1abcd2345efgh6789ijkl",
      "to": "201001234567",
      "type": "template",
      "template": {
        "name": "order_shipped",
        "language": "ar",
        "params": [
          "منى",
          "1042"
        ]
      },
      "reference": "order-1042"
    }

    Response

    200Example

    200 — application/json
    {
      "id": "3EB0A1B2C3D4E5F60718",
      "numberId": "cm1abcd2345efgh6789ijkl",
      "status": "sent",
      "type": "template",
      "reference": "order-1042",
      "scheduledAt": null,
      "interactionId": null,
      "format": null,
      "fallbackIncluded": null,
      "estimatedDelayMs": null
    }

    Fields in this response

    Fields of the example answer. Expand objects and arrays.

    • responseobject10 fields
      • idstring "3EB0A1B2C3D4E5F60718"
      • numberIdstring "cm1abcd2345efgh6789ijkl"
      • statusstring "sent"
      • typestring "template"
      • referencestring "order-1042"
      • scheduledAtnull null
      • interactionIdnull null
      • formatnull null
      • fallbackIncludednull null
      • estimatedDelayMsnull null

    Parameters

    Headers

    NameTypeConstraintsDescription
    Idempotency-KeyrequiredTypestringConstraints≤ 191 charsDescriptionYour unique id for this operation (≤ 191 visible ASCII). A retry with the same key and body returns the first answer with Idempotent-Replayed: true — it never runs twice. Kept 24 h.
    X-Request-IdoptionalTypestringConstraints—DescriptionOptional: your own request id, echoed back (otherwise we generate req_…). Quote it to support.

    Errors

    Besides the authentication, rate-limit and validation errors every endpoint can return:

    • 400 · MESSAGE_TEMPLATE_REQUIRED — type "template" needs a template object {name, language, params | components}.

      Send the approved template name and language.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_REQUIRED",
          "message": "type \"template\" needs a template object {name, language, params | components}.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_REQUIRED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · MESSAGE_TEMPLATE_NAME_INVALID — template.name must be the approved template name (lowercase letters, digits, _).

      Copy the name from the Templates page.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_NAME_INVALID",
          "message": "template.name must be the approved template name (lowercase letters, digits, _).",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_NAME_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · MESSAGE_TEMPLATE_LANGUAGE_INVALID — template.language must be a code such as "ar" or "en_US".

      Use the language the template was approved in.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_LANGUAGE_INVALID",
          "message": "template.language must be a code such as \"ar\" or \"en_US\".",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_LANGUAGE_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · MESSAGE_TEMPLATE_PARAMS_INVALID — template.params must be up to 20 non-empty values, one per {{n}}.

      Send one value for each variable of the template body.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_PARAMS_INVALID",
          "message": "template.params must be up to 20 non-empty values, one per {{n}}.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_PARAMS_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · MESSAGE_TEMPLATE_PARAMS_CONFLICT — Send template.params or template.components, not both.

      Use params for simple body variables, components for headers/buttons.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_PARAMS_CONFLICT",
          "message": "Send template.params or template.components, not both.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_PARAMS_CONFLICT",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · MESSAGE_TEMPLATE_COMPONENTS_INVALID — template.components must be up to 10 Graph API component objects.

      See Meta’s template message components.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "MESSAGE_TEMPLATE_COMPONENTS_INVALID",
          "message": "template.components must be up to 10 Graph API component objects.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#MESSAGE_TEMPLATE_COMPONENTS_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · CLOUD_API_ONLY — Templates can only be sent from an official WhatsApp Business number.

      Use a numberId connected through Meta.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "CLOUD_API_ONLY",
          "message": "Templates can only be sent from an official WhatsApp Business number.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#CLOUD_API_ONLY",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · CLOUD_API_SEND_FAILED — Meta refused the message (the message says why, e.g. template not approved or wrong parameters).

      Fix the template name, language or parameters and retry.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "CLOUD_API_SEND_FAILED",
          "message": "Meta refused the message (the message says why, e.g. template not approved or wrong parameters).",
          "docsUrl": "https://mursilat.com/developers/v2/errors#CLOUD_API_SEND_FAILED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · IDEMPOTENCY_KEY_REQUIRED — Idempotency-Key header is required.

      Send one unique value per logical request.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "IDEMPOTENCY_KEY_REQUIRED",
          "message": "Idempotency-Key header is required.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#IDEMPOTENCY_KEY_REQUIRED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 400 · IDEMPOTENCY_KEY_INVALID — Idempotency-Key must be 1–191 visible ASCII characters.

      Use e.g. order-1042-confirm.

      Correct the cause before repeating the request.

      HTTP 400 · application/json
      {
        "error": {
          "code": "IDEMPOTENCY_KEY_INVALID",
          "message": "Idempotency-Key must be 1–191 visible ASCII characters.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#IDEMPOTENCY_KEY_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 409 · IDEMPOTENCY_KEY_REUSED — This Idempotency-Key was used with a different request.

      Use a new key for a new request.

      Correct the cause before repeating the request.

      HTTP 409 · application/json
      {
        "error": {
          "code": "IDEMPOTENCY_KEY_REUSED",
          "message": "This Idempotency-Key was used with a different request.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#IDEMPOTENCY_KEY_REUSED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 409 · IDEMPOTENCY_IN_PROGRESS — The first request with this key is still running.

      Retry in a few seconds.

      Retry after addressing the cause.

      HTTP 409 · application/json
      {
        "error": {
          "code": "IDEMPOTENCY_IN_PROGRESS",
          "message": "The first request with this key is still running.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#IDEMPOTENCY_IN_PROGRESS",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 403 · SCOPE_REQUIRED — The key lacks the scope of this endpoint.

      Add the scope in details.required to the key.

      Correct the cause before repeating the request.

      HTTP 403 · application/json
      {
        "error": {
          "code": "SCOPE_REQUIRED",
          "message": "The key lacks the scope of this endpoint.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#SCOPE_REQUIRED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 401 · API_KEY_REQUIRED — No API key was sent.

      Send Authorization: Bearer wsl_live_…

      Correct the cause before repeating the request.

      HTTP 401 · application/json
      {
        "error": {
          "code": "API_KEY_REQUIRED",
          "message": "No API key was sent.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#API_KEY_REQUIRED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 401 · API_KEY_INVALID — The API key is not valid.

      Copy the key again from Settings → API keys (it is shown only once; create a new one if lost).

      Correct the cause before repeating the request.

      HTTP 401 · application/json
      {
        "error": {
          "code": "API_KEY_INVALID",
          "message": "The API key is not valid.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#API_KEY_INVALID",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors
    • 429 · RATE_LIMITED — Rate limit of this key reached.

      Wait Retry-After seconds; watch X-RateLimit-Remaining.

      Retry after addressing the cause.

      HTTP 429 · application/json
      {
        "error": {
          "code": "RATE_LIMITED",
          "message": "Rate limit of this key reached.",
          "docsUrl": "https://mursilat.com/developers/v2/errors#RATE_LIMITED",
          "requestId": "req_6604bedc8c489f20e582691a"
        }
      }
      Errors

    Errors →

    Behaviour notes

    Meta can still refuse a template after the send: watch message.status — failed with TEMPLATE_NOT_FOUND, TEMPLATE_PARAMS_MISMATCH, TEMPLATE_PAUSED, META_MARKETING_LIMIT, RECIPIENT_STOPPED_MARKETING…; template reviews arrive as template.status.

    Try it

    Send this request from your browser to the Mursilat API.

    documented example

    Preview — this copy of the docs isn’t on mursilat.com, so the console shows the documented example instead of calling the API.

    Real requests use your real number and plan: they can send WhatsApp messages, spend quota and delete data. (changes settings)

    Kept only in this tab’s memory: never saved, never put in the URL, sent only to mursilat.com. Reloading the page forgets it.

    Send this request for real?

    This changes your account settings.

    POST /v2/messages