# Sending SMS

Senders, segments, languages and delivery tracking — what to know before sending an SMS in Mauritania and the region.

## Choose a sender

The sender is the name your customer sees, for example `KARAMPAY`. It is registered **country by country** in the dashboard, under Senders: until it is approved in a country, sends to that country are refused.

## Send

**cURL**

```sh
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**

```node
// 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**

```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
```

## Segments and languages

An SMS is billed per segment. Arabic and characters outside the GSM alphabet switch to Unicode, which makes a segment shorter. Each response gives the segment count (`parts`) and the encoding (`bodyEncoding`: `GSM7` or `UCS2`).

| Encoding | One segment | Long message, per segment |
| --- | --- | --- |
| GSM-7 | 160 characters | 153 characters |
| Unicode (UCS-2) | 70 characters | 67 characters |

## Delivery statuses

| Status | Meaning |
| --- | --- |
| `submitted` | Submitted: the operator accepted the message. Not a delivery yet. |
| `delivered` | Delivered: the operator confirms it reached the phone. The only status that means delivered. |
| `failed` | Failed: the message was not delivered. |
| `delivery_unknown` | Outcome unknown: no delivery report 72 hours after submission. The message is not counted as delivered. |

> Today, `POST /v1/messages` answers `submitted`. The later statuses will come with reading a message and webhooks, available soon.
