NewWhatsApp, Instagram, Messenger, email, SMS and website chat, now in one inbox
CAT Engage 360

Send a message

Send a WhatsApp message to a phone number: an approved template, a text reply, a file or a message with buttons. If the number isn't a contact yet, the contact and its conversation are created, and the message shows in your inbox like any other.

POST/api/v1/messages

Needs the scope messages:send

Templates first, free text within 24 hours

WhatsApp lets businesses start a conversation only with a template Meta has approved. Text, media and buttons work while the customer's last message is less than 24 hours old. Outside that window Meta refuses the message and you get meta_error.

Body#

A JSON object. Only the fields for the message type you send are used.

  • tostringRequired
    The customer's phone number in international format, for example +919876543210.
  • typestringoptional
    One of text, template, image, video, document, audio or interactive. Default: text.
  • textstringoptional
    The message for text (required there), or the caption for an image, video or document (up to 1,024 characters).
  • templateobjectoptional
    Required when type is template. The template must be approved by Meta and synced in CAT Engage. List templates tells you the names and exactly which values each one needs.
    • namestringRequired
      The template name, for example order_update.
    • languagestringoptional
      Language code such as en_US. Leave it out to use the approved template with that name.
    • paramsstring[] | objectoptional
      The values for the template's variables. A list fills the body in order ({{1}}, {{2}}…). For more, send an object: body (list), headerText, headerMediaUrl (an https link) and buttonParams (button index to value, for example { "0": "A-1042" }).
  • media_urlstringoptional
    Required for image, video, document and audio. A public https:// link to the file.
  • filenamestringoptional
    The file name the customer sees, for documents. For example invoice.pdf.
  • interactive_payloadobjectoptional
    Required for interactive. Up to 3 reply buttons, or a list of up to 10 rows. When the customer taps one, its id comes back as interactive_reply_id in the message.received webhook.
    • kind"buttons" | "list"Required
      Which layout to send.
    • bodystringRequired
      The message text above the buttons or list (up to 1,024 characters).
    • headerstringoptional
      Optional plain-text header (up to 60 characters).
    • footerstringoptional
      Optional grey footer line (up to 60 characters).
    • buttonsobject[]optional
      For buttons: 1 to 3 items of { id, title }. Titles up to 20 characters.
    • button_labelstringoptional
      For list: the label of the button that opens the list (up to 20 characters).
    • sectionsobject[]optional
      For list: sections of { title?, rows: [{ id, title, description? }] }, 10 rows in total at most.
  • reply_to_message_idstringoptional
    Quote an earlier message in the same conversation (our message id).
  • namestringoptional
    A name for the contact, used only when this number is new.

Examples#

Template with a variable

Fills {{1}} in the template body with the order number.

curl -X POST https://app.catengage360.com/api/v1/messages \
  -H "Authorization: Bearer cat_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+919876543210",
  "type": "template",
  "template": {
    "name": "order_update",
    "language": "en_US",
    "params": [
      "A-1042"
    ]
  }
}'

Text reply

curl -X POST https://app.catengage360.com/api/v1/messages \
  -H "Authorization: Bearer cat_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+919876543210",
  "text": "Your order is out for delivery and will reach you by 6 pm."
}'

Document with a caption

curl -X POST https://app.catengage360.com/api/v1/messages \
  -H "Authorization: Bearer cat_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+919876543210",
  "type": "document",
  "media_url": "https://example.com/invoices/A-1042.pdf",
  "filename": "Invoice A-1042.pdf",
  "text": "Here is your invoice."
}'

Reply buttons

curl -X POST https://app.catengage360.com/api/v1/messages \
  -H "Authorization: Bearer cat_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
  "to": "+919876543210",
  "type": "interactive",
  "interactive_payload": {
    "kind": "buttons",
    "body": "Would you like to confirm your appointment for Friday at 11 am?",
    "buttons": [
      {
        "id": "confirm",
        "title": "Confirm"
      },
      {
        "id": "reschedule",
        "title": "Reschedule"
      }
    ]
  }
}'

Response#

201Message sent to WhatsApp

JSON
{
  "data": {
    "message_id": "0f6b1c52-8d0e-4b8c-9a51-3f1e2d7c9a10",
    "whatsapp_message_id": "wamid.HBgMOTE5ODc2NTQzMjEwFQIAERgS…",
    "conversation_id": "5d2a9e47-1c3b-4f6e-8a20-7b9c1d4e6f81",
    "contact_id": "a81c3f09-2e5d-4b7a-9c64-0d1e2f3a4b5c",
    "contact_created": false
  }
}

Keep whatsapp_message_id: delivery updates (sent, delivered, read, failed) arrive with it in the message.status_updated webhook. contact_created is true when this number was new.

403Account not approved yet

JSON
{
  "error": {
    "code": "account_not_approved",
    "message": "Your account is waiting for approval. You can send messages once it is approved."
  }
}

Errors#

Branch on error.code. The message explains what went wrong in plain words.

CodeStatusWhat it means
bad_request400A field is missing or invalid, for example no to, no text for a text message, or a media link that isn't https.
template_not_found400No template with that name. Sync templates from Meta in Settings, then try again.
template_not_approved400The template exists but Meta hasn’t approved it, or it is paused or disabled.
whatsapp_not_configured400WhatsApp is not connected for this business, or needs reconnecting.
unauthorized401The API key is missing, wrong, revoked or expired.
forbidden403The key doesn't have the messages:send scope.
account_not_approved403The business is waiting for approval. Reads and contacts work; sending starts after approval.
account_suspended403Messaging is paused for this business.
plan_limit403The number is new and the plan’s contact limit is reached.
rate_limited429More than 120 requests a minute with this key. Wait for the seconds in Retry-After.
meta_error502WhatsApp refused the message, for example free text outside the 24-hour window. The message includes Meta’s reason.

Sending to many people?

Use a broadcast instead of looping over this endpoint. It is paced for you, skips people who opted out, and reports progress.