Use a Sticker ID to Send a Sticker
Note: Following the announcement by Meta that the WhatsApp On-Prem API will be sunset, the Vonage On-Prem API (Vonage Hosting) is now deprecated. All WhatsApp numbers will be migrated to Cloud API (WhatsApp Hosting). Since sending stickers with an ID is a feature of the On-Prem API, this feature will no longer be available once customers have been migrated to Cloud API (WhatsApp Hosting). Sending stickers with a URL will continue to be supported.
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:
| Key | Description |
|---|---|
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 |
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.
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Create a file named send-sticker-id.js and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Add the following to build.gradle:
Create a class named SendWhatsappStickerId and add the following code to the main method:
Write the code
Add the following to the main method of the SendWhatsappStickerId class:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.messages.whatsapp with the package containing SendWhatsappStickerId:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Add the following to build.gradle:
Create a class named SendWhatsappStickerId and add the following code to the main method:
Write the code
Add the following to the main method of the SendWhatsappStickerId class:
Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
Run the following gradle command to execute your application, replacing com.vonage.quickstart.messages.whatsapp with the package containing SendWhatsappStickerId:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Create a file named send-sticker-id.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Run your code
Save this file to your machine and run it:
Prerequisites
If you do not have an application you can create one. Make sure you also configure your webhooks.
Create a file named send-sticker-id.rb and add the following code:
Run your code
Save this file to your machine and run it:
Try it out
When you run the code a WhatsApp sticker is sent to the destination number.