Sending messages

To send messages it is necessary to call:

 POST https://api.wazzup24.com/v3/message

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

Request Parameters

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”,
  • WhatsApp group chat: “whatsgroup”,
  • Instagram: “instagram”,
  • Telegram: “telegram”.
chatId String Chat ID (contact’s account in messenger):

  • for “whatsapp” — 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 and Telegram up to 4096 characters.
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.

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 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 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 Buttons attached to a message. Can be used to work with WABA templates and with WABA interactive messages.

Interactive message is a message with buttons, which can be sent in an active 24-hour correspondence with the client from the WABA channel.

WABA template is a template that is moderated by Meta. They are used to start 24-hour correspondence.

When working with WABA templates buttonsObject comes in handy only if you want to bind a payload to the buttons. You don’t need to write the text of the buttons that will be sent with the WABA template.

buttonsObject.buttons   Object[ ] An array of objects with buttons. No more than 10.

If the array is larger, take the first 10 buttons.

buttonsObject.buttons.text   String Needed to work with interactive messages. Button text, maximum 25 characters.
buttonsObject.buttons.type   String Button type. Needed to work with interactive messages.

Now we only support text format so specify “text” type.

buttonsObject.id   String Payload from interactive message buttons.
buttonsObject.payload   String Payload from template message buttons.
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.

Request examples

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"
  },
});

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.

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"}
     ]
    }
  },
});

Response

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

Error code Description
MESSAGE_WRONG_CONTENT_TYPE Invalid content type. Appears if the content type could not be detected or is not supported.
MESSAGE_ONLY_TEXT_OR_CONTENT 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 No message text was found.
MESSAGE_TEXT_TOO_LONG The length of the text message exceeds 10 000 characters.
MESSAGE_CONTENT_CAN_NOT_BE_BLANK A file with content cannot be empty.

Occurs when sending a non-text message to which no content has been attached.

MESSAGE_CONTENT_SIZE_EXCEEDED Content exceeds the allowable size of 10 MB.
MESSAGE_TEXT_CAN_NOT_BE_BLANK The text message cannot be empty.
CHANNEL_NOT_FOUND The channel through which the message is sent is not found in the integration.
CHANNEL_BLOCKED The channel through which the message is sent is off.
MESSAGE_DOWNLOAD_CONTENT_ERROR Failed to download content from the specified link.
MESSAGES_NOT_TEXT_FIRST On the “Start” tariff, you cannot write first.
MESSAGES_IS_SPAM Wazzup rated this message as spam.
CHAT_WRONG_CHAT_TYPE Invalid chat type.

Occurs if you send an outgoing message to a messenger not included in the [INSTAGRAM, WHATSAPP, TELEGRAM] list.

CHAT_MISSING_CHAT_TYPE chatType is not transmitted.

Select the chat type from the [INSTAGRAM, WHATSAPP, TELEGRAM] list.

CHAT_INCORRECT_CHAT_ID_WHATSAPP Incorrect WhatsApp number.

Phone number must be in international format: contain from 9 to 16 digits without +

CHAT_MISSING_CHAT_ID chatId is not transmitted.
VALIDATION_ERROR Validation error of the parameter passed to the query.
ACCOUNT_NOT_FOUND Account not found in integration.
CONTACT_NOT_FOUND The contact is not found among the account’s contacts — there is no chat with this phone number.
CHANNEL_NO_MONEY The channel is not paid and has the status of “Not Paid”.
MESSAGE_CHANNEL_UNAVAILABLE The channel from which the message is sent is not available.

The channel has the status “Phone Unavailable” or “Wait a Minute”.

CONTACT_DETAIL_NOT_FOUND No contact information.
MESSAGES_ABNORMAL_SEND 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 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 The message has not been sent. An unexpected server error occurred.
REFERENCE_MESSAGE_NOT_FOUND 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 Unknown error.

Contact support.