Today, we’ll show you the ultimate guide to sending different types of WhatsApp messages using Java
Effective communication is vital for project coordination, community engagement, and responsive customer support. Wassenger enhances this process by providing seamless management and interaction tools within WhatsApp messages. With its intuitive API and automation features, sending messages, videos, images, documents, and voice memos becomes simple and efficient.
In this article you will find:
- Send Image Message 🖼️
- Send Video Messages 📹
- Send Document Messages 📄
- Send Audio Voice Record 🎙️
- Send a Media Message with an Uploaded File 📤
- Send a GIF Message 🎞️
- Send a Poll Message 📊
- Send a Scheduled Date and Time Message 📅
- Send Dynamic Native Button Messages 🔘
- Send a List of Items to Select From 📝
- Send a Message with Text Formatting ✍️
- Send a Location Message with Coordinates 📍
- Send a Location Message with the Address 🗺️
- Send a Message with Variables 🔄
- Send Messages with Links 🔗
- Send Contact Card Messages 📇
- Reply to a Message 💬
- Forward a Message 🔁
- Send a Catalogue Message 📒
- Send a Message in Real-Time with No Enqueueing ⏱️
- Send a Message with Maximum Retries 🔄
- Send a Message with the Expiration Time ⏳
- Send a Message Within a Time and Day Range 🕰️
- Send a Message Reaction 😊
- Remove a Message Reaction 🚫
- Send a Message on Behalf of an Agent and Assign a Chat 👤
- Send a Message and Resolve the Chat ✅
- Send a Message and Add a Chat Label 🏷️
🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes!
Requirements
- To have a WhatsApp number already linked to the platform and online.
- Message recipient phone number with international prefix in E164 format. Example:
+12345678900. Validate the phone number format here.
API endpoint
We will use the following API endpoint to send messages to a group:
Prepare the request
Target API URL using the POST method
https://api.wassenger.com/v1/messages
Required HTTPS headers > Obtain your API key here
Content-Type: application/json
Token: $API_TOKEN
Use body in JSON format
{
"phone": "+1234567890",
"message": "Hello world, this is a sample message"
}
🖥️ Looking for a code example? Go to the API live tester and get ready-to-use code examples in 15+ programming languages, including JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL and more.
Send text messages with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
More examples for group messages with Java
For full samples, visit our API Live Tester
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send document messages with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send audio voice record with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a media message with an uploaded file using Java
*{{UPLOADED FILE ID}}*: Replace this expression with the specific value
- You can upload the file here
- The file ID will look something like this: 57443b8773c036f2bae0cd96
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a scheduled date and time message with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send dynamic native button messages with Java
WhatsApp no longer accepts native button messages. Buttons messages will be automatically converted into raw text equivalent messages. Learn more here
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a list of items to select from with Java
WhatsApp no longer accepts list messages. List messages will be automatically converted into raw text equivalent messages. Learn more here
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message with text formatting using Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponsestrikethrough format and ```monospace format```\"}")
.asString();
Send a message with location coordinates using Java
Learn more about how to send location messages with coordinates in this tutorial
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send location message with address using Java
Learn more about how to send location messages with addresses in this tutorial
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message with variables using Java
Learn more about how to send messages with template variables in this tutorial.
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message with a URL using Java
Learn more about how to send messages with URL links in this tutorial
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send contact card messages with Java
Learn more about how to send contact card messages in this tutorial
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
{{MESSAGE ID}} : Replace with the actual WhatsApp message ID to forward (18, 20, 22 or 32 hexadecimal value)
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
{{MESSAGE ID}} : Replace with the actual WhatsApp message ID to reply to (18, 20, 22 or 32 hexadecimal value)
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a catalogue message with Java
{{PRODUCT CATALOG ID TO SEND}} : Replace this expression with the specific value
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message in real-time with no enqueueing using Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message with maximum retries using Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message with the expiration time using Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Send a message within a time and day range using Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message reaction using Java
{{WHATSAPP MESSAGE ID}} : Replace this expression with the specific value
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Remove message reaction:
{{WHATSAPP MESSAGE ID}} : Replace this expression with the specific value
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message on behalf of an agent and assign a chat using Java
{{USER ID}} : Replace with the actual user ID (24 hexadecimal value)
{{ASSIGNED USER ID}} : Replace with the actual user ID to assign the chat (24 hexadecimal value)
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message and resolve the chat with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
Send a message and add a chat label with Java
// This code requires you to have installed Unirest package. // Documentation: https://kong.github.io/unirest-java/#requests // Installation: http://kong.github.io/unirest-java/
HttpResponse
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
Live API testing
You can live-test and play with the API directly from your browser in minutes.
Once you are done testing, get the auto-generated code example in your preferred programming language and you will be ready to go.
FAQ
How to send messages to multiple phone numbers
You have to send numerous API requests, one per target phone number.
For instance, to send a message to 10 phone numbers, you should send 10 independent HTTPS requests to the API.
There is no option to send multiple messages in a single API request.
How to validate if a phone number can receive WhatsApp messages
You can validate if a given phone number is linked to a WhatsApp account and can receive messages.
The API provides an endpoint that can validate whether a given phone number exists in WhatsApp or not.
The only requirement is to have at least one WhatsApp number connected to the platform in your current account.
For more details, please check out the API endpoint documentation here.
Before you check if a phone number exists on WhatsApp, you can also validate and normalize the format of a list of phone numbers by using the numbers validator API endpoint. This endpoint only validates the correct E164 format, but it does not check whether the phone number effectively exists on WhatsApp.
Note: The number of WhatsApp check validations is limited per month based on your subscription plan. Please check out the pricing table for more details about the limits.
Looking for more answers? Check out the extended FAQs.
Further useful resources
API Documentation
For more details about the endpoint API, please check the documentation where you will find all the details about the accepted request params, possible success or error responses and ready-to-use code examples in multiple programming languages:
https://app.wassenger.com/docs/#tag/Messages/operation/createMessage







