Send a message

Send one SMS and follow it to delivery.

Send a message with POST /messages:

curl https://api.appstractone.com/v1/messages \
  -H "Authorization: Bearer $APPSTRACT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 3f1c9a52-6a5f-4b8e-9c55-0e7f1a2b3c4d" \
  -d '{
    "to": "0241234567",
    "from": "MYSHOP",
    "text": "Your order #1042 is on its way.",
    "reference": "order-1042"
  }'
FieldRequiredDescription
toYesA Ghana mobile number, local (0241234567) or international (+233241234567).
fromYesAn approved sender ID on your account.
textYesThe message. Long messages are split into segments.
referenceNoYour own reference, up to 100 characters. Returned in responses and webhooks.

The API responds with 202 Accepted:

{
  "id": "msg_01M6MJSBV7KXZGYK5TZGGA0P6R",
  "to": "+233241234567",
  "status": "queued",
  "encoding": "GSM-7",
  "segments": 1,
  "cost": { "amount": "0.04", "currency": "GHS" },
  "reference": "order-1042",
  "test": false
}

202 means the message was accepted and paid for, not that it was delivered. Follow it with webhooks or by fetching it with GET /messages/{id}.

Check the cost first

To see how many segments a message uses and what it costs, without sending it, call POST /messages/estimate:

curl https://api.appstractone.com/v1/messages/estimate \
  -H "Authorization: Bearer $APPSTRACT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Your order #1042 is on its way.", "recipients": 250 }'

Retry safely

Network errors happen. Send an Idempotency-Key header with every message so that retrying a request never sends the message twice. See Idempotency.

Find messages later

List your messages with GET /messages. Filter by status, to, from, reference, batchId, createdFrom and createdTo.

On this page