SMS
Text messages to any phone, under your approved sender ID.
What you can do
- Send one text to up to 1,000 numbers in a single request.
- Follow each message from
senttodeliveredorfailed, by request or by webhook. - Try everything first with a test key, free, in the sandbox.
Before you start
An SMS goes out under a sender ID, the name people see it from. Request one in the dashboard under SMS, then Sender IDs. Once it is approved, it shows in your list:
curl https://v3.ghala.io/v1/sender-ids \
-H "Authorization: Bearer $GHALA_KEY"Each has a status, and access says whether it is yours (owned) or one Ghala shares (global). The examples below use ACME: put your own in its place.
Send
curl https://v3.ghala.io/v1/messages \
-H "Authorization: Bearer $GHALA_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1042-ready" \
-d '{"channel": "sms", "from": "ACME", "to": ["0700000001", "+255 700 000 004"], "type": "text", "text": "Your order is ready"}'/v1/messagesSend messagemessages:send
fromis required, and must be a sender ID approved for your workspace.totakes up to 1,000 numbers, written as people type them. A local number is read against your workspace's country, and messages come back with the number as country code and digits:255712345678.- Numbers that will not parse come back in
invalid. Numbers on your suppression list are skipped and come back insuppressed. partsis how many SMS parts the text takes. A live send is charged per part, reserved from your wallet before it goes.
The older body still works and makes the same send: {"to": [...], "body": "...", "sender_id": "ACME"}. Use one shape or the other, not both.
Statuses
An SMS goes sent, then delivered or failed. SMS does not report read. See Message statuses.
Test mode
A test key checks your sender ID and numbers like a live send, then hands the message to the sandbox: free, and nothing reaches a phone. 255700000001 is always delivered and 255700000002 always fails. See Test mode.
When it fails
| Status | code | When |
|---|---|---|
400 | missing_field | no from. field is from |
400 | invalid_address | none of the numbers is a valid phone number. field is to |
403 | sender_id_not_approved | your workspace may not send as from |
402 | insufficient_funds | a live send your wallet cannot cover; nothing was sent |
502 | provider_rejected | the network refused it; recorded as failed, not charged |
503 | provider_unavailable | the network did not answer. It may still have been delivered: check the message's status before sending again |