# Preview a message

Renders the message without sending it, with no idempotency key. Nothing is created or billed.

`POST https://api.rassilo.ai/v1/messages/preview`

## Body parameters

|  |  |  |  |
| --- | --- | --- | --- |
| `channel` | `string` | required | The sending channel. — `sms` \| `whatsapp` |
| `to` | `string` | required | E.164 number, for example `+22200000000`. — `^\+[1-9]\d{6,14}$` |
| `body` | `string` | optional | The message text. May mix Arabic and French. — length 1–1600 |
| `template` | `string` | optional | A catalogue template, rendered by Rassilo instead of `body`. Send either `body` or `template`. Today: `identity_verify_otp_v1`. — `identity_verify_otp_v1` |
| `data` | `object` | optional | 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). |
| `language` | `string` | optional | The template variant to render: required with `template`, not allowed without it. — `ar` \| `fr` \| `en` |
| `category` | `string` | optional | 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` |

> The cost is not available yet: `cost` is always `null`, and `pricingUnavailableReason` is `pricing_unavailable`. Do not use it for billing.

## Example request

```sh
curl https://api.rassilo.ai/v1/messages/preview \
  -H "Authorization: Bearer $RASSILO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "channel": "sms", "to": "+22200000000", "body": "Votre code Karam Pay est 482913." }'
```

## Responses

**200** — Preview

```json
{
  "channel": "sms",
  "to": "+22200000000",
  "renderedBody": "Votre code Karam Pay est 482913.",
  "cost": null,
  "pricingUnavailableReason": "pricing_unavailable",
  "note": "Cost is not available yet -- there is no real pricing/billing system. Do not rely on this response for invoicing or balance checks."
}
```

## Error codes

| HTTP | Code |  |
| --- | --- | --- |
| `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` | `template_unavailable` | This template has no variant for this channel, or no approved WhatsApp template is configured for this language. Nothing is created. |
| `503` | — | Service temporarily unavailable: try again later. |
