Arrow
Get started with Wazzup
Arrow
How to connect a messenger
Arrow
How to use Wazzup chats
Arrow
How to pay for the service
Arrow
Bitrix24
Arrow
Kommo
Arrow
Zoho CRM
Arrow
HubSpot
Arrow
Pipedrive
Arrow
Other CRMs
Arrow
How to sell even easier
Arrow
All about WABA
Arrow
For partners
Arrow
Public API
Public API
Arrow

Sending messages

In this article, we will thoroughly examine the process of sending, editing, and deleting messages via the Wazzup API.

How to send messages

To send messages it is necessary to call:

POST https://api.wazzup24.com/v3/message
POST https://api.wazzup24.com/v3/message
├── channelId *
├── chatType *
├── chatId
├── text
├── contentUri
├── refMessageId
├── crmUserId
├── crmMessageId
├── username
├── phone
├── clearUnanswered
├── templateId
├── templateValues[]
└── buttonsObject
    ├── buttons[]
    │   ├── text
    │   ├── type
    │   ├── url
    │   └── callbackData
    ├── replyMarkup
    ├── removeKeyboard
    └── oneTimeKeyboard

In the message body you should pass the parameters of the message with the authorization data in the header.

Parameter

Required parameters are marked with an asterisk
Type Description
channelId* String Id of the channel (uuidv4) through which to send the message
chatType* String Available values:
  • WhatsApp: "whatsapp",
  • Viber: "viber"
  • WhatsApp group chat: "whatsgroup",
  • Instagram: "instagram",
  • Telegram: "telegram".
chatId String Chat ID (contact's account in messenger):
  • for "whatsapp" and "viber" — only numbers, without spaces and special characters in the format 79011112233,
  • for "instagram" — an account without "@" in the beginning,
  • for "whatsgroup" — comes in webhooks of incoming messages,
  • for "telegram" — comes in webhooks of incoming messages and in response to a request when sending an outgoing one with phone or username parameters.
text String Message text. Obligatory if contentUri is not specified. Both text and contentUri cannot be sent at the same time. Restrictions:
  • for WhatsApp up to 10 000 characters,
  • for Instagram up to 1000 characters,
  • for WABA up to 550 characters in a template message, and 1024 characters in a regular message,
  • for Telegram up to 4096 characters.

Whatsapp, WABA, Viber, Telegram Bot messages can be formatted using the following symbols:

  • *bold*
  • _italic_
  • ```Monospaced```
  • ~strikethrough~

Telegram Bot messages can also be formatted using the following tags:

<code><b>bold</b></code> — for bold text
<code><i>italic</i></code> — italic
<code><u>underlined</u></code> — underlined
<code><s>strikethrough</s></code> — strikethrough

Telegram Personal, Instagram messages cannot be formatted.

If you do not work with the "templateId" parameter for WABA, you can send a template approved by Meta using the text parameter. To do this, specify the template code in the value and fill in the variables, if any. Example:

text: "@template: 6201005a-9a6f-486f-bdd5-e6cb86c76ddb { [[variable value]] }"

contentUri String A link to the file to send. Required if text is not specified.

The content must be downloaded via a link without redirects.

An attempt to download content will be made as soon as the request is received, i.e. short-lived links can be made. There may be restrictions on the type and size of content, specific to each messenger.

Both text and contentUri cannot be transmitted at the same time.

Telegram voice messages up to 1 MB in .mp3 and .ogg formats will be sent as voice messages. Other formats and larger recordings will be sent as files.
refMessageId String Id of the message to cite.
crmUserId String CRM user id specified with CRUD users. If specified, and if such a user already exists, we will save his id and name as when sending via iframe

Does not work when connecting via Sidecar API
crmMessageId String Message identifier on the CRM side. Needed to make the routing idempotent.
username String For Telegram Personal only.
The username of the Telegram contact, with no @ at the beginning. Can be used when sending messages via Telegram if chatId is not known
phone String For Telegram Personal only.
Contact's phone number in international format, without "+" and other symbols, only numbers, with the correct country code. Can be used when sending messages via Telegram if the chatId is not known
clearUnanswered Boolean Whether to reset the unanswered counter.

Specify "false" to prevent the message from resetting the counter. For example, with automation. So the CRM user will see a notification of a new incoming, even if his client has left an automatic response.

If nothing is specified, the outgoing message will reset the counter.
templateId String WABA template code.
templateValues String (Array) Values to fill in the variables in the template.
buttonsObject Object buttonsObject

Buttons attached to a message. Can be used for:

  • WABA templates
  • WABA interactive messages
  • Telegram Bot messages with buttons

WABA interactive message – a message with buttons that can be sent within an active 24-hour conversation with a customer on a WABA channel.

WABA templates – templates approved by Meta moderation. They are used to initiate a 24-hour conversation.

When working with WABA templates, the buttonsObject is only useful if you want to attach a payload to the buttons. You do not need to specify the button text for WABA templates here, as it is defined during template creation and moderation.

buttonsObject (object)

Parameter Type Description
buttons Object[ ] buttons An array of objects with buttons. No more than 10.

If the array is larger, take the first 10 buttons.
replyMarkup String Telegram Bot keyboard types for messages with buttons:
  • Inline keyboard: inline
  • Custom (reply) keyboard: reply
removeKeyboard Boolean This parameter is used to remove the custom (reply) keyboard when set to true.
oneTimeKeyboard Boolean Set to true to hide the custom keyboard after a button is pressed (the keyboard is not removed from the chat).
payload String Payload from templates and WABA interactive message buttons.

buttons (object)

Parameter Type Description
text String

This field is required for working with WABA interactive messages and Telegram Bot messages.

Character limit for button labels:

  • WABA: 20 characters
  • Telegram Bot: 64 characters
type String Button type. Needed to work with WABA interactive messages.

Now we only support text format so specify "text" type.
url String For Telegram Bot messages with buttons. This field contains the URL that will open when the button is pressed.
callbackData String For Telegram Bot messages with buttons. This field contains the data (1-64 bytes) that will be sent to the bot as a callback when the button is pressed.
Route is not idempotent! Repeated requests with the same content will result in sending several identical messages. To protect against possible duplicate messages, you can add the crmMessageId property unique to the message.

If it was sent, then if another request with the same crmMessageId is received, the message will not be sent, the error 400 Bad Request, { error: 'repeatedCrmMessageId', description: 'You have already sent message with the same crmMessageId' } will be returned.

Important: In order to send WABA templates in the "text" field you must pass the "template code", which you can obtain from support. If there are variables in the template, you should replace them with the necessary values at the moment of sending. You can read more about how to add a template and examples of how to use it in the article.

Regular message request example

fetch("https://api.wazzup24.com/v3/message", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer {apiKey|sidecarApiKey}",
  },
  body: {
    channelId: "e0629e11-0f67-4567-92a9-2237e91ec1b9",
    refMessageId: "61e5a375-1760-452f-ad73-5318844ffc4f",
    crmUserId: "string-user-id",
    crmMessageId: "string-crm-message-id",
    chatId: "string-chat-id",
    chatType: "whatsapp",
    text: "message text"
  },
});

WABA template request example

Request to submit a WABA template with 3 buttons. Each has a payload.

fetch("https://api.wazzup24.com/v3/message", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer {apiKey|sidecarApiKey}",
  },
  body: {
    channelId: "24197d5f-06de-421f-8576-9f6e6cb67f28",
    chatType: "whatsapp",
    chatId: "79994621848",
    templateId: "6201005a-9a6f-486f-bdd5-e6cb86c76ddb",
    templateValues: ["value"]
    buttonsObject: {
      buttons: [
          { payload: "button_payload 1" },
          { payload: "button_payload 2" },
          { payload: "button_payload 3" }
      ]
    }
  },
});

The request for WABA templates with buttons does not require button text. They are moderated along with the main text of the template, so the buttons cannot be changed.

buttonsObject is only useful if you need to specify a payload for the buttons.

WABA interactive message request example

In this request we send an interactive message with 3 buttons: "Yes", "No" and "Maybe". The buttons have no payload.

fetch("https://api.wazzup24.com/v3/message", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer {apiKey|sidecarApiKey}",
  },
  body: {
    channelId: "e0629e11-0f67-4567-92a9-2237e91ec1b9",
    refMessageId: "61e5a375-1760-452f-ad73-5318844ffc4f",
    crmUserId: "string-user-id",
    crmMessageId: "string-crm-message-id",
    chatId: "string-chat-id",
    chatType: "whatsapp",
    text: "message text",
    buttonsObject: {
      buttons: [
          {text: "Yes", type: "text"},
          {text: "No", type: "text"},
          {text: "Maybe", type: "text"}
      ]
    }
  },
});

Telegram Bot inline keyboard message

Each inline keyboard button must include either a callback_data or url parameter.

Button layout is defined in an array, which determines their arrangement both in rows and within each row.

Example:

This request body contains an inline keyboard with three buttons: "ONE", "TWO", and "THREE".

  • The "ONE" button includes a url parameter.
  • The "TWO" and "THREE" buttons include callback_data parameters.

The button layout consists of two rows:

  • First row: "ONE" button;
  • Second row: "TWO" and "THREE" buttons.
{
   "channelId": "3dbcc57d-de7d-43d9-8414-0f8b86aa2cf2",
   "chatType": "telegram",
   "chatId": "779064031",
   "text": "INLINE TEXT",
   "buttonsObject": {
       "replyMarkup": "inline",
       "buttons": [
           [
               {
                   "text": "ONE",
                   "url": "https://www.youtube.com"
               }
           ],
           [
               {
                   "text": "TWO",
                   "callbackData": "TWO"
               },
               {
                   "text": "THREE",
                   "callbackData": "THREE"
               }
           ]
       ]
   }
}

Messages with a custom Telegram Bot keyboard

Custom keyboard buttons only transmit text. Additional parameters are not transmitted.

The button layout is defined in an array, which specifies the order of placement both by row and within each row.

Example

This request body transmits a custom keyboard with three buttons: "ONE", "TWO", and "THREE". The oneTimeKeyboard parameter is also transmitted. The button layout consists of two rows:

  • The first row contains the "ONE" button.
  • The second row contains the "TWO" and "THREE" buttons.
{
   "channelId": "3dbcc57d-de7d-43d9-8414-0f8b86aa2cf2",
   "chatType": "telegram",
   "chatId": "779064031",
   "text": "INLINE TEXT",
   "buttonsObject": {
       "replyMarkup": "reply",
       "oneTimeKeyboard": true,
       "buttons": [
           [
               {
                   "text": "ONE"
               }
           ],
           [
               {
                   "text": "TWO"
               },
               {
                   "text": "THREE"
               }
           ]
       ]
   }
}

Message includes the parameter, which removes the current custom keyboard

This message includes the remove_keyboard parameter, which removes the current custom keyboard.

{
   "channelId": "3dbcc57d-de7d-43d9-8414-0f8b86aa2cf2",
   "chatType": "telegram",
   "chatId": "779064031",
   "text": "INLINE delete",
   "buttonsObject": {
       "replyMarkup": "reply",
       "removeKeyboard": true
   }
}

Response

If you send a template without a payload via the API, we will send the text of the corresponding button in the response message webhook. If you send an interactive message without a payload, we will send the button's serial number, starting from 0.

Parameter Type Description
messageId String Message identifier.

Specified only when code=OK
chatId String Chat Id.

Specified only when code=OK

Response example

HTTP/1.1 201 OK 
{ 
    "messageId": "f66c53a6-957a-46b2-b41b-5a2ef4844bcb", 
    "chatId": "79999999999" 
}

Errors when sending messages

If the request contains incorrect data or parameters, the system will return one of the following errors:

1. Invalid Parameter Values

If a parameter value does not meet the requirements (for example, channelId is not in UUID format, chatId is not a string, or chatType does not match the allowed values), the API will return the following error:

{
    "status": 400,
    "requestId": "7ca68797d127735e72b066b0080e2cc0",
    "error": "INVALID_MESSAGE_DATA",
    "description": "Message data is invalid",
    "data": {
        "fields": [
            "channelId"
        ]
    }
}

Solution: Check the validity of the parameter values being passed. The data.fields array will indicate the parameter that contains the error.

2. Mismatch Between Transport Type and Channel

If the request specifies a channelId with one transport type, but the chatType belongs to another transport, the API will return the following error:

{
    "status": 400,
    "requestId": "21a9be7692d378b0270e7fc1d993381a",
    "error": "WRONG_TRANSPORT",
    "description": "You can't send message to vk chat from whatsapp transport",
    "data": {
        "channelId": "dffa1c7b-6db8-4b8f-b559-91166aba879e",
        "transport": "whatsapp",
        "chatType": "vk"
    }
}

Solution: Ensure that chatType matches the transport type specified in channelId.

3. Reusing crmMessageId

If the request includes a crmMessageId that was already used within the last 60 seconds, the API will return the following error:

{
    "status": 400,
    "requestId": "c1005276e8a2b5aa23fcc94407d39f49",
    "error": "REPEATED_CRM_MESSAGE_ID",
    "description": "You have already sent message with same crmMessageId",
    "data": {
        "crmMessageId": "1"
    }
}

Solution: Use unique crmMessageId values for each message. The system checks for duplicates within a 60-second window.

Editing Messages

Wazzup supports editing sent messages. You can change either the text or the attachment, but not both at the same time.

PATCH https://api.wazzup24.com/v3/message/:messageId
PATCH https://api.wazzup24.com/v3/message/:messageId
├── crmUserId
├── text
└── contentUri

Include the API key in the request header:

"Authorization": "Bearer {apiKey|sidecarApiKey}"

How to edit a message:

  • Specify the new message text in the text field.
  • If you need to replace the attachment, use contentUri.
  • You cannot change both the text and the attachment simultaneously.
Parameter Type Description
messageId String Path parameter for message identification
crmUserId String CRM user ID, specified using CRUD users
text String Message text. Required if contentUri is not specified. text and contentUri cannot be used simultaneously
contentUri String URL of the file to be sent. Required if text is not specified

Example usage for text messages:

curl --location --request PATCH 'https://api.wazzup24.com/v3/message/6f1b3c67-3008-488b-9abc-12fcac6de134' \
--header 'Authorization: Bearer {apiKey|sidecarApiKey}' \
--header 'Content-Type: application/json' \
--data '{
"text": "Updated message text",
"crmUserId": "2e0df379-0e3c-470f-9b36-06b9e34c3bdb"
}'

Example usage for messages with attachments:

curl --location --request PATCH 'https://api.wazzup24.com/v3/message/6f1b3c67-3008-488b-9abc-12fcac6de134' \
--header 'Authorization: Bearer {apiKey|sidecarApiKey}' \
--header 'Content-Type: application/json' \
--data '{
"contentUri": "https://example.com/image.png",
"crmUserId": "2e0df379-0e3c-470f-9b36-06b9e34c3bdb"
}'

Deleting Messages

To delete a message, use the following method:

DELETE https://api.wazzup24.com/v3/message/:messageId

Include the API key in the request header:

"Authorization": "Bearer {apiKey|sidecarApiKey}"

Example of message deletion:

curl --location --request DELETE 'https://api.wazzup24.com/v3/message/6f1b3c67-3008-488b-9abc-12fcac6de134' \
--header 'Authorization: Bearer {apiKey|sidecarApiKey}'
Error code Type Description
BALANCE_IS_EMPTY String The WABA subscription balance has run out of funds.
MESSAGE_WRONG_
CONTENT_TYPE
String Invalid content type. Appears if the content type could not be detected or is not supported.
MESSAGE_ONLY_TEXT_
OR_CONTENT
String The message can contain text or content. You can't send text and content to WhatsApp and Instagram at the same time.
MESSAGE_NOTHING_
TO_SEND
String No message text was found.
MESSAGE_TEXT_TOO_LONG String The length of the text message exceeds 10 000 characters.
MESSAGES_TOO_LONG
_INSTAGRAM
String The Instagram message text exceeds 10,000 characters.
MESSAGES_TOO_LONG
_TELEGRAM
String The Telegram message text exceeds 4096 characters.
MESSAGES_TOO_LONG
_WABA
String The WABA message text is too long. The maximum is 1024 characters for the title and 4096 characters for the main text.
MESSAGES_CONTENT_
CAN_NOT_BE_BLANK
String A file with content cannot be empty. Occurs when sending a non-text message to which no content has been attached.
MESSAGES_CONTENT_
SIZE_EXCEEDED
String Content exceeds the allowable size of 10 MB.
MESSAGES_TEXT_
CAN_NOT_BE_BLANK
String The text message cannot be empty.
CHANNEL_NOT_FOUND String The channel through which the message is sent is not found in the integration.
CHANNEL_BLOCKED String The channel through which the message is sent is off.
CHANNEL_WAPI_REJECTED String The WABA channel is blocked.
MESSAGE_DOWNLOAD_
CONTENT_ERROR
String Failed to download content from the specified link.
MESSAGES_NOT_TEXT_FIRST String On the "Inbox" tariff, you cannot write first.
MESSAGES_IS_SPAM String Wazzup rated this message as spam.
VALIDATION_ERROR String Validation error of the parameter passed to the query.
CHANNEL_NO_MONEY String The channel is not paid and has the status of "Not Paid".
MESSAGE_CHANNEL_
UNAVAILABLE
String The channel from which the message is sent is not available. The channel has the status "Phone Unavailable" or "Wait a Minute".
MESSAGES_ABNORMAL_
SEND
String The chat type does not match the source of the contact. For example, this error can occur if you try to send a message from the WhatsApp channel to the Instagram channel.
MESSAGES_INVALID_
CONTACT_TYPE
String The chat type does not match the Instagram contact source. For example, this error can occur if you are trying to send a message from an Instagram channel to a WhatsApp channel.
MESSAGES_CAN_NOT_ADD String The message has not been sent. An unexpected server error occurred.
MESSAGES_CONTENT_
SIZE_EXCEEDED_WABA
String The content exceeds the allowed size. For Telegram, the maximum photo size is 5 MB, and for other content, it's 16 MB.
MESSAGES_CONTENT_
SIZE_EXCEEDED_TELEGRAM
String The content exceeds the allowed size. For Telegram, the maximum photo size is 5 MB, and for other content, it's 20 MB.
MESSAGES_TOO_LONG_VIBER String The Viber message text exceeds 6999 characters.
MESSAGES_TOO_LONG_
WABA_HEADER
String The WABA template title text exceeds 60 characters.
MESSAGES_TOO_LONG_
WABA_TEMPLATE
String The WABA template text exceeds 1024 characters.
REFERENCE_MESSAGE_
NOT_FOUND
String An error occurs when quoting if the message to which the quote is attached cannot be found. Check that the message identifier received from Wazzup is passed as the refId.
UNKNOWN_ERROR String Unknown error. Contact support.
UNKNOWN_ERROR_
WITH_TRACE_ID
String Unknown error. Please contact us for assistance with the error trace ID.
MESSAGES_EDITING_
TIME_EXPIRED
String The message editing time has expired. The message can only be edited within a set period after sending.
MESSAGES_CONTAIN
_BUTTONS
String The message contains buttons and cannot be edited.
CHANNEL_INVALID_
TRANSPORT_FOR_EDITING
String The channel does not support message editing.
CHANNEL_INVALID_
TRANSPORT_FOR_CONTENT
_EDITING
String The channel does not support editing message content (e.g., attachments).
CHAT_NO_ACCESS String No access to the specified chat. Check access settings.
MESSAGES_NOT_FOUND String The message was not found or does not contain any content.
CHANNEL_LIMIT_EXCEEDED String The limit of active dialogues for the channel has been exceeded.
MESSAGES_DELETION_
TIME_EXPIRED
String The deletion time for the message has expired. The message can only be deleted within a set period after sending.
CHANNEL_INVALID_
TRANSPORT_FOR_DELETION
String The channel does not support message deletion.
TEMPLATE_REJECTED String Meta has restricted the template. Try another one or wait for an incoming message.
BAD_CONTACT String Message not sent. Number may not be on WhatsApp or uses an old version. Try later.