Home / Developers
SMS and WhatsApp messaging API
One API to send SMS and WhatsApp messages, with automatic fallback, OTP codes and signed webhooks. Test everything without sending anything with a test key.
Quick start
The Warilo messaging API sends SMS and WhatsApp messages with a single call. All requests go through https://api.warilo.com/v1/, in JSON, with your key in the Authorization header.
Three steps to a first message:
- Request your account: you receive a test key
wk_test_…and a live keywk_live_…. - Send a message with the test key: nothing is actually sent, and the message goes through every status as in production.
- Replace the test key with the live key on your server.
curl -X POST https://api.warilo.com/v1/messages \
-H "Authorization: Bearer $WARILO_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "+237673713115", "text": "Hello from 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": "Hello from 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": "Hello from 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": "Hello from 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\": \"Hello from 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\": \"Hello from 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": "Hello from 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\": \"Hello from Warilo\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Response: the message is accepted and queued (201, status queued). Then track its status by webhook or with GET /v1/messages/{id}.
Authentication
Every request carries the header Authorization: Bearer <key>.
- Test key (
wk_test_…): no real sending, no credits used. Can be used from a browser, for example in the console below. - Live key (
wk_live_…): real sending, charged to your balance. Server side only: a request carrying a live key and a browserOriginheader is refused (403 live_key_in_browser).
Keep your keys in an environment variable or a secrets vault, never in source code. An exposed key is revoked immediately on request.
Test mode and test numbers
With a test key, the API simulates operators and WhatsApp: statuses, delivery receipts and webhooks arrive as in production, within seconds. These numbers reproduce the difficult cases:
| Number | Behaviour |
|---|---|
+237600000001 | Immediate failure: number does not exist (invalid_number) |
+237600000002 | Sent, then not delivered (undelivered) |
+237600000003 | Not on WhatsApp (not_on_whatsapp): triggers the SMS fallback |
+237600000004 | Sent, no delivery receipt: stays sent |
+237600000005 | Operator unavailable: automatic retries |
| Any other number | Delivered after a few seconds (and read, on WhatsApp) |
In test mode, POST /v1/otp also returns the code sent, so you can automate your tests, and POST /v1/sandbox/inbound simulates a customer reply on WhatsApp.
Sending SMS
- Numbers: international E.164 format (
+237673713115,+22676138952). Spaces and dashes are accepted and removed. - Sender (
from): up to 11 alphanumeric characters, registered with the operators. Withoutfrom, your account's default sender is used. - Segments: an SMS holds 160 characters of the GSM alphabet, or 70 if the text contains other characters (some accents, emojis). Beyond that, the message is split into segments of 153 or 67 characters, reassembled by the phone. Each segment is billed; the response gives
segmentsandencoding. - Idempotency: send a unique
Idempotency-Keyheader, for example the order ID. Replaying the request after a network failure does not create a duplicate.
Message lifecycle
| Status | Meaning |
|---|---|
queued | Queued for sending |
sent | Handed to the operator or WhatsApp |
delivered | Delivered to the recipient's phone |
read | Read (WhatsApp, if the recipient allows it) |
undelivered | Not delivered (phone off too long, inactive number…) |
failed | Could not be sent; see error and fallback_id |
WhatsApp: templates and the 24-hour window
WhatsApp enforces two rules, set by Meta:
- To message a customer first, use a template approved by Meta (order notification, reminder, code…). Pass its name, language and variables in
template. List your templates withGET /v1/whatsapp/templatesand submit new ones withPOST /v1/whatsapp/templates. - Within 24 hours of the customer's last message, you can reply freely with
textormedia(image, PDF, audio, video). Outside this window, the API refuses free-form text (422 window_closed): use a template.
Messages from your customers reach you through the message.received webhook, with the window end date (window_expires_at). WhatsApp messages go through Meta's servers: mention it in your privacy policy.
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}"WhatsApp to SMS fallback
With "channel": "auto", the message goes out on WhatsApp. If the recipient does not use WhatsApp, did not receive it, or your account has no WhatsApp number, an SMS is sent with fallback_text. The WhatsApp message then becomes failed, and fallback_id points to the backup SMS, which has its own lifecycle.
Outside the 24-hour window and without a template, the SMS goes out directly.
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": "Hello Awa, your order C-1042 is on its way."}'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": "Hello Awa, your order C-1042 is on its way."
})
});
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": "Hello Awa, your order C-1042 is on its way."
},
)
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": "Hello Awa, your order C-1042 is on its way."}')),
]);
$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\": \"Hello Awa, your order C-1042 is on its way.\"}"))
.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\": \"Hello Awa, your order C-1042 is on its way.\"}", 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": "Hello Awa, your order C-1042 is on its way."}`)
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\": \"Hello Awa, your order C-1042 is on its way.\"}"
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(req) }
puts "#{res.code} #{res.body}"Verification codes (OTP)
To verify a number or confirm an operation, request a code with POST /v1/otp, then check what the user typed with POST /v1/otp/{id}/verify. The API generates the code, sends it by SMS or WhatsApp (authentication template, with SMS fallback in auto) and only keeps a hash of it.
- Validity from 1 to 30 minutes (
ttl), and 4 to 8 digits (length). - A code can be used only once, with at most five attempts.
- A given number receives at most five codes every ten 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
Declare an https:// address with PUT /v1/webhook. Every status change and every received message is sent to it as a JSON POST. The configuration response contains a secret, shown only once.
- Events:
message.sent,message.delivered,message.read,message.undelivered,message.failed,message.received. - Expected response: a 2xx code within 10 seconds. Otherwise, retries after 1 min, 5 min, 30 min, 2 h, 6 h and 24 h.
- Duplicates: the same event may arrive twice; deduplicate with the
Warilo-Event-Idheader. - Signature: check the
Warilo-Signature: t=…,v1=…header, an HMAC-SHA256 oft.bodycomputed with your secret. Reject events older than five 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"])
endSample event
{
"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"
}
}Errors
Errors always have the same shape: {"error": {"code": "…", "message": "…"}}. Your code should rely on code, which stays stable; message is meant for humans. The most common codes:
| HTTP | code | Meaning |
|---|---|---|
| 401 | unauthorized | Missing, invalid or revoked key |
| 403 | live_key_in_browser | Live key used from a browser |
| 402 | insufficient_balance | Not enough credits for this message |
| 422 | invalid_number | Number not in international E.164 format |
| 422 | text_too_long | SMS longer than 10 segments |
| 422 | window_closed | WhatsApp outside the 24-hour window without a template |
| 422 | missing_fallback_text | Fallback text missing with channel auto |
| 409 | already_verified | OTP code already used |
| 410 | expired | OTP code expired |
| 429 | rate_limited | Too many requests: retry with increasing delay |
| 500 | internal | Error on our side: request_id lets us trace it |
API reference
Send a message
POST/v1/messages
Creates a message and queues it for sending. The response arrives before delivery: track the status with GET /v1/messages/{id} or by webhook. With channel auto, the message goes out on WhatsApp and falls back to SMS (fallback_text) if the recipient does not use WhatsApp or did not receive it.
Parameters
| Name | In | Description |
|---|---|---|
Idempotency-Key | header | A unique key on your side: replaying the request with the same key does not create a second message. |
Request body
| Field | Type | Description |
|---|---|---|
channel | sms | whatsapp | auto | auto: WhatsApp, then SMS on failure |
to required | string | Number in international E.164 format |
text | string | SMS text, or free-form WhatsApp message (within the 24-hour window) |
from | string | SMS: registered sender name (11 characters max) |
template | object | |
media | object | WhatsApp: file reachable over https:// |
fallback_text | string | Text of the backup SMS (channel auto) |
reference | string | Your reference, returned in webhooks |
Example
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}"Response 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"
}List messages
GET/v1/messages
Messages from newest to oldest. Paginate with starting_after (ID of the last message received).
Parameters
| Name | In | Description |
|---|---|---|
limit | query | Number of messages (1 to 100) |
starting_after | query | ID to continue from |
status | query | Filter by status |
channel | query | Filter by channel |
to | query | Filter by recipient (E.164) |
reference | query | Filter by your reference |
Example
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}"Send a batch of messages
POST/v1/messages/batch
Up to 100 messages per call. Each message is validated separately: the response (207) gives, for each one, the created message or the error.
Request body
| Field | Type | Description |
|---|---|---|
messages required | array |
Example
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}"Retrieve a message
GET/v1/messages/{id}
Current status, any error and, after a fallback, the ID of the backup SMS (fallback_id).
Parameters
| Name | In | Description |
|---|---|---|
id required | path |
Example
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}"Response 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"
}Send a verification code
POST/v1/otp
Generates a code, sends it by SMS or WhatsApp (authentication template) and only stores its hash. With a test key, the response includes the code so you can automate your tests. At most five codes per number every ten minutes.
Request body
| Field | Type | Description |
|---|---|---|
to required | string | |
channel | sms | whatsapp | auto | |
brand | string | Name shown in the message |
length | integer | |
ttl | integer | Validity in seconds |
language | fr | en |
Example
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}"Response 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"
}Verify a code
POST/v1/otp/{id}/verify
A code is valid only once, until it expires, with at most five attempts.
Parameters
| Name | In | Description |
|---|---|---|
id required | path |
Request body
| Field | Type | Description |
|---|---|---|
code required | string |
Example
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}"Response 200
{
"id": "otp_9a8b7c6d5e4f3a2b1c0d",
"object": "otp",
"valid": true,
"status": "verified"
}Submit a template to Meta
POST/v1/whatsapp/templates
The template is reviewed by Meta before it can be used; its status changes from pending to approved or rejected. Variables: {{1}}, {{2}}…
Request body
| Field | Type | Description |
|---|---|---|
name | string | |
language | string | |
category | marketing | utility | authentication | |
status | pending | approved | rejected | paused | disabled | |
components | array |
Example
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}"List templates
GET/v1/whatsapp/templates
Templates of the WhatsApp Business account and their Meta approval status. With a test key: sample templates.
Example
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}"Retrieve the webhook
GET/v1/webhook
Address that receives the account's events.
Example
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}"Response 200
{
"object": "webhook",
"url": "https://exemple.cm/webhooks/warilo",
"enabled": true,
"secret": "whsec_…"
}Set the webhook
PUT/v1/webhook
Public https:// address. The response contains the signing secret, shown only once. A new configuration replaces the secret.
Request body
| Field | Type | Description |
|---|---|---|
url required | string |
Example
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}"Response 200
{
"object": "webhook",
"url": "https://exemple.cm/webhooks/warilo",
"enabled": true,
"secret": "whsec_…"
}Disable the webhook
DELETE/v1/webhook
No more events are sent.
Example
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}"Send a test event
POST/v1/webhook/test
Sends a webhook.test event to the configured address.
Example
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}"Retrieve the balance
GET/v1/balance
Remaining credits (live key) and unit cost per message type. Test-mode sends use no credits.
Example
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}"Response 200
{
"object": "balance",
"balance": 12500,
"unit": "credit",
"test": false,
"prices": {
"sms_segment": 1,
"whatsapp_template": 1,
"whatsapp_session": 0
}
}Service status
GET/v1/healthno authentication
No authentication.
Example
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}"Simulate a WhatsApp reply
POST/v1/sandbox/inbound
Test key only. Simulates a message received from this contact: the 24-hour window opens and a message.received webhook is sent.
Request body
| Field | Type | Description |
|---|---|---|
from required | string | |
text | string |
Example
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}"Test and integrate
Test console
Enter your test key (wk_test_…). It stays in this page: it is neither stored nor sent anywhere but to the API.
Files and tools
Download the OpenAPI specification to generate a client in your language, or import the collection into Postman, Bruno or Insomnia.
Ready to integrate messaging?
Get your test and live keys, and support for your integration.
