Send Transactional WhatsApp Message with Button Reply
  • 07 Aug 2023
  • 4 Minutes to read

    Send Transactional WhatsApp Message with Button Reply


      Article Summary

      Overview

      This API enables you to send targeted transactional WhatsApp messages to your users. You can send media and text content in this message type.

      Your title goes here
      You can send this message type if the user has sent a message to your number in the last 24 hours.

      Endpoint and Headers

      POST https://whatsapp.useinsider.com/v1/send

      Headers

      HeaderSample ValueDescription
      X-INS-AUTH-KEY1a2b3c4d5e6fThis key is required to authorize your request. Refer to API Authentication Tokens to generate your token.
      Content-Typeapplication/jsonThis header specifies the media type of the resource.

      Body parameters

      ColumnDescriptionData TypeRequired
      messagesAll messages are contained in the messages key. You can send multiple messages with a single requestArrayYes
      phoneNumberPhone number for the person you want to send a message to.StringYes
      messageMessage objectObjectYes
      typeMust be a “interactive” for this message type.StringYes
      interactiveAn interactive object. The components of each interactive object generally follow a consistent pattern: header, body, footer, and action.ObjectYes
      type (in interactive)Must be a “button” for this message type.StringYes
      header


      ObjectNo
          type

      The header type you would like to use. Supported values are:

      • text: Used for List Messages, Reply Buttons, and Multi-Product Messages.
      • video: Used for Reply Buttons.
      • image: Used for Reply Buttons.
      • document: Used for Reply Buttons.
      StringYes
          textText for the header. Formatting allows emojis, but not markdown. Maximum length is 60 characters.StringYes if the type is text.
          imageContains the media object for this imageStringYes if the type is image.
              linkRequired when the type is audio, document, image, sticker, or video and you are not using an uploaded media ID. The file types are image/jpeg, image/png. Max 5 MB.StringYes if there is no id.
              id

      Required when the type is audio, document, image, sticker, or video and you are not using a link.

      URLYes is there is no link.
              captionDescribes the specified image, document, or  video media. Do not  use with audio or sticker media.StringNo
          audio
      ObjectYes if the type is audio.
              linkRequired when the type is audio, document, image, sticker, or video and you are not using an uploaded media ID. The file types are audio/mp4, audio/mpeg, audio/amr, audio/ogg. Max 16 MB.URLYes if there is no id.
              idRequired when the type is audio, document, image, sticker, or video and you are not using a link.URLYes is there is no link.
          document
      ObjectYes is the type is document.
              link

      Required when type is audio, document, image, sticker, or video and you are not using an uploaded media ID. The File Types are:

      • text/plain, 
      • application/pdf, 
      • application/vnd.ms-powerpoint, 
      • application/msword, 
      • application/vnd.ms-excel,
      • application/vnd.openxmlformats-officedocument.wordprocessingml.document,
      • application/vnd.openxmlformats-officedocument.presentationml.presentation,
      • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

      Max 100 MB.

      URLYes if there is no id.
              idRequired when the type is audio, document, image, sticker, or video and you are not using a link.
      URLYes if there is no link.
              captionDescribes the specified image, document, or video media. Do not use with audio or sticker media.
      StringNo
              filenameDescribes the filename for the specific document. Use only with document media.
      StringNo
          video
      ObjectYes if the type is video.
              linkRequired when type is audio, document, image, sticker, or video and you are not using an uploaded media ID. File Types are video/mp4, video/3gp. Max 16 MB.
      URLYes if there is no id.
              idRequired when type is audio, document, image, sticker, or video and you are not using a link.
      URLYes if there is no link.
              captionDescribes the specified image, document, or video media. Do not use with audio or sticker media.
      StringNo
      bodyThe body object contains the following field: textstring – Required if body is present. The content of the message. Emojis and markdown are supported. Maximum length: 1024 characters
      ObjectYes
          textThe content of the message.StringYes
      action
      ObjectYes
          buttonsYou can use Min:1, Max:3 buttons.ArrayYes
          typeMust be a “reply” for this message type.
      StringYes
          reply
      ObjectYes
              idId of the button.
      StringYes
              titleTitle of the button
      StringYes

      Sample Example

      Sample Request

      curl --location 'https://whatsapp.useinsider.com/v1/send' \
      --header 'Content-Type: application/json' \
      --header 'x-ins-auth-key: INS.1a2b3c4d5e6f' \
      --data '{
          "messages": [
              {
                  "phoneNumber": "+1**********",
                  "message": {
                      "type": "interactive",
                      "interactive": {
                          "type": "button",
                          "header": {
                              "type": "text",
                              "text": "HEADER_TEXT"
                          },
                          "body": {
                              "text": "BUTTON_TEXT"
                          },
                          "action": {
                              "buttons": [
                                  {
                                      "type": "reply",
                                      "reply": {
                                          "id": "UNIQUE_BUTTON_ID_1",
                                          "title": "BUTTON_TITLE_1"
                                      }
                                  },
                                  {
                                      "type": "reply",
                                      "reply": {
                                          "id": "UNIQUE_BUTTON_ID_2",
                                          "title": "BUTTON_TITLE_2"
                                      }
                                  }
                              ]
                          }
                      }
                  }
              }
          ]
      }'

      Sample Responses

      One key information will be returned for each message to be sent. This key will be added to all events related to the message.

      {
          "keys": [
              "whatsapp-*************************"
          ]
      }

      401 Unauthorized

      If you use the wrong key, you will see the following error.

      {
          "message": "unauthorized"
      }

      Limitations

      • All functions must be executed with a simple HTTPS POST request.
      • Only new WhatsApp messages can be sent via this API. No data can be retrieved.
      • The API Key should be provided as the authorization key on the request header. If the key is incorrect, the operation will not be executed and an authorization error will return in the response.
      • Transactional API cannot be used for sending bulk/promotional WhatsApp messages. It is designed only to set transactional WhatsApp messages.
      • The rate limit is 10 requests per second.

      Was this article helpful?

      ESC

      Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses