Accueil / Développeurs
API de messagerie SMS et WhatsApp
Une seule API pour envoyer des SMS et des messages WhatsApp, avec bascule automatique, codes OTP et webhooks signés. Testez tout sans rien envoyer avec une clé de test.
Démarrage rapide
L'API de messagerie Warilo envoie des SMS et des messages WhatsApp avec un seul appel. Toutes les requêtes passent par https://api.warilo.com/v1/, en JSON, avec votre clé dans l'en-tête Authorization.
Trois étapes pour un premier envoi :
- Demandez votre compte : vous recevez une clé de test
wk_test_…et une clé livewk_live_…. - Envoyez un message avec la clé de test : rien ne part réellement, et le message passe par tous les statuts comme en production.
- Remplacez la clé de test par la clé live sur votre serveur.
curl -X POST https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+237673713115", "text": "Bonjour depuis Warilo"}'const res = await fetch("https://api.warilo.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"to": "+237673713115",
"text": "Bonjour depuis Warilo"
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/messages",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"to": "+237673713115",
"text": "Bonjour depuis Warilo"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"to": "+237673713115", "text": "Bonjour depuis Warilo"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"to\": \"+237673713115\", \"text\": \"Bonjour depuis Warilo\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/messages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"to\": \"+237673713115\", \"text\": \"Bonjour depuis Warilo\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"to": "+237673713115", "text": "Bonjour depuis Warilo"}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"to\": \"+237673713115\", \"text\": \"Bonjour depuis Warilo\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse : le message est accepté et mis en file (201, statut queued). Suivez ensuite son statut par webhook ou avec GET /v1/messages/{id}.
Authentification
Chaque requête porte l'en-tête Authorization: Bearer <clé>.
- Clé de test (
wk_test_…) : aucun envoi réel, aucun crédit consommé. Utilisable depuis un navigateur, par exemple dans la console ci-dessous. - Clé live (
wk_live_…) : envois réels, débités sur votre solde. Côté serveur uniquement : une requête qui porte une clé live et un en-têteOriginde navigateur est refusée (403 live_key_in_browser).
Conservez vos clés dans une variable d'environnement ou un coffre-fort de secrets, jamais dans le code source. Une clé exposée se révoque immédiatement sur simple demande.
Mode test et numéros de test
Avec une clé de test, l'API simule les opérateurs et WhatsApp : statuts, accusés de remise et webhooks arrivent comme en production, en quelques secondes. Ces numéros reproduisent les cas difficiles :
| Numéro | Comportement |
|---|---|
+237600000001 | Échec immédiat : numéro inexistant (invalid_number) |
+237600000002 | Envoyé, puis non remis (undelivered) |
+237600000003 | N'utilise pas WhatsApp (not_on_whatsapp) : déclenche la bascule SMS |
+237600000004 | Envoyé, aucun accusé de remise : reste au statut sent |
+237600000005 | Opérateur indisponible : nouveaux essais automatiques |
| Autre numéro | Remis après quelques secondes (et lu, sur WhatsApp) |
En mode test, POST /v1/otp renvoie aussi le code envoyé, pour automatiser vos tests, et POST /v1/sandbox/inbound simule la réponse d'un client sur WhatsApp.
Envoyer un SMS
- Numéros : format international E.164 (
+237673713115,+22676138952). Les espaces et tirets sont acceptés et retirés. - Expéditeur (
from) : 11 caractères alphanumériques au plus, déclaré auprès des opérateurs. Sansfrom, l'expéditeur par défaut de votre compte est utilisé. - Segments : un SMS contient 160 caractères de l'alphabet GSM, ou 70 si le texte contient d'autres caractères (certains accents, emojis). Au-delà, le message est découpé en segments de 153 ou 67 caractères, réassemblés par le téléphone. Chaque segment est facturé ; la réponse indique
segmentsetencoding. - Idempotence : envoyez un en-tête
Idempotency-Keyunique, par exemple l'identifiant de la commande. Rejouer la requête après une coupure réseau ne crée pas de doublon.
Cycle de vie d'un message
| Statut | Signification |
|---|---|
queued | En file d'envoi |
sent | Transmis à l'opérateur ou à WhatsApp |
delivered | Remis au téléphone du destinataire |
read | Lu (WhatsApp, si le destinataire l'autorise) |
undelivered | Non remis (téléphone éteint trop longtemps, numéro inactif…) |
failed | Envoi impossible ; voir error et fallback_id |
WhatsApp : modèles et fenêtre de 24 heures
WhatsApp impose deux règles, fixées par Meta :
- Pour écrire en premier à un client, utilisez un modèle approuvé par Meta (notification de commande, rappel, code…). Passez son nom, sa langue et ses variables dans
template. Listez vos modèles avecGET /v1/whatsapp/templateset soumettez-en de nouveaux avecPOST /v1/whatsapp/templates. - Dans les 24 heures qui suivent le dernier message du client, vous pouvez répondre librement avec
textoumedia(image, PDF, audio, vidéo). Hors de cette fenêtre, l'API refuse le texte libre (422 window_closed) : utilisez un modèle.
Les messages reçus de vos clients vous parviennent par le webhook message.received, avec la date de fin de fenêtre (window_expires_at). Les messages WhatsApp transitent par les serveurs de Meta : mentionnez-le dans votre politique de confidentialité.
curl -X POST https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "whatsapp", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}}'const res = await fetch("https://api.warilo.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"channel": "whatsapp",
"to": "+237673713115",
"template": {
"name": "suivi_commande",
"language": "fr",
"variables": [
"Awa",
"C-1042"
]
}
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/messages",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"channel": "whatsapp",
"to": "+237673713115",
"template": {
"name": "suivi_commande",
"language": "fr",
"variables": ["Awa", "C-1042"]
}
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"channel": "whatsapp", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"channel\": \"whatsapp\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/messages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"channel\": \"whatsapp\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"channel": "whatsapp", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"channel\": \"whatsapp\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Bascule WhatsApp vers SMS
Avec "channel": "auto", le message part sur WhatsApp. Si le destinataire n'utilise pas WhatsApp, ne l'a pas reçu, ou si votre compte n'a pas de numéro WhatsApp, un SMS part avec fallback_text. Le message WhatsApp passe alors au statut failed, et fallback_id indique le SMS de secours, qui a son propre cycle de vie.
Hors de la fenêtre de 24 heures et sans modèle, le SMS part directement.
curl -X POST https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "auto", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}, "fallback_text": "Bonjour Awa, votre commande C-1042 est en route."}'const res = await fetch("https://api.warilo.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"channel": "auto",
"to": "+237673713115",
"template": {
"name": "suivi_commande",
"language": "fr",
"variables": [
"Awa",
"C-1042"
]
},
"fallback_text": "Bonjour Awa, votre commande C-1042 est en route."
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/messages",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"channel": "auto",
"to": "+237673713115",
"template": {
"name": "suivi_commande",
"language": "fr",
"variables": ["Awa", "C-1042"]
},
"fallback_text": "Bonjour Awa, votre commande C-1042 est en route."
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"channel": "auto", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}, "fallback_text": "Bonjour Awa, votre commande C-1042 est en route."}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"channel\": \"auto\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}, \"fallback_text\": \"Bonjour Awa, votre commande C-1042 est en route.\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/messages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"channel\": \"auto\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}, \"fallback_text\": \"Bonjour Awa, votre commande C-1042 est en route.\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"channel": "auto", "to": "+237673713115", "template": {"name": "suivi_commande", "language": "fr", "variables": ["Awa", "C-1042"]}, "fallback_text": "Bonjour Awa, votre commande C-1042 est en route."}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"channel\": \"auto\", \"to\": \"+237673713115\", \"template\": {\"name\": \"suivi_commande\", \"language\": \"fr\", \"variables\": [\"Awa\", \"C-1042\"]}, \"fallback_text\": \"Bonjour Awa, votre commande C-1042 est en route.\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Codes de vérification (OTP)
Pour vérifier un numéro ou confirmer une opération, demandez un code avec POST /v1/otp, puis vérifiez la saisie de l'utilisateur avec POST /v1/otp/{id}/verify. L'API génère le code, l'envoie par SMS ou WhatsApp (modèle d'authentification, avec bascule SMS en auto) et n'en conserve qu'une empreinte.
- Durée de validité réglable de 1 à 30 minutes (
ttl), et 4 à 8 chiffres (length). - Un code ne sert qu'une fois, et cinq essais au plus sont autorisés.
- Un même numéro reçoit au plus cinq codes par tranche de dix minutes.
curl -X POST https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "482913"}'const res = await fetch("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"code": "482913"
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"code": "482913"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"code": "482913"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"code\": \"482913\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"code\": \"482913\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"code": "482913"}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"code\": \"482913\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Webhooks
Déclarez une adresse https:// avec PUT /v1/webhook. Chaque changement de statut et chaque message reçu y est envoyé en POST JSON. La réponse de configuration contient un secret, affiché une seule fois.
- Événements :
message.sent,message.delivered,message.read,message.undelivered,message.failed,message.received. - Réponse attendue : un code 2xx en moins de 10 secondes. Sinon, nouveaux essais après 1 min, 5 min, 30 min, 2 h, 6 h et 24 h.
- Doublons : un même événement peut arriver deux fois ; dédoublonnez avec l'en-tête
Warilo-Event-Id. - Signature : vérifiez l'en-tête
Warilo-Signature: t=…,v1=…, qui est un HMAC-SHA256 det.corpscalculé avec votre secret. Refusez les événements de plus de cinq minutes.
import crypto from "node:crypto";
// rawBody : le corps exact reçu (Buffer), avant tout JSON.parse
export function verifyWarilo(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(",").map(p => p.split("=")));
const expected = crypto.createHmac("sha256", secret)
.update(`${parts.t}.`).update(rawBody).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
return fresh && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}import hashlib, hmac, time
def verify_warilo(raw_body: bytes, header: str, secret: str) -> bool:
parts = dict(p.split("=", 1) for p in header.split(","))
expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw_body, hashlib.sha256).hexdigest()
fresh = abs(time.time() - int(parts["t"])) < 300
return fresh and hmac.compare_digest(expected, parts["v1"])function verify_warilo(string $rawBody, string $header, string $secret): bool {
parse_str(str_replace(',', '&', $header), $p);
$expected = hash_hmac('sha256', $p['t'] . '.' . $rawBody, $secret);
$fresh = abs(time() - (int) $p['t']) < 300;
return $fresh && hash_equals($expected, $p['v1']);
}import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.HexFormat;
import java.util.Map;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
public static boolean verifyWarilo(byte[] rawBody, String header, String secret) throws Exception {
Map<String, String> parts = new HashMap<>();
for (String p : header.split(",")) {
String[] kv = p.split("=", 2);
parts.put(kv[0].trim(), kv[1].trim());
}
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), "HmacSHA256"));
mac.update((parts.get("t") + ".").getBytes(StandardCharsets.UTF_8));
byte[] expected = mac.doFinal(rawBody);
boolean fresh = Math.abs(System.currentTimeMillis() / 1000 - Long.parseLong(parts.get("t"))) < 300;
return fresh && MessageDigest.isEqual(expected, HexFormat.of().parseHex(parts.get("v1")));
}using System.Linq;
using System.Security.Cryptography;
using System.Text;
static bool VerifyWarilo(byte[] rawBody, string header, string secret)
{
var parts = header.Split(',').Select(p => p.Split('=', 2)).ToDictionary(kv => kv[0], kv => kv[1]);
using var hmac = IncrementalHash.CreateHMAC(HashAlgorithmName.SHA256, Encoding.UTF8.GetBytes(secret));
hmac.AppendData(Encoding.UTF8.GetBytes(parts["t"] + "."));
hmac.AppendData(rawBody);
var expected = hmac.GetHashAndReset();
var fresh = Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - long.Parse(parts["t"])) < 300;
return fresh && CryptographicOperations.FixedTimeEquals(expected, Convert.FromHexString(parts["v1"]));
}import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"strconv"
"strings"
"time"
)
func verifyWarilo(rawBody []byte, header, secret string) bool {
parts := map[string]string{}
for _, p := range strings.Split(header, ",") {
kv := strings.SplitN(p, "=", 2)
parts[kv[0]] = kv[1]
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(parts["t"] + "."))
mac.Write(rawBody)
expected := hex.EncodeToString(mac.Sum(nil))
t, _ := strconv.ParseInt(parts["t"], 10, 64)
fresh := time.Since(time.Unix(t, 0)) < 5*time.Minute
return fresh && hmac.Equal([]byte(expected), []byte(parts["v1"]))
}require "openssl"
def verify_warilo(raw_body, header, secret)
parts = header.split(",").to_h { |p| p.split("=", 2) }
expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{parts['t']}.#{raw_body}")
fresh = (Time.now.to_i - parts["t"].to_i).abs < 300
fresh && OpenSSL.fixed_length_secure_compare(expected, parts["v1"])
endExemple d'événement
{
"id": "evt_5c4b3a29180f7e6d5c4b",
"type": "message.delivered",
"created_at": "2026-10-28T09:12:07Z",
"test": false,
"data": {
"id": "msg_3f2a9c0d1e4b5a6f7c8d",
"object": "message",
"channel": "sms",
"to": "+237673713115",
"status": "delivered",
"reference": "commande-1042"
}
}Erreurs
Les erreurs ont toujours la même forme : {"error": {"code": "…", "message": "…"}}. Votre code doit s'appuyer sur code, qui reste stable ; message est destiné aux humains. Les codes les plus fréquents :
| HTTP | code | Signification |
|---|---|---|
| 401 | unauthorized | Clé absente, invalide ou révoquée |
| 403 | live_key_in_browser | Clé live utilisée depuis un navigateur |
| 402 | insufficient_balance | Crédits insuffisants pour ce message |
| 422 | invalid_number | Numéro hors du format international E.164 |
| 422 | text_too_long | SMS de plus de 10 segments |
| 422 | window_closed | WhatsApp hors fenêtre de 24 heures sans modèle |
| 422 | missing_fallback_text | Texte de secours manquant avec channel auto |
| 409 | already_verified | Code OTP déjà utilisé |
| 410 | expired | Code OTP expiré |
| 429 | rate_limited | Trop de requêtes : réessayez avec un délai croissant |
| 500 | internal | Erreur de notre côté : request_id permet de la retrouver |
Référence de l’API
Envoyer un message
POST/v1/messages
Crée un message et le met en file d'envoi. La réponse arrive avant la remise : suivez le statut avec GET /v1/messages/{id} ou par webhook. Avec channel auto, le message part sur WhatsApp et bascule en SMS (fallback_text) si le destinataire n'utilise pas WhatsApp ou ne l'a pas reçu.
Paramètres
| Nom | Emplacement | Description |
|---|---|---|
Idempotency-Key | en-tête | Clé unique de votre côté : rejouer la requête avec la même clé ne crée pas de second message. |
Corps de la requête
| Champ | Type | Description |
|---|---|---|
channel | sms | whatsapp | auto | auto : WhatsApp, puis SMS en cas d'échec |
to obligatoire | string | Numéro au format international E.164 |
text | string | Texte du SMS, ou message WhatsApp libre (dans la fenêtre de 24 heures) |
from | string | SMS : nom d'expéditeur déclaré (11 caractères au plus) |
template | object | |
media | object | WhatsApp : fichier accessible en https:// |
fallback_text | string | Texte du SMS de secours (channel auto) |
reference | string | Votre référence, renvoyée dans les webhooks |
Exemple
curl -X POST https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"channel": "sms", "to": "+237673713115", "from": "WARILO", "text": "Votre commande C-1042 est prête.", "reference": "commande-1042"}'const res = await fetch("https://api.warilo.com/v1/messages", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"channel": "sms",
"to": "+237673713115",
"from": "WARILO",
"text": "Votre commande C-1042 est prête.",
"reference": "commande-1042"
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/messages",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"channel": "sms",
"to": "+237673713115",
"from": "WARILO",
"text": "Votre commande C-1042 est prête.",
"reference": "commande-1042"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"channel": "sms", "to": "+237673713115", "from": "WARILO", "text": "Votre commande C-1042 est prête.", "reference": "commande-1042"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"channel\": \"sms\", \"to\": \"+237673713115\", \"from\": \"WARILO\", \"text\": \"Votre commande C-1042 est pr\u00eate.\", \"reference\": \"commande-1042\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/messages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"channel\": \"sms\", \"to\": \"+237673713115\", \"from\": \"WARILO\", \"text\": \"Votre commande C-1042 est pr\u00eate.\", \"reference\": \"commande-1042\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"channel": "sms", "to": "+237673713115", "from": "WARILO", "text": "Votre commande C-1042 est prête.", "reference": "commande-1042"}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/messages", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"channel\": \"sms\", \"to\": \"+237673713115\", \"from\": \"WARILO\", \"text\": \"Votre commande C-1042 est pr\u00eate.\", \"reference\": \"commande-1042\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 201
{
"id": "msg_3f2a9c0d1e4b5a6f7c8d",
"object": "message",
"channel": "sms",
"to": "+237673713115",
"from": "WARILO",
"status": "queued",
"error": null,
"segments": 1,
"encoding": "gsm7",
"cost": 1,
"reference": "commande-1042",
"fallback_id": null,
"parent_id": null,
"test": true,
"text": "Votre commande C-1042 est prête.",
"created_at": "2026-10-28T09:12:03Z",
"updated_at": "2026-10-28T09:12:03Z"
}Lister les messages
GET/v1/messages
Messages du plus récent au plus ancien. Paginez avec starting_after (identifiant du dernier message reçu).
Paramètres
| Nom | Emplacement | Description |
|---|---|---|
limit | requête | Nombre de messages (1 à 100) |
starting_after | requête | Identifiant à partir duquel continuer |
status | requête | Filtrer par statut |
channel | requête | Filtrer par canal |
to | requête | Filtrer par destinataire (E.164) |
reference | requête | Filtrer par votre référence |
Exemple
curl -X GET https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/messages", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/messages",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/messages");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/messages", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Envoyer un lot de messages
POST/v1/messages/batch
Jusqu'à 100 messages par appel. Chaque message est validé séparément : la réponse (207) indique, pour chacun, le message créé ou l'erreur.
Corps de la requête
| Champ | Type | Description |
|---|---|---|
messages obligatoire | array |
Exemple
curl -X POST https://api.warilo.com/v1/messages/batch \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"to": "+237673713115", "text": "Rappel : réunion demain à 9 h."}, {"to": "+22676138952", "text": "Rappel : réunion demain à 9 h."}]}'const res = await fetch("https://api.warilo.com/v1/messages/batch", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"messages": [
{
"to": "+237673713115",
"text": "Rappel : réunion demain à 9 h."
},
{
"to": "+22676138952",
"text": "Rappel : réunion demain à 9 h."
}
]
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/messages/batch",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"messages": [
{
"to": "+237673713115",
"text": "Rappel : réunion demain à 9 h."
},
{
"to": "+22676138952",
"text": "Rappel : réunion demain à 9 h."
}
]
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages/batch");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"messages": [{"to": "+237673713115", "text": "Rappel : réunion demain à 9 h."}, {"to": "+22676138952", "text": "Rappel : réunion demain à 9 h."}]}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages/batch"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"messages\": [{\"to\": \"+237673713115\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}, {\"to\": \"+22676138952\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}]}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/messages/batch");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"messages\": [{\"to\": \"+237673713115\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}, {\"to\": \"+22676138952\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}]}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"messages": [{"to": "+237673713115", "text": "Rappel : réunion demain à 9 h."}, {"to": "+22676138952", "text": "Rappel : réunion demain à 9 h."}]}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/messages/batch", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages/batch")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"messages\": [{\"to\": \"+237673713115\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}, {\"to\": \"+22676138952\", \"text\": \"Rappel : r\u00e9union demain \u00e0 9 h.\"}]}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Consulter un message
GET/v1/messages/{id}
Statut à jour, erreur éventuelle et, en cas de bascule, l'identifiant du SMS de secours (fallback_id).
Paramètres
| Nom | Emplacement | Description |
|---|---|---|
id obligatoire | chemin |
Exemple
curl -X GET https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/messages/msg_3f2a9c0d1e4b5a6f7c8d")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 200
{
"id": "msg_3f2a9c0d1e4b5a6f7c8d",
"object": "message",
"channel": "sms",
"to": "+237673713115",
"from": "WARILO",
"status": "queued",
"error": null,
"segments": 1,
"encoding": "gsm7",
"cost": 1,
"reference": "commande-1042",
"fallback_id": null,
"parent_id": null,
"test": true,
"text": "Votre commande C-1042 est prête.",
"created_at": "2026-10-28T09:12:03Z",
"updated_at": "2026-10-28T09:12:03Z"
}Envoyer un code de vérification
POST/v1/otp
Génère un code, l'envoie par SMS ou WhatsApp (modèle d'authentification) et le conserve sous forme d'empreinte uniquement. Avec une clé de test, la réponse contient le code pour automatiser vos tests. Cinq codes au plus par numéro et par dix minutes.
Corps de la requête
| Champ | Type | Description |
|---|---|---|
to obligatoire | string | |
channel | sms | whatsapp | auto | |
brand | string | Nom affiché dans le message |
length | integer | |
ttl | integer | Durée de validité en secondes |
language | fr | en |
Exemple
curl -X POST https://api.warilo.com/v1/otp \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+237673713115", "channel": "sms", "brand": "MaBanque", "length": 6, "ttl": 300}'const res = await fetch("https://api.warilo.com/v1/otp", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"to": "+237673713115",
"channel": "sms",
"brand": "MaBanque",
"length": 6,
"ttl": 300
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/otp",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"to": "+237673713115",
"channel": "sms",
"brand": "MaBanque",
"length": 6,
"ttl": 300
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/otp");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"to": "+237673713115", "channel": "sms", "brand": "MaBanque", "length": 6, "ttl": 300}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/otp"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"to\": \"+237673713115\", \"channel\": \"sms\", \"brand\": \"MaBanque\", \"length\": 6, \"ttl\": 300}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/otp");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"to\": \"+237673713115\", \"channel\": \"sms\", \"brand\": \"MaBanque\", \"length\": 6, \"ttl\": 300}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"to": "+237673713115", "channel": "sms", "brand": "MaBanque", "length": 6, "ttl": 300}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/otp", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/otp")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"to\": \"+237673713115\", \"channel\": \"sms\", \"brand\": \"MaBanque\", \"length\": 6, \"ttl\": 300}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 201
{
"id": "otp_9a8b7c6d5e4f3a2b1c0d",
"object": "otp",
"to": "+237673713115",
"channel": "sms",
"message_id": "msg_1b2c3d4e5f6a7b8c9d0e",
"status": "pending",
"expires_at": "2026-10-28T09:17:03Z",
"test": true,
"code": "482913"
}Vérifier un code
POST/v1/otp/{id}/verify
Un code n'est valable qu'une fois, jusqu'à son expiration, avec cinq essais au plus.
Paramètres
| Nom | Emplacement | Description |
|---|---|---|
id obligatoire | chemin |
Corps de la requête
| Champ | Type | Description |
|---|---|---|
code obligatoire | string |
Exemple
curl -X POST https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "482913"}'const res = await fetch("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"code": "482913"
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"code": "482913"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"code": "482913"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"code\": \"482913\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"code\": \"482913\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"code": "482913"}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/otp/otp_9a8b7c6d5e4f3a2b1c0d/verify")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"code\": \"482913\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 200
{
"id": "otp_9a8b7c6d5e4f3a2b1c0d",
"object": "otp",
"valid": true,
"status": "verified"
}Soumettre un modèle à Meta
POST/v1/whatsapp/templates
Le modèle est examiné par Meta avant de pouvoir être utilisé ; son statut passe de pending à approved ou rejected. Variables : {{1}}, {{2}}…
Corps de la requête
| Champ | Type | Description |
|---|---|---|
name | string | |
language | string | |
category | marketing | utility | authentication | |
status | pending | approved | rejected | paused | disabled | |
components | array |
Exemple
curl -X POST https://api.warilo.com/v1/whatsapp/templates \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "rappel_paiement", "language": "fr", "category": "utility", "components": [{"type": "BODY", "text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.", "example": {"body_text": [["Awa", "25 000", "5 novembre"]]}}]}'const res = await fetch("https://api.warilo.com/v1/whatsapp/templates", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"name": "rappel_paiement",
"language": "fr",
"category": "utility",
"components": [
{
"type": "BODY",
"text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.",
"example": {
"body_text": [
[
"Awa",
"25 000",
"5 novembre"
]
]
}
}
]
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/whatsapp/templates",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"name": "rappel_paiement",
"language": "fr",
"category": "utility",
"components": [
{
"type": "BODY",
"text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.",
"example": {
"body_text": [
["Awa", "25 000", "5 novembre"]
]
}
}
]
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/whatsapp/templates");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"name": "rappel_paiement", "language": "fr", "category": "utility", "components": [{"type": "BODY", "text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.", "example": {"body_text": [["Awa", "25 000", "5 novembre"]]}}]}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/whatsapp/templates"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"name\": \"rappel_paiement\", \"language\": \"fr\", \"category\": \"utility\", \"components\": [{\"type\": \"BODY\", \"text\": \"Bonjour {{1}}, votre \u00e9ch\u00e9ance de {{2}} FCFA arrive le {{3}}.\", \"example\": {\"body_text\": [[\"Awa\", \"25 000\", \"5 novembre\"]]}}]}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/whatsapp/templates");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"name\": \"rappel_paiement\", \"language\": \"fr\", \"category\": \"utility\", \"components\": [{\"type\": \"BODY\", \"text\": \"Bonjour {{1}}, votre \u00e9ch\u00e9ance de {{2}} FCFA arrive le {{3}}.\", \"example\": {\"body_text\": [[\"Awa\", \"25 000\", \"5 novembre\"]]}}]}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"name": "rappel_paiement", "language": "fr", "category": "utility", "components": [{"type": "BODY", "text": "Bonjour {{1}}, votre échéance de {{2}} FCFA arrive le {{3}}.", "example": {"body_text": [["Awa", "25 000", "5 novembre"]]}}]}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/whatsapp/templates", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/whatsapp/templates")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"name\": \"rappel_paiement\", \"language\": \"fr\", \"category\": \"utility\", \"components\": [{\"type\": \"BODY\", \"text\": \"Bonjour {{1}}, votre \u00e9ch\u00e9ance de {{2}} FCFA arrive le {{3}}.\", \"example\": {\"body_text\": [[\"Awa\", \"25 000\", \"5 novembre\"]]}}]}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Lister les modèles
GET/v1/whatsapp/templates
Modèles du compte WhatsApp Business et leur statut d'approbation par Meta. Avec une clé de test : modèles d'exemple.
Exemple
curl -X GET https://api.warilo.com/v1/whatsapp/templates \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/whatsapp/templates", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/whatsapp/templates",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/whatsapp/templates");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/whatsapp/templates"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/whatsapp/templates");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/whatsapp/templates", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/whatsapp/templates")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Consulter le webhook
GET/v1/webhook
Adresse qui reçoit les événements du compte.
Exemple
curl -X GET https://api.warilo.com/v1/webhook \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/webhook", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/webhook",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/webhook");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/webhook"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/webhook");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/webhook", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/webhook")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 200
{
"object": "webhook",
"url": "https://exemple.cm/webhooks/warilo",
"enabled": true,
"secret": "whsec_…"
}Configurer le webhook
PUT/v1/webhook
Adresse https:// publique. La réponse contient le secret de signature, affiché une seule fois. Une nouvelle configuration remplace le secret.
Corps de la requête
| Champ | Type | Description |
|---|---|---|
url obligatoire | string |
Exemple
curl -X PUT https://api.warilo.com/v1/webhook \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://exemple.cm/webhooks/warilo"}'const res = await fetch("https://api.warilo.com/v1/webhook", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"url": "https://exemple.cm/webhooks/warilo"
})
});
const data = await res.json();import os, requests
r = requests.put(
"https://api.warilo.com/v1/webhook",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"url": "https://exemple.cm/webhooks/warilo"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/webhook");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"url": "https://exemple.cm/webhooks/warilo"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/webhook"))
.method("PUT", HttpRequest.BodyPublishers.ofString("{\"url\": \"https://exemple.cm/webhooks/warilo\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("PUT"), "https://api.warilo.com/v1/webhook");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"url\": \"https://exemple.cm/webhooks/warilo\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"url": "https://exemple.cm/webhooks/warilo"}`)
req, _ := http.NewRequest("PUT", "https://api.warilo.com/v1/webhook", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/webhook")
req = Net::HTTP::Put.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"url\": \"https://exemple.cm/webhooks/warilo\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 200
{
"object": "webhook",
"url": "https://exemple.cm/webhooks/warilo",
"enabled": true,
"secret": "whsec_…"
}Désactiver le webhook
DELETE/v1/webhook
Plus aucun événement n'est envoyé.
Exemple
curl -X DELETE https://api.warilo.com/v1/webhook \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/webhook", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.delete(
"https://api.warilo.com/v1/webhook",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/webhook");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/webhook"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("DELETE"), "https://api.warilo.com/v1/webhook");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("DELETE", "https://api.warilo.com/v1/webhook", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/webhook")
req = Net::HTTP::Delete.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Envoyer un événement de test
POST/v1/webhook/test
Envoie un événement webhook.test à l'adresse configurée.
Exemple
curl -X POST https://api.warilo.com/v1/webhook/test \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/webhook/test", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/webhook/test",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/webhook/test");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/webhook/test"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/webhook/test");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/webhook/test", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/webhook/test")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Consulter le solde
GET/v1/balance
Crédits restants (clé live) et coût unitaire par type de message. Les envois en mode test ne consomment aucun crédit.
Exemple
curl -X GET https://api.warilo.com/v1/balance \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/balance", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/balance",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/balance");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/balance"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/balance");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/balance", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/balance")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Réponse 200
{
"object": "balance",
"balance": 12500,
"unit": "credit",
"test": false,
"prices": {
"sms_segment": 1,
"whatsapp_template": 1,
"whatsapp_session": 0
}
}État du service
GET/v1/healthsans authentification
Sans authentification.
Exemple
curl -X GET https://api.warilo.com/v1/health \
-H "Authorization: Bearer $WARILO_KEY"const res = await fetch("https://api.warilo.com/v1/health", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`
}
});
const data = await res.json();import os, requests
r = requests.get(
"https://api.warilo.com/v1/health",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/health");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/health"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.warilo.com/v1/health");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.warilo.com/v1/health", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/health")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Simuler une réponse WhatsApp
POST/v1/sandbox/inbound
Clé de test uniquement. Simule un message reçu de ce contact : la fenêtre de 24 heures s'ouvre et un webhook message.received est envoyé.
Corps de la requête
| Champ | Type | Description |
|---|---|---|
from obligatoire | string | |
text | string |
Exemple
curl -X POST https://api.warilo.com/v1/sandbox/inbound \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "+237673713115", "text": "Bonjour, où en est ma commande ?"}'const res = await fetch("https://api.warilo.com/v1/sandbox/inbound", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.WARILO_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"from": "+237673713115",
"text": "Bonjour, où en est ma commande ?"
})
});
const data = await res.json();import os, requests
r = requests.post(
"https://api.warilo.com/v1/sandbox/inbound",
headers={"Authorization": f"Bearer {os.environ['WARILO_KEY']}"},
json={
"from": "+237673713115",
"text": "Bonjour, où en est ma commande ?"
},
)
print(r.status_code, r.json())$ch = curl_init("https://api.warilo.com/v1/sandbox/inbound");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("WARILO_KEY"), "Content-Type: application/json"],
CURLOPT_POSTFIELDS => json_encode(json_decode('{"from": "+237673713115", "text": "Bonjour, où en est ma commande ?"}')),
]);
$data = json_decode(curl_exec($ch), true);import java.net.URI;
import java.net.http.*;
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://api.warilo.com/v1/sandbox/inbound"))
.method("POST", HttpRequest.BodyPublishers.ofString("{\"from\": \"+237673713115\", \"text\": \"Bonjour, o\u00f9 en est ma commande ?\"}"))
.header("Authorization", "Bearer " + System.getenv("WARILO_KEY"))
.header("Content-Type", "application/json")
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using var client = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.warilo.com/v1/sandbox/inbound");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WARILO_KEY"));
request.Content = new StringContent("{\"from\": \"+237673713115\", \"text\": \"Bonjour, o\u00f9 en est ma commande ?\"}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := []byte(`{"from": "+237673713115", "text": "Bonjour, où en est ma commande ?"}`)
req, _ := http.NewRequest("POST", "https://api.warilo.com/v1/sandbox/inbound", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("WARILO_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(res.Status, string(data))
}require "net/http"
require "json"
require "uri"
uri = URI("https://api.warilo.com/v1/sandbox/inbound")
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['WARILO_KEY']}"
req["Content-Type"] = "application/json"
req.body = "{\"from\": \"+237673713115\", \"text\": \"Bonjour, o\u00f9 en est ma commande ?\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Tester et intégrer
Console de test
Saisissez votre clé de test (wk_test_…). Elle reste dans cette page : elle n'est ni enregistrée ni envoyée ailleurs qu'à l'API.
Fichiers et outils
Téléchargez la spécification OpenAPI pour générer un client dans votre langage, ou importez la collection dans Postman, Bruno ou Insomnia.
Prêt à intégrer la messagerie ?
Recevez vos clés de test et live, et un accompagnement pour votre intégration.
