Guides
Messages

Templates

Create templates, simulate Meta's review, send them with parameters (OTP included) and handle the status, quality and category webhooks.

Templates are the only way to start a conversation or to talk to a customer outside the 24-hour window. They belong to the WABA and must be APPROVED to be sent.

Create

bash
curl --request POST \
  --url https://whatsapp.mimicr.dev/v24.0/313255174969123/message_templates \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "pedido_confirmado",
    "language": "pt_BR",
    "category": "UTILITY",
    "components": [
      { "type": "BODY", "text": "Oi {{1}}, recebemos o pedido {{2}}. Avisaremos quando sair para entrega.", "example": { "body_text": [["Ana", "#1042"]] } },
      { "type": "BUTTONS", "buttons": [{ "type": "QUICK_REPLY", "text": "Falar com atendente" }] }
    ]
  }'
json
{ "id": "591246717117208", "status": "PENDING", "category": "UTILITY" }

Names only take lowercase letters, numbers and _ (otherwise subcode 2388042). The same name in the same language answers subcode 2388024. parameter_format: "NAMED" allows {{name}} variables, filled with parameter_name.

Review

With Meta the review is automatic. In Mimicr, the template stays PENDING until you decide, in the console or with the control API:

bash
curl --request POST \
  --url https://api.mimicr.dev/v1/whatsapp/docs/templates/591246717117208/review \
  --header 'Authorization: Bearer mk_...' \
  --header 'Content-Type: application/json' \
  --data '{ "action": "approve" }'
actionStatusWebhook
approveAPPROVEDmessage_template_status_update, event: APPROVED
rejectREJECTEDevent: REJECTED, reason (default INVALID_FORMAT, or the reason you send)
pausePAUSEDevent: PAUSED with other_info
disableDISABLEDevent: DISABLED
reinstateAPPROVEDevent: REINSTATED
quality(unchanged)message_template_quality_update (quality: GREEN, YELLOW, RED)
recategorize(unchanged)template_category_update (new category)
json
{
  "object": "whatsapp_business_account",
  "entry": [{
    "id": "313255174969123",
    "time": 1793914190,
    "changes": [{
      "field": "message_template_status_update",
      "value": { "event": "APPROVED", "message_template_id": 591246717117208, "message_template_name": "pedido_confirmado", "message_template_language": "pt_BR", "reason": "NONE" }
    }]
  }]
}

Send with parameters

bash
curl --request POST \
  --url https://whatsapp.mimicr.dev/v24.0/424361664134261/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "messaging_product": "whatsapp",
    "to": "5511987654321",
    "type": "template",
    "template": {
      "name": "pedido_confirmado",
      "language": { "code": "pt_BR" },
      "components": [{ "type": "body", "parameters": [{ "type": "text", "text": "Ana" }, { "type": "text", "text": "#1042" }] }]
    }
  }'
json
{
  "messaging_product": "whatsapp",
  "contacts": [{ "input": "5511987654321", "wa_id": "5511987654321" }],
  "messages": [{ "id": "wamid.HBgNNTUxMTk4NzY1NDMyMRUCABEYEjExMUUxQzk2RDk4MTZCODY5MwA=", "message_status": "accepted" }]
}
ErrorWhen
132001Name or language does not exist, or the template is not approved
132000Parameter count differs from the template
132012Parameter in the wrong format (e.g. image header without image)
132015 / 132016Template paused / disabled
132005Final text longer than 1024 characters

When the customer taps a quick reply of the template, a type: "button" message arrives with button.payload and button.text (see Incoming messages).

Authentication templates (OTP)

json
{
  "name": "codigo_acesso",
  "language": "pt_BR",
  "category": "AUTHENTICATION",
  "components": [
    { "type": "BODY", "add_security_recommendation": true },
    { "type": "FOOTER", "code_expiration_minutes": 10 },
    { "type": "BUTTONS", "buttons": [{ "type": "OTP", "otp_type": "COPY_CODE", "text": "Copiar código" }] }
  ]
}

The code goes as the single body parameter and again in the url button:

json
{
  "messaging_product": "whatsapp",
  "to": "5521998761234",
  "type": "template",
  "template": {
    "name": "codigo_acesso",
    "language": { "code": "pt_BR" },
    "components": [
      { "type": "body", "parameters": [{ "type": "text", "text": "482913" }] },
      { "type": "button", "sub_type": "url", "index": "0", "parameters": [{ "type": "text", "text": "482913" }] }
    ]
  }
}

The code has up to 15 characters. In a test, read what the phone received with GET /v1/whatsapp/{slug}/contacts/{wa_id}/otp/latest and use the OTP scenarios of Sandbox testing.

List, edit and delete

  • List templates filters by name, status, category, language and quality_score, with fields, limit and after/before cursors.
  • Edit a template changes components, category or message_send_ttl_seconds; an approved template goes back to PENDING and message_template_components_update goes out.
  • Delete templates by name removes every language (or one, with hsm_id); Delete a template removes by ID.

Sample header media

Templates with an IMAGE, VIDEO or DOCUMENT header need an example.header_handle, obtained from the Resumable Upload API: Start an upload session with the app token, then Upload the file data, which returns the h handle.