curl --request POST \
--url https://api.wachap.com/v1/whatsapp/messages/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"to": "+33612345678",
"type": "text",
"content": "Souhaitez-vous confirmer ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "website",
"text": "Voir le site",
"type": "url",
"url": "https://wachap.com"
}
],
"footerText": "WaChap"
}
}
'Messages WhatsApp
Envoyer un message texte
Envoyez un message texte simple à un contact WhatsApp
POST
/
whatsapp
/
messages
/
send
curl --request POST \
--url https://api.wachap.com/v1/whatsapp/messages/send \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data": {
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"to": "+33612345678",
"type": "text",
"content": "Souhaitez-vous confirmer ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "website",
"text": "Voir le site",
"type": "url",
"url": "https://wachap.com"
}
],
"footerText": "WaChap"
}
}
'Endpoint
Headers
Body Parameters
Jusqu’à trois boutons interactifs. Consultez Boutons interactifs.
Pied affiché sous les boutons, limité à 60 caractères. Il est ignoré si
buttons est absent ou vide.Exemples de requêtes
curl -X POST https://api.wachap.com/v1/whatsapp/messages/send \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"data": {
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"to": "+33612345678",
"type": "text",
"content": "Souhaitez-vous confirmer ?",
"buttons": [
{"id": "yes", "text": "Oui", "type": "reply"},
{"id": "site", "text": "Voir le site", "type": "url", "url": "https://wachap.com"}
],
"footerText": "WaChap"
}
}'
const response = await fetch('https://api.wachap.com/v1/whatsapp/messages/send', {
method: 'POST',
headers: {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
data: {
accountId: 'a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878',
to: '+33612345678',
type: 'text',
content: 'Souhaitez-vous confirmer ?',
buttons: [
{ id: 'yes', text: 'Oui', type: 'reply' },
{ id: 'site', text: 'Voir le site', type: 'url', url: 'https://wachap.com' }
],
footerText: 'WaChap'
}
})
});
const data = await response.json();
console.log(data);
import requests
url = "https://api.wachap.com/v1/whatsapp/messages/send"
headers = {
"Authorization": "Bearer token",
"Content-Type": "application/json"
}
payload = {
"data": {
"accountId": "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"to": "+33612345678",
"type": "text",
"content": "Souhaitez-vous confirmer ?",
"buttons": [
{"id": "yes", "text": "Oui", "type": "reply"},
{"id": "call", "text": "Nous appeler", "type": "call", "phoneNumber": "+2290100000000"}
],
"footerText": "WaChap"
}
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
<?php
$curl = curl_init();
$payload = [
"data" => [
"accountId" => "a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878",
"to" => "+33612345678",
"type" => "text",
"content" => "Souhaitez-vous confirmer ?",
"buttons" => [
["id" => "yes", "text" => "Oui", "type" => "reply"],
["id" => "site", "text" => "Voir le site", "type" => "url", "url" => "https://wachap.com"]
],
"footerText" => "WaChap"
]
];
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/whatsapp/messages/send",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer token",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
Exemple de réponse
{
"success": true,
"message": "Message envoyé avec succès",
"messageId": "3EB0123456789ABCDEF",
"timestamp": 1702000000
}
Codes d’erreur
| Code | Description |
|---|---|
400 | MISSING_ACCOUNT_ID - accountId manquant |
400 | MISSING_TO - Numéro destinataire manquant |
400 | MISSING_TYPE - Type de message manquant |
400 | MISSING_CONTENT - Contenu du message manquant |
400 | SEND_ERROR - Boutons invalides (limite, texte, URL ou numéro) |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | ACCOUNT_NOT_FOUND - Compte WhatsApp non trouvé |
429 | MESSAGE_LIMIT_REACHED - Limite de messages atteinte |
