Get started

Quickstart

Create a test key, send your first SMS through the sandbox, and read what happened to it.

A test key sends through Ghala's sandbox: it is checked like a live send, nothing reaches a phone, and nothing is charged. This guide takes about five minutes.

Create a test key

In the Ghala dashboard, open Developers, then API keys, and create a key with the mode set to Test. Give it the messages:send and messages:read scopes.

The key is shown once. Keep it in an environment variable, never in your code:

export GHALA_KEY="ghala_test_..."

Only a workspace's owners and admins create keys.

Have an approved sender ID

An SMS goes out under a sender ID your workspace may use, and a test key checks this like a live one. A workspace starts with none. Request one in the dashboard under SMS, then Sender IDs, and list the ones you can use:

curl https://v3.ghala.io/v1/sender-ids \
  -H "Authorization: Bearer $GHALA_KEY"

The examples below use ACME. Put your own approved sender ID in its place.

Send a message

Send to 255700000001, a sandbox number that is always delivered:

curl https://v3.ghala.io/v1/messages \
  -H "Authorization: Bearer $GHALA_KEY" \
  -H "Content-Type: application/json" \
  -d '{"channel": "sms", "from": "ACME", "to": ["255700000001"], "type": "text", "text": "Hello from Ghala"}'
const res = await fetch("https://v3.ghala.io/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.GHALA_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ channel: "sms", from: "ACME", to: ["255700000001"], type: "text", text: "Hello from Ghala" }),
})
console.log(res.status, await res.json())
import os, requests

res = requests.post(
    "https://v3.ghala.io/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['GHALA_KEY']}"},
    json={"channel": "sms", "from": "ACME", "to": ["255700000001"], "type": "text", "text": "Hello from Ghala"},
)
print(res.status_code, res.json())

The answer is 201. Every message carries "test": true, and nothing was charged:

{
  "status": "sent",
  "job_id": "sandbox_2b0aed2c-141e-452f-bee3-405245d6a69e",
  "parts": 1,
  "charged_minor": 0,
  "messages": [
    {
      "id": "beed6233-06e0-4805-aba8-c506fe88ab88",
      "phone": "255700000001",
      "channel": "sms",
      "from": "ACME",
      "content": { "type": "text", "text": "Hello from Ghala" },
      "status": "sent",
      "request_id": "78e87745e1a902aa033d376d0afbb1ef",
      "price_minor": 0,
      "test": true
    }
  ],
  "invalid": [],
  "suppressed": []
}

Read what happened

About two seconds later the sandbox reports the outcome, the way a network's delivery report arrives. Look the message up by its id:

curl https://v3.ghala.io/v1/messages/beed6233-06e0-4805-aba8-c506fe88ab88 \
  -H "Authorization: Bearer $GHALA_KEY"

Its status is now delivered, with delivered_at set. To be told instead of asking, add a webhook: every status change is posted to your endpoint, signed.

Next

  • Test mode: the numbers with fixed outcomes, and what a test key cannot do.
  • Going live: a live key, a funded wallet, and the checks to make first.

On this page