Use a Sticker ID to Send a Sticker

In this code snippet you learn how to send a sticker on WhatsApp using its sticker ID. You can read more about Using WhatsApp Stickers for additional context on using this code snippet.

Example

Find the description for all variables used in each code snippet below:

KeyDescription
JWT

Used to authenticate your request. See Authentication for more information, including how to generate a JWT.

STICKER_ID

The ID of the sticker in relation to a specific WhatsApp deployment.

TO_NUMBER

The number you are sending the to in E.164 format. For example 447700900000.

WHATSAPP_NUMBER

The WhatsApp number that has been allocated to you by Vonage. For sandbox testing the number is 14157386102.

NOTE: Don't use a leading + or 00 when entering a phone number, start with the country code, for example, 447700900000.

Prerequisites

If you do not have an application you can create one. Make sure you also configure your webhooks.

Write the code

Add the following to send-sticker-id.sh:

curl -X POST $MESSAGES_API_URL \
     -H 'Authorization: Bearer '$JWT \
     -H 'Content-Type: application/json' \
     -H 'Accept: application/json' \
     -d $'{
  "message_type": "sticker",
  "sticker": {
    "id": "'$STICKER_ID'"
  },
  "to": "'$TO_NUMBER'",
  "from": "'$WHATSAPP_NUMBER'",
  "channel": "whatsapp"
}'

View full source

Run your code

Save this file to your machine and run it:

bash send-sticker-id.sh

Try it out

When you run the code a WhatsApp sticker is sent to the destination number.

Further information