Send automated messages on WhatsApp using cURL
Take your marketing strategy to the next level with automated WhatsApp messages. By integrating the Wassenger API with cURL, you can effortlessly send your customers reminders, personalized messages, and promotional content. This powerful tool helps businesses increase sales and improve customer engagement.
In this article, we’ll guide you through setting up and using the Wassenger API with cURL to automate your WhatsApp messaging, ensuring timely and targeted interactions with your audience. This guide will boost your marketing efforts, enhance customer satisfaction, and drive sales growth.
🫣 Don’t want to use programming? No problem! Explore our new no-code WhatsApp Campaigns feature. Import your contacts, define a message, set a delivery date and relax! 🥳 🥳
🤩 🤖 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 chat:
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 Python, JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL and more.
🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!
To send automated WhatsApp messages using cURL, follow these steps:
- Install cURL: Ensure you have the cURL package installed. Installation instructions.
- Prepare the cURL Command: Use the cURL command with the appropriate HTTP method, URL, headers, and data.
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: ENTER API KEY HERE' \
--data '{"phone":"+1234567890","message":"Hello world, this is a sample message"}'
- Request Method: Use
--request POST
to specify the HTTP POST method. - URL: Set the API endpoint URL with
--url https://api.wassenger.com/v1/messages
- Headers: Add the
Content-Type
andToken
headers using--header
. - Data: Include the message payload in JSON format using
--data
.
With the Wassenger API, you have the versatility you always wanted. Check out the different types of messages you can send:
1. Send text messages with high priority to a group
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: <api token goes here>' \
--data '{"group":"123456789000000000@g.us","priority":"high","message":"Hello world! This is a simple test message."}'
2. Send media messages to users. Note the file must be updated first
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: <api token goes here>' \
--data '{"phone":"+1234567890","message":"Hello world! This is a test media message.","media":{"file":"<24 characters length file ID>"}}'
3. Send text messages that should be delivered now
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: <api token goes here>' \
--data '{"phone":"+1234567890","message":"Hello world! This is a simple test message.","enqueue":"never"}'
4. Send scheduled messages with a custom delay
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: <api token goes here>' \
--data '{"phone":"+1234567890","schedule":{"delayTo":"1h"},"message":"Hello world! This is a simple test message."}'
5. Send a scheduled message at a specific date with a valid ISO 8601 date
curl --request POST \
--url https://api.wassenger.com/v1/messages \
--header 'Content-Type: application/json' \
--header 'Token: <api token goes here>' \
--data '{"phone":"+1234567890","deliverAt":"2019-01-01T11:00:00.410Z","message":"Hello world! This is a simple test message."}'
🤩 🤖 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.
Once you are done testing, get the auto-generated code example in your preferred programming language and you will be ready to go.
🤩 🤖 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!
FAQ
Can I use Wassenger to send marketing messages?
As you may know, WhatsApp has strict policies about sending unsolicited marketing messages, illicit content or spam.
Sending marketing or any unsolicited messages to users is not allowed and you would put your WhatsApp number at a high risk of getting banned.
WhatsApp communication may be better for some business cases, so we recommend designing a legitimate and user-approved communication strategy to avoid further problems.
Please read our guidelines with communication best practices and how to prevent getting banned.
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.
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 does not check whether the phone number is effectively 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