Skip to content

Send messages

Send buttons

Send reply or link buttons on WhatsApp, and action buttons on Instagram and Messenger, with POST /v1/messages.

POST /v1/messages with type: "interactive" sends reply or link buttons on WhatsApp. On Instagram and Messenger the equivalent is type: "buttons". The fields shared by every send are in Common fields.

  • An API key with the send permission (see Authentication).
  • An Active connection for the channel.
  • An interactive message is a free-form message: it only goes out within 24 hours of the contact’s last message (see Windows). Outside it, use a template.

interactive.type: "button" shows 1 to 3 buttons. When the contact taps one, the button id comes back to you.

Janela do terminal
curl https://api.messajo.com/v1/messages \
-H "Authorization: Bearer $MESSAJO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"connection_id": "conn_...",
"to": "5511999999999",
"type": "interactive",
"interactive": {
"type": "button",
"header": {
"type": "text",
"text": "Your order"
},
"body": {
"text": "Your order #123 arrived. Did everything go well?"
},
"footer": {
"text": "Reply with one tap"
},
"action": {
"buttons": [
{
"type": "reply",
"reply": {
"id": "sim",
"title": "Yes"
}
},
{
"type": "reply",
"reply": {
"id": "nao",
"title": "No"
}
}
]
}
}
}'
Field Rule
interactive.body.text Required, 1 to 1024 characters.
interactive.header Optional. { "type": "text", "text": "…" } with up to 60 characters. The type can also be image, video or document.
interactive.footer.text Optional, up to 60 characters.
interactive.action.buttons 1 to 3 items { "type": "reply", "reply": { "id", "title" } }.
reply.id 1 to 256 characters. This is what you get back.
reply.title 1 to 20 characters. This is the button label.

interactive.type: "cta_url" shows a single button that opens a URL. header and footer are optional, as with reply buttons.

Janela do terminal
curl https://api.messajo.com/v1/messages \
-H "Authorization: Bearer $MESSAJO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"connection_id": "conn_...",
"to": "5511999999999",
"type": "interactive",
"interactive": {
"type": "cta_url",
"body": {
"text": "Track the delivery with the link."
},
"action": {
"name": "cta_url",
"parameters": {
"display_text": "Track order",
"url": "https://exemplo.com/pedido/123"
}
}
}
}'

display_text is 1 to 20 characters and url is the page it opens.

The tap arrives as a message.received event, with data.message.content of type reply:

{
"type": "message.received",
"data": {
"message": {
"direction": "inbound",
"content": {
"type": "reply",
"kind": "button",
"id": "sim",
"title": "Yes",
"description": null,
"payload": null
}
}
}
}

id and title are those of the tapped button. Tie your logic to the id, not the text, which you may change.

On these channels use type: "buttons": a text of 1 to 640 characters and 1 to 3 buttons. Each button is postback (title 1 to 20 and payload 1 to 1000 characters, returned when the contact taps) or web_url (title 1 to 20 and an https url). quick_replies is also accepted.

Janela do terminal
curl https://api.messajo.com/v1/messages \
-H "Authorization: Bearer $MESSAJO_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"connection_id": "conn_...",
"to": "17841400000000000",
"type": "buttons",
"buttons": {
"text": "How can we help?",
"buttons": [
{
"type": "postback",
"title": "Talk to sales",
"payload": "vendas"
},
{
"type": "web_url",
"title": "Visit site",
"url": "https://exemplo.com"
}
]
}
}'

For several cards with image, title and buttons, use type: "cards": 1 to 10 cards, with a title of up to 80 characters and, optionally, subtitle, image_url, default_url and buttons. See Message types.