Quickstart

1. Create an account, confirm your e-mail and verify your phone. 2. Copy the API key from the dashboard. 3. Send:

curl -X POST https://api.sendrail.cz/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": "+420777123456", "message": "Your code is 482913"}'
HTTP/1.1 202 Accepted
{
  "id": "msg_5f0c9a1e7b2d4c8a9e01",
  "status": "queued",
  "to": "+420777123456",
  "country": "CZ",
  "segments": 1,
  "encoding": "GSM-7",
  "tier": "standard",
  "price": 0.5,
  "currency": "CZK",
  "trial": false,
  "via_backup_route": false,
  "error": null,
  "created_at": "2026-11-25 10:15:02",
  "final_at": null
}

PHP:

$ch = curl_init("https://api.sendrail.cz/v1/messages");
curl_setopt_array($ch, [
  CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["Authorization: Bearer $apiKey", "Content-Type: application/json"],
  CURLOPT_POSTFIELDS => json_encode(["to" => "+420777123456", "message" => "Your code is 482913"]),
]);
$message = json_decode(curl_exec($ch), true);

Python:

import requests
r = requests.post("https://api.sendrail.cz/v1/messages",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={"to": "+420777123456", "message": "Your code is 482913"}, timeout=20)
message = r.json()

Node.js:

const r = await fetch("https://api.sendrail.cz/v1/messages", {
  method: "POST",
  headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({ to: "+420777123456", message: "Your code is 482913" }),
});
const message = await r.json();

Authentication

Every request carries an API key: Authorization: Bearer YOUR_API_KEY (the header X-API-Key works too). Keys are created in the dashboard. Keep them on your server; anyone holding a key can spend your credit. A key can be paused at any time.

Send a message

POST /v1/messages with a JSON body:

FieldTypeDescription
tostring, requiredRecipient in international format, e.g. +420777123456.
messagestring, requiredText, at most 10 segments.
idempotency_keystring, optionalYour own unique id of this message, up to 120 characters. Can also be sent as the Idempotency-Key header.
dry_runboolean, optionaltrue validates the request and returns segments and price without sending or charging.

The answer is 202 Accepted with the message object. The price is taken from your credit at this moment and returned in full if the message does not leave.

The sender is a real mobile number of ours, so the recipient can reply. Alphanumeric sender names are not available.

Segments and price

Text made only of GSM-7 characters fits 160 characters per SMS, or 153 per segment when it has to be split. Any other character (for example Czech diacritics such as ě š č) switches the whole text to UCS-2: 70 characters, or 67 per segment. You pay per segment; segments, encoding and price are in every response. Current prices: price list or GET /v1/prices.

Idempotency

Networks fail. If your request times out you cannot know whether we accepted it. Send an idempotency_key with every message and simply repeat the request: the same key on the same API key returns the original message with "duplicate": true and status 200 instead of sending a second SMS.

Independently of that, an identical text to the same number within five minutes is treated as a repeat and is not sent twice.

Message status

GET /v1/messages/{id} returns the message object.

StatusMeaningCharged
queuedAccepted, waiting for a free line or being sent.reserved
sentHanded over to the mobile network. Final. via_backup_route tells whether the backup operator was used.yes
failedCould not be sent. Final.refunded
rejectedRefused by the gateway (for example a number that cannot exist). Final.refunded
cancelledCancelled by you before it left. Final.refunded

sent means the network accepted the message. Handset delivery receipts are not available.

Webhooks

Set a webhook URL on the API key and we POST the final state of every message sent with that key:

POST https://your-server.example/sendrail
Content-Type: application/json
X-Sendrail-Signature: sha256=6f1c…

{"event":"message.final","message":{"id":"msg_5f0c9a1e7b2d4c8a9e01","status":"sent", …}}

Verify the signature: it is the hex HMAC-SHA256 of the raw request body, keyed with the signing secret shown next to the key in the dashboard.

expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
ok = hmac.compare_digest("sha256=" + expected, request.headers["X-Sendrail-Signature"])

Answer with any 2xx within 5 seconds. Otherwise we retry after 1 minute, 5 minutes, 15 minutes, 1 hour and 6 hours, then give up. The URL must be public https; redirects are not followed. Handle repeats: the same event can arrive more than once.

Cancel

POST /v1/messages/{id}/cancel cancels a message that is still queued and refunds it. A message that already left answers 409.

Account

GET /v1/account returns your credit, remaining trial messages and the rules of the key used.

Key rules and plans

Each key has a plan and an optional list of allowed destination countries; a message to any other country is refused with 403.

PlanBehaviour
StandardSent over our own SIM network only. If it cannot be sent, the message ends as failed and is refunded.
GaranceIf our own network cannot send within about a minute, the message goes out through a contracted backup operator at the same price.

Trial mode

A new account gets 100 free messages. Until the first credit top-up they can be sent only to the phone number verified at sign-up; other recipients answer 403 trial_recipient.

Errors

Errors are JSON: {"error": {"code": "…", "message": "…"}}.

HTTPCodeWhat to do
400missing_field, invalid_number, message_too_long, rejectedFix the request; repeating it unchanged will fail again.
401invalid_api_keyCheck the key and that it is not paused.
402insufficient_credit, trial_exhaustedTop up credit.
403country_not_allowed, trial_recipient, phone_not_verified, account_blockedChange the key's rules, verify your phone, or contact us.
404not_foundThe message id does not belong to your account.
409already_finalThe message can no longer be cancelled.
422country_not_supportedWe do not send to that country on this plan yet.
429rate_limitedSlow down and retry.
502gateway_errorNothing was charged. Retry with the same idempotency_key.

Limits

60 messages per minute per API key. The service is built for transactional traffic of up to thousands of messages a day; bulk marketing campaigns are not allowed. Typical time from request to sent is around ten seconds, so give your HTTP client a timeout of at least 20 seconds for the request itself and read the final state from the webhook or by polling.