Créer une campagne
curl --request POST \
--url https://api.wachap.com/v1/campaigns/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Confirmation événement",
"type": "bulk_contacts",
"listId": "list_123",
"whatsappProfiles": [
"account_123"
],
"variations": [
{
"id": "var_1",
"type": "text",
"content": "Bonjour {{name}}, confirmez-vous votre présence ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "details",
"text": "Voir les détails",
"type": "url",
"url": "https://example.com/evenement"
}
],
"footerText": "WaChap"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Confirmation événement',
type: 'bulk_contacts',
listId: 'list_123',
whatsappProfiles: ['account_123'],
variations: [
{
id: 'var_1',
type: 'text',
content: 'Bonjour {{name}}, confirmez-vous votre présence ?',
buttons: [
{id: 'yes', text: 'Oui', type: 'reply'},
{
id: 'details',
text: 'Voir les détails',
type: 'url',
url: 'https://example.com/evenement'
}
],
footerText: 'WaChap'
}
]
})
};
fetch('https://api.wachap.com/v1/campaigns/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Confirmation événement',
type: 'bulk_contacts',
listId: 'list_123',
whatsappProfiles: ['account_123'],
variations: [
{
id: 'var_1',
type: 'text',
content: 'Bonjour {{name}}, confirmez-vous votre présence ?',
buttons: [
{id: 'yes', text: 'Oui', type: 'reply'},
{
id: 'details',
text: 'Voir les détails',
type: 'url',
url: 'https://example.com/evenement'
}
],
footerText: 'WaChap'
}
]
})
};
fetch('https://api.wachap.com/v1/campaigns/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/campaigns/create"
payload = {
"name": "Confirmation événement",
"type": "bulk_contacts",
"listId": "list_123",
"whatsappProfiles": ["account_123"],
"variations": [
{
"id": "var_1",
"type": "text",
"content": "Bonjour {{name}}, confirmez-vous votre présence ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "details",
"text": "Voir les détails",
"type": "url",
"url": "https://example.com/evenement"
}
],
"footerText": "WaChap"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/campaigns/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Confirmation événement',
'type' => 'bulk_contacts',
'listId' => 'list_123',
'whatsappProfiles' => [
'account_123'
],
'variations' => [
[
'id' => 'var_1',
'type' => 'text',
'content' => 'Bonjour {{name}}, confirmez-vous votre présence ?',
'buttons' => [
[
'id' => 'yes',
'text' => 'Oui',
'type' => 'reply'
],
[
'id' => 'details',
'text' => 'Voir les détails',
'type' => 'url',
'url' => 'https://example.com/evenement'
]
],
'footerText' => 'WaChap'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/campaigns/create"
payload := strings.NewReader("{\n \"name\": \"Confirmation événement\",\n \"type\": \"bulk_contacts\",\n \"listId\": \"list_123\",\n \"whatsappProfiles\": [\n \"account_123\"\n ],\n \"variations\": [\n {\n \"id\": \"var_1\",\n \"type\": \"text\",\n \"content\": \"Bonjour {{name}}, confirmez-vous votre présence ?\",\n \"buttons\": [\n {\n \"id\": \"yes\",\n \"text\": \"Oui\",\n \"type\": \"reply\"\n },\n {\n \"id\": \"details\",\n \"text\": \"Voir les détails\",\n \"type\": \"url\",\n \"url\": \"https://example.com/evenement\"\n }\n ],\n \"footerText\": \"WaChap\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}Campagnes
Créer une campagne
Créez une nouvelle campagne d’envoi de messages WhatsApp
POST
/
campaigns
/
create
Créer une campagne
curl --request POST \
--url https://api.wachap.com/v1/campaigns/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Confirmation événement",
"type": "bulk_contacts",
"listId": "list_123",
"whatsappProfiles": [
"account_123"
],
"variations": [
{
"id": "var_1",
"type": "text",
"content": "Bonjour {{name}}, confirmez-vous votre présence ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "details",
"text": "Voir les détails",
"type": "url",
"url": "https://example.com/evenement"
}
],
"footerText": "WaChap"
}
]
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Confirmation événement',
type: 'bulk_contacts',
listId: 'list_123',
whatsappProfiles: ['account_123'],
variations: [
{
id: 'var_1',
type: 'text',
content: 'Bonjour {{name}}, confirmez-vous votre présence ?',
buttons: [
{id: 'yes', text: 'Oui', type: 'reply'},
{
id: 'details',
text: 'Voir les détails',
type: 'url',
url: 'https://example.com/evenement'
}
],
footerText: 'WaChap'
}
]
})
};
fetch('https://api.wachap.com/v1/campaigns/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Confirmation événement',
type: 'bulk_contacts',
listId: 'list_123',
whatsappProfiles: ['account_123'],
variations: [
{
id: 'var_1',
type: 'text',
content: 'Bonjour {{name}}, confirmez-vous votre présence ?',
buttons: [
{id: 'yes', text: 'Oui', type: 'reply'},
{
id: 'details',
text: 'Voir les détails',
type: 'url',
url: 'https://example.com/evenement'
}
],
footerText: 'WaChap'
}
]
})
};
fetch('https://api.wachap.com/v1/campaigns/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.wachap.com/v1/campaigns/create"
payload = {
"name": "Confirmation événement",
"type": "bulk_contacts",
"listId": "list_123",
"whatsappProfiles": ["account_123"],
"variations": [
{
"id": "var_1",
"type": "text",
"content": "Bonjour {{name}}, confirmez-vous votre présence ?",
"buttons": [
{
"id": "yes",
"text": "Oui",
"type": "reply"
},
{
"id": "details",
"text": "Voir les détails",
"type": "url",
"url": "https://example.com/evenement"
}
],
"footerText": "WaChap"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wachap.com/v1/campaigns/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Confirmation événement',
'type' => 'bulk_contacts',
'listId' => 'list_123',
'whatsappProfiles' => [
'account_123'
],
'variations' => [
[
'id' => 'var_1',
'type' => 'text',
'content' => 'Bonjour {{name}}, confirmez-vous votre présence ?',
'buttons' => [
[
'id' => 'yes',
'text' => 'Oui',
'type' => 'reply'
],
[
'id' => 'details',
'text' => 'Voir les détails',
'type' => 'url',
'url' => 'https://example.com/evenement'
]
],
'footerText' => 'WaChap'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wachap.com/v1/campaigns/create"
payload := strings.NewReader("{\n \"name\": \"Confirmation événement\",\n \"type\": \"bulk_contacts\",\n \"listId\": \"list_123\",\n \"whatsappProfiles\": [\n \"account_123\"\n ],\n \"variations\": [\n {\n \"id\": \"var_1\",\n \"type\": \"text\",\n \"content\": \"Bonjour {{name}}, confirmez-vous votre présence ?\",\n \"buttons\": [\n {\n \"id\": \"yes\",\n \"text\": \"Oui\",\n \"type\": \"reply\"\n },\n {\n \"id\": \"details\",\n \"text\": \"Voir les détails\",\n \"type\": \"url\",\n \"url\": \"https://example.com/evenement\"\n }\n ],\n \"footerText\": \"WaChap\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}Créer une campagne
Créez une nouvelle campagne d’envoi de messages WhatsApp en utilisant une liste de contacts existante.Endpoint
/v1/campaigns/create
Headers
Bearer token avec votre Secret Key (format:
Bearer sk_...)Body Parameters
Nom de la campagne
Type de campagne:
bulk_contacts, bulk_groups, individualID de la liste de contacts à utiliser (Requis pour
bulk_contacts)Tableau des IDs de profils WhatsApp à utiliser
Variations de messages (spintax, A/B testing). Voir structure ci-dessous.
Délai entre messages:
{min: 5, max: 10} (en secondes, défaut: 5-10s)Fenêtres d’envoi:
[{start: "09:00", end: "18:00"}] (défaut: 24h/24)Timezone:
Africa/Abidjan, Europe/Paris, etc. (défaut: UTC)Date programmée (ISO 8601)
Structure de variations
{
"id": "var_1",
"type": "text",
"content": "Bonjour {{name}}, souhaitez-vous continuer ?",
"buttons": [
{"id": "yes", "text": "Oui", "type": "reply"},
{"id": "site", "text": "Voir le site", "type": "url", "url": "https://wachap.com/{{campaign}}"}
],
"footerText": "WaChap"
}
Boutons dans les variations
Chaque variationtext, image, video ou document peut contenir :
| Champ | Type | Description |
|---|---|---|
buttons | array | 1 à 3 boutons reply, url ou call |
footerText | string | Pied facultatif, limité à 60 caractères |
buttons[].text, buttons[].url, buttons[].phoneNumber et footerText, comme dans content. Consultez Boutons interactifs pour les contraintes complètes.
Types de messages supportés
| Type | Description | Champs requis |
|---|---|---|
text | Message texte simple | content |
image | Image avec caption | content (caption), mediaUrl |
video | Vidéo avec caption | content (caption), mediaUrl |
document | Document PDF, etc. | content (nom fichier), mediaUrl |
audio | Message vocal/audio | mediaUrl |
Variables de personnalisation
{{name}}- Nom du contact{{phone}}- Numéro du contact{{email}},{{city}}, etc. - Toute colonne de votre liste de contacts
Spintax (variation de texte)
Utilisez{option1|option2|option3} pour générer des variations aléatoires :
{Bonjour|Salut|Hello} {{name}} → génère différentes salutations.
Cela permet d’éviter la détection de spam et rend chaque message unique.
Exemples de requêtes
curl -X POST https://api.wachap.com/v1/campaigns/create \
-H "Content-Type: application/json" \
-H "Authorization: Bearer token" \
-d '{
"name": "Promo Black Friday 2024",
"type": "bulk_contacts",
"listId": "65f1234567890abcdef12345",
"whatsappProfiles": ["a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878"],
"variations": [
{
"id": "var_1",
"type": "text",
"content": "{Bonjour|Salut|Hello} {{name}}, découvrez notre offre !",
"buttons": [
{"id": "offer", "text": "Voir l’offre", "type": "url", "url": "https://example.com/offre/{{phone}}"},
{"id": "call", "text": "Nous appeler", "type": "call", "phoneNumber": "+2290100000000"}
],
"footerText": "Offre limitée"
}
],
"messageDelay": {"min": 5, "max": 10},
"timezone": "Africa/Abidjan"
}'
const response = await fetch('https://api.wachap.com/v1/campaigns/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer token'
},
body: JSON.stringify({
name: 'Test A/B Promo',
type: 'bulk_contacts',
listId: '65f1234567890abcdef12345',
whatsappProfiles: ['a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878'],
variations: [
{
id: 'version_a',
type: 'text',
content: 'Bonjour {{name}}, -20% sur tout le site !'
},
{
id: 'version_b',
type: 'text',
content: 'Hello {{name}}, offre flash -20% aujourd\'hui !'
}
]
})
});
const data = await response.json();
console.log(data);
import requests
from datetime import datetime, timedelta
# Programmer pour demain à 10h
scheduled_time = (datetime.now() + timedelta(days=1)).replace(hour=10, minute=0, second=0)
url = 'https://api.wachap.com/v1/campaigns/create'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer token'
}
payload = {
'name': 'Campagne Programmée',
'listId': '65f1234567890abcdef12345',
'whatsappProfiles': ['a1233b-a1233b-a1233b-a1233b-a1233bcdjdg9878'],
'variations': [{ 'content': 'Bonjour {{name}} !' }],
'scheduledAt': scheduled_time.isoformat()
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())
Exemple de réponse
{
"success": true,
"campaignId": "675c1234567890abcdef1234",
"campaign": {
"$id": "675c1234567890abcdef1234",
"userId": "user_xxx",
"name": "Promo Black Friday 2024",
"status": "ready",
"totalContacts": 1523
}
}
Notes importantes
- listId requis : Pour
type: bulk_contacts, lelistIdest obligatoire. - Statut automatique : Si
listIdest fourni, le statut seraready(prêt à lancer). - Multiples profils : Rotation automatique entre les profils WhatsApp fournis.
- Boutons facultatifs : Omettez
buttonsou utilisez un tableau vide pour envoyer uniquement le message.
Codes d’erreur
| Code | Description |
|---|---|
400 | MISSING_NAME, MISSING_TYPE, MISSING_LIST_ID, INVALID_TYPE |
401 | INVALID_SECRET_KEY - Clé secrète invalide |
404 | Liste de contacts non trouvée |
500 | Erreur lors de la création |
Autorisations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Corps
application/json
Réponse
OK
⌘I
