Send a message
Send one SMS to a Moroccan mobile number. The cost is taken from your balance when the message is accepted; a failed message is refunded.
POSThttps://api.keryk.io/v1/messages
curl https://api.keryk.io/v1/messages \
-H "Authorization: Bearer $KERYK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "+212612345678",
"text": "Votre code Keryk : 482913. Il expire dans 5 minutes.",
"reference": "login-7781"
}'Body parameters
| Name | Type | Description |
|---|---|---|
to required | string | Mobile number in E.164 format, for example +212612345678. |
text required | string | Message body. Latin text fits 160 characters per SMS; Arabic script 70. See encoding and segments. |
reference | string | Your own ID, returned in webhooks. |
callback_url | string | Receives delivered, failed and reply events. |
Response
{
"id": "msg_8f2k1q",
"status": "queued",
"segments": 1,
"encoding": "GSM-7",
"cost": { "amount": "[0.00]", "currency": "MAD" },
"balance": { "amount": "[0.00]", "currency": "MAD" }
}Messages are sent from a Moroccan mobile number. Start every message with your brand name so recipients know who it is from. Custom sender IDs are on the roadmap.
Errors
| Status | When |
|---|---|
400 | to is not a Moroccan mobile number, or text is empty. |
401 | The API key is missing or revoked. |
402 | Your balance is too low for this message. |
429 | Too many requests for this key or this number. Retry after the Retry-After header. |
[ERROR BODY FORMAT]