Send a message
Sends a message on the chosen channel: SMS or WhatsApp today.
POSThttps://api.rassilo.ai/v1/messages
Base URL https://api.rassilo.ai/v1
Try it
Simulates a Sandbox request without leaving the page. Nothing is sent or billed.
Response
The response will show here.
Body parameters
channelstringrequiredThe sending channel.
sms | whatsapptostringrequiredE.164 number, for example
+22200000000.^\+[1-9]\d{6,14}$bodystringoptionalThe message text. May mix Arabic and French.
length 1–1600templatestringoptionalA catalogue template, rendered by Rassilo instead of
body. Send eitherbodyortemplate. Today:identity_verify_otp_v1.identity_verify_otp_v1dataobjectoptionalThe template’s variables: required with
template, not allowed without it. Foridentity_verify_otp_v1:code(4 to 8 digits) andexpiry_minutes(1 to 60).languagestringoptionalThe template variant to render: required with
template, not allowed without it.ar | fr | encategorystringoptionalThe message category, which drives routing and priority. With
template, it is the template’s own: any other value gives a400.transactional | utility | marketing | authentication
Headers
X-Idempotency-KeystringrequiredReplaying the same request with the same key does not send twice. The cURL samples generate it with
uuidgen(on Debian, packageuuid-runtime).length 0–255
Example request
cURL
curl https://api.rassilo.ai/v1/messages \
-H "Authorization: Bearer $RASSILO_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Idempotency-Key: $(uuidgen)" \
-d '{
"channel": "sms",
"to": "+22200000000",
"body": "Votre code Karam Pay est 482913."
}'Node.js
// send.mjs
import { randomUUID } from 'node:crypto';
const response = await fetch('https://api.rassilo.ai/v1/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.RASSILO_API_KEY}`,
'Content-Type': 'application/json',
'X-Idempotency-Key': randomUUID(),
},
body: JSON.stringify({
channel: 'sms',
to: '+22200000000',
body: 'Votre code Karam Pay est 482913.',
}),
});
const message = await response.json();
console.log(message.provisionalId, message.status); // … submittedPython
# send.py
import os
import uuid
import requests
response = requests.post(
"https://api.rassilo.ai/v1/messages",
headers={
"Authorization": f"Bearer {os.environ['RASSILO_API_KEY']}",
"X-Idempotency-Key": str(uuid.uuid4()),
},
json={
"channel": "sms",
"to": "+22200000000",
"body": "Votre code Karam Pay est 482913.",
},
)
message = response.json()
print(message["provisionalId"], message["status"]) # … submittedPHP
<?php
// send.php
$ch = curl_init('https://api.rassilo.ai/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RASSILO_API_KEY'),
'Content-Type: application/json',
'X-Idempotency-Key: ' . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode([
'channel' => 'sms',
'to' => '+22200000000',
'body' => 'Votre code Karam Pay est 482913.',
]),
]);
$message = json_decode(curl_exec($ch), true);
echo $message['provisionalId'] . ' ' . $message['status']; // … submittedJava
// SendMessage.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;
public class SendMessage {
public static void main(String[] args) throws Exception {
String json = """
{
"channel": "sms",
"to": "+22200000000",
"body": "Votre code Karam Pay est 482913."
}""";
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.rassilo.ai/v1/messages"))
.header("Authorization", "Bearer " + System.getenv("RASSILO_API_KEY"))
.header("Content-Type", "application/json")
.header("X-Idempotency-Key", UUID.randomUUID().toString())
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body()); // … "status": "submitted" …
}
}Responses
201Message created
JSON
{
"provisionalId": "msg_provisoire_0001",
"channel": "sms",
"to": "+22200000000",
"provider": "bird",
"providerMessageId": "bird_0001",
"status": "submitted",
"parts": 1,
"bodyEncoding": "GSM7"
}400Invalid parameter
JSON
{
"error": {
"code": "validation_failed",
"fieldErrors": [
{
"field": "to",
"code": "regex"
}
]
}
}422Message too long
JSON
{
"error": {
"code": "message_too_long",
"parts": 12,
"bodyEncoding": "UCS2",
"maxParts": 10
}
}Error codes
| HTTP | Code | Meaning |
|---|---|---|
400 | Invalid request: a parameter, a missing or too long X-Idempotency-Key header, or a destination this channel does not support. | |
401 | Key missing or incorrect. | |
403 | insufficient_scope | The key is valid but lacks the scope this operation needs, or it is a publishable key. Nothing is created. |
413 | payload_too_large | The request body is too large. |
422 | test_env_not_available, template_unavailable, message_too_long | test_env_not_available: This refusal also answers any send with a test-environment key: test keys can read and preview, but not send yet. template_unavailable: This template has no variant for this channel, or no approved WhatsApp template is configured for this language. Nothing is created. message_too_long: The text needs more segments than the operator accepts in one send; parts, bodyEncoding and maxParts give the detail. The same text will fail the same way. |
502 | The operator rejected or did not accept the send. | |
503 | Service temporarily unavailable: try again later. |