Skip to content

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.

Sandbox

No key here: on your server, the request reads the key from the RASSILO_API_KEY variable.

E.164 format: +222 then 8 digits.

32 characters, 1 segment

Request

cURL
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."
}'

Response

The response will show here.

Body parameters

  • channelstringrequired

    The sending channel.

    sms | whatsapp

  • tostringrequired

    E.164 number, for example +22200000000.

    ^\+[1-9]\d{6,14}$

  • bodystringoptional

    The message text. May mix Arabic and French.

    length 1–1600

  • templatestringoptional

    A catalogue template, rendered by Rassilo instead of body. Send either body or template. Today: identity_verify_otp_v1.

    identity_verify_otp_v1

  • dataobjectoptional

    The template’s variables: required with template, not allowed without it. For identity_verify_otp_v1: code (4 to 8 digits) and expiry_minutes (1 to 60).

  • languagestringoptional

    The template variant to render: required with template, not allowed without it.

    ar | fr | en

  • categorystringoptional

    The message category, which drives routing and priority. With template, it is the template’s own: any other value gives a 400.

    transactional | utility | marketing | authentication

Headers

  • X-Idempotency-Keystringrequired

    Replaying the same request with the same key does not send twice. The cURL samples generate it with uuidgen (on Debian, package uuid-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); // … submitted
Python
# 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"])  # … submitted
PHP
<?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']; // … submitted
Java
// 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
JSON
{
  "provisionalId": "msg_provisoire_0001",
  "channel": "sms",
  "to": "+22200000000",
  "provider": "bird",
  "providerMessageId": "bird_0001",
  "status": "submitted",
  "parts": 1,
  "bodyEncoding": "GSM7"
}

400Invalid parameter

JSON
JSON
{
  "error": {
    "code": "validation_failed",
    "fieldErrors": [
      {
        "field": "to",
        "code": "regex"
      }
    ]
  }
}

422Message too long

JSON
JSON
{
  "error": {
    "code": "message_too_long",
    "parts": 12,
    "bodyEncoding": "UCS2",
    "maxParts": 10
  }
}

Error codes

HTTPCodeMeaning
400Invalid request: a parameter, a missing or too long X-Idempotency-Key header, or a destination this channel does not support.
401Key missing or incorrect.
403insufficient_scopeThe key is valid but lacks the scope this operation needs, or it is a publishable key. Nothing is created.
413payload_too_largeThe request body is too large.
422test_env_not_available, template_unavailable, message_too_longtest_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.
502The operator rejected or did not accept the send.
503Service temporarily unavailable: try again later.