Upload and send a sticker via the API

Stickers can be uploaded as media and then sent in WhatsApp messages to users via the API.

Let's look at how you would do this:

  1. Step 1: Upload the media to WhatsApp (as described in the documentation here).
  2. Step 2: The response to the media upload API request will include an id field that can then be used to send the sticker media in messages to users.
Important: Stickers must have a transparent background, be exactly 512 x 512 pixels, and be less than 100 KB in size. Additionally, sticker media must be in webp format. Other file types can be transformed into webp online by using a file conversion site such as cloudconvert.

Example Request:

curl -i -X POST https://whatsapp.turn.io/v1/media -H 'Authorization: Bearer your-token-here' -H 'Content-Type: image/webp'  --data-binary '@/path_to_sticker_file.webp'

If successful, this will generate a response that contains a media id, such as:

{ media":[ {"id":"your-unique-media-id-f6dacb02..."}]…}

Using the id from this response, you can then make a request to send the sticker media to a user’s chat (as described in the documentation here). For example:

curl -X POST https://whatsapp.turn.io/v1/messages  -H 'Authorization: Bearer your-token-here'  -H 'Content-Type: application/json'     -d '
{
"recipient_type": "individual",
"to": "14171234567",
"type": "sticker",
"sticker": {
"id": "your-unique-media-id-f6dacb02..."
}
}
'

Success! Now you can share Chuck Norris with the rest of the world 😉

Was this article helpful?

How do I create message templates via the API?

Replacing the Contact Export API

Contact