SafeEdge SMS

SafeEdge SMS API

Send text messages to any Ghana mobile number under your own sender ID, follow every message from your request to the handset, and buy units, all from your own code.

Base URL: https://api.dinn.safeedgesystems.com. Every request and answer is JSON. Money is in pesewas (GHS 1.00 = 100), and times are ISO 8601 in UTC, which is Ghana time.

Quickstart

  1. Get your keys. SafeEdge creates your account and gives you a test key (ssk_test_…) and a live key (ssk_live_…). Each is shown to SafeEdge once; keep it in your server's secrets, never in a web page or an app.
  2. Check your account and approved sender IDs:
    curl https://api.dinn.safeedgesystems.com/v1/account \
      -H "Authorization: Bearer $SAFEEDGE_KEY"
  3. Send with your test key first: nothing is delivered or charged, but you get every answer and webhook exactly as in live.
    curl https://api.dinn.safeedgesystems.com/v1/messages \
      -H "Authorization: Bearer $SAFEEDGE_KEY" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: order-1043-shipped" \
      -d '{
        "sender_id": "ACMESHOP",
        "message": "Hello {name}, order {order} has shipped.",
        "recipients": [
          { "to": "0241234567", "variables": { "name": "Ama", "order": "1043" }, "reference": "order-1043" }
        ]
      }'
  4. Follow it: read GET /v1/messages/{id}, or better, add a webhook and be told.

Then switch to your live key. Nothing else changes.

Keys and scopes

Send your key on every request: Authorization: Bearer ssk_live_…. SafeEdge stores only a fingerprint of it, so a lost key cannot be shown again: ask SafeEdge to revoke it and issue a new one.

ScopeAllows
sendSending and dry runs.
readEverything you can read: the log, batches, usage, sender IDs (and requesting new ones), webhooks, opt-outs.
billingBuying units.
Give each system the least it needs. A key that sits inside a website or a phone app should have send only, so it can never read your log or spend money.

Sender IDs

A sender ID is the name your recipients see instead of a number: 3 to 11 letters, digits, spaces, _ . -, with at least one letter. You can only send under your own approved names (GET /v1/sender-ids, can_send: true).

  • GET /v1/sender-ids/check?name=ACMESHOP says whether a name can be had, and why not.
  • POST /v1/sender-ids/requests asks for one, with what the messages are for. SafeEdge reviews it and submits it to the network registry; the sender_id.status_changed webhook tells you the outcome.
A name the registry has refused can never be registered again, by anyone. Names of networks, banks or government bodies are refused outright. Check first, and describe your messages honestly.

Sending messages

POST /v1/messages sends one text, or a personalised text per recipient, to 1 to 1000 numbers.

  • Numbers in any usual form: 0241234567, 233241234567, +233 24 123 4567.
  • Placeholders: {name} in message is filled from each recipient's variables. A recipient missing one is blocked (missing_variable), not sent with a gap.
  • Own text: a recipient's message replaces the shared one.
  • Your reference: reference (up to 100 characters) comes back in the log and in webhooks.
  • Idempotency: send an Idempotency-Key header. If your request times out, send the same request with the same key again: you get the first answer, and nothing is sent twice.
curl https://api.dinn.safeedgesystems.com/v1/messages \
  -H "Authorization: Bearer $SAFEEDGE_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: promo-2026-12-06" \
  -d '{"sender_id":"ACMESHOP","message":"Hi {name}, 10% off today only.",
       "recipients":[{"to":"0241234567","variables":{"name":"Ama"}},
                     {"to":"0201234567","variables":{"name":"Kofi"}}]}'

The answer lists every recipient in the order you sent them, each with its own id, status (queued, held_for_review or blocked), reason, pages and units. A blocked recipient is never sent and never charged:

reasonwhy
invalid_numberNot a Ghana mobile number.
duplicate_recipientThe same number is earlier in this request.
missing_variableA {placeholder} had no value.
empty_messageNo text for this recipient.
message_too_longOver 10 pages.
spam_suspectedMatched a content rule; reason_detail says which.
opted_outThe number is on your opt-out list.

Dry run: POST /v1/messages/check takes the same body and answers everything a send would decide (the final text of each message, its pages and units, what would be blocked and why, whether it would wait for review, and whether you have enough units), with nothing stored, sent or charged.

Pages and units

One unit is one page of text, counted the way the network provider bills:

  • Plain text (the standard SMS alphabet): 150 characters a unit, so 1 to 150 characters is 1 unit, 151 to 300 is 2, and so on. { } [ ] ~ \ | ^ € count as two characters each.
  • Anything else (an emoji, a curly quote, many accented letters) switches the whole text to 70 characters for one unit, then 67 a unit.

At most 10 units a message. The dry run tells you the exact count before you send.

Units are taken when a message is accepted. They come back when a message is blocked in review or refused before it was sent. A message that reached the network is charged whatever happens next, because the network charges for it.

Message statuses

queued → sending → submitted → sent → delivered
                                     ↘ not_delivered | expired | prohibited
statusmeaningfinal?
queuedAccepted, about to go.
held_for_reviewSafeEdge checks it first (a new account's first sends, or text a content rule flagged, or a suspended account).
sendingBeing handed to the provider.
submittedWith the SMS provider.
sentWith the mobile network.
deliveredOn the handset.yes
not_deliveredThe network could not deliver it (phone off for too long, number not in use).yes
expiredThe network gave up after its retry window.yes
prohibitedThe network refused the content or the sender ID.yes
held_by_providerThe provider has not passed it on after 2 hours, perhaps for its content. It may still move on.
blockedStopped before sending. Never charged.yes
failedRefused before it was sent. Units returned.yes
unknownThe provider did not answer. It is never sent again automatically; SafeEdge settles it.
not_confirmedThe provider never confirmed it; SafeEdge settled it as charged (it most likely went).yes

GET /v1/messages/{id} shows the whole journey: every status, when, why, and who moved it (api, safeedge_review, safeedge, network, sandbox).

What may be sent

Every account shares the same network routes, so every text is checked before it leaves.

  • A new account's first sends wait briefly for SafeEdge to read them (held_for_review).
  • Content rules block phishing patterns (an "account blocked" warning, asking for a PIN or code, "money sent by mistake", prize scams, shortened or bare-IP links) and hold others for a person to read.
  • If more than 20% of an account's messages in an hour are refused by the networks, sending pauses automatically and SafeEdge gets in touch (the account.status_changed webhook tells you at once).

Send only to people who agreed to hear from you, say who you are, and honour every request to stop (opt-outs).

The message log

GET /v1/messages lists everything you sent, newest first, with each number in full and each text (texts are kept for 90 days). Filter by status (comma separated), batch_id, sender_id, reference, to (a number), mode, created_after and created_before.

Lists answer {"data": [...], "pagination": {"has_more": true, "next_cursor": "…"}}. Pass next_cursor back as ?cursor= for the next page; limit is up to 100.

Also: GET /v1/batches (one per request, counted by status), GET /v1/usage?from=&to= (per day: sent, delivered, failed, pages, units) and GET /v1/account/units (your units statement).

Webhooks

Instead of asking, be told. Register an HTTPS endpoint on your server and choose events:

curl https://api.dinn.safeedgesystems.com/v1/webhooks \
  -H "Authorization: Bearer $SAFEEDGE_KEY" -H "Content-Type: application/json" \
  -d '{"url":"https://shop.acme.example/safeedge-hooks",
       "events":["message.status_changed","balance.low","purchase.completed"]}'

The answer contains your endpoint's signing secret (whsec_…) once: store it with your other secrets. Up to 5 endpoints.

eventwhen
message.status_changedA message moves on after your send was answered (sent, delivered, failed…).
sender_id.status_changedOne of your sender IDs is approved, refused or removed.
balance.lowYour units fall below your alert level (PATCH /v1/account, 100 by default).
purchase.completed / purchase.failedA purchase is paid, or fails or expires.
account.status_changedYour account is suspended or reinstated.

Each delivery is a POST of:

{
  "id": "3f2b6c1e-8a1d-4e4b-9b8f-2c1d0e9a7b6c",
  "type": "message.status_changed",
  "timestamp": "2026-12-06T10:00:09Z",
  "data": { "id": "…", "to": "0241234567", "status": "delivered", "reference": "order-1043", … }
}
  • Answer any 2xx within 10 seconds. Do slow work after answering.
  • Anything else, a redirect included, is retried after 1 minute, 5 minutes, 30 minutes, 2, 6, 12 and 24 hours.
  • The same event can arrive more than once, and events can arrive out of order: use id to ignore repeats and data.at to order them.
  • An endpoint that fails 50 times in a row with no success for a day is switched off; fix it, then switch it on with PATCH /v1/webhooks/{id} {"active": true}.
  • POST /v1/webhooks/{id}/test sends a test event; GET /v1/webhooks/{id}/deliveries shows every attempt.

Verifying webhooks

Deliveries are signed the Standard Webhooks way, so their libraries (standardwebhooks on npm, PyPI, Packagist and others) verify them. Or by hand: the webhook-signature header is v1, and the base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body}, keyed with the base64-decoded part of your secret after whsec_. Use the raw body, before any JSON parsing, and refuse a timestamp more than 5 minutes old.

import crypto from 'node:crypto';

export function verifySafeEdge(secret, headers, rawBody) {
  const id = headers['webhook-id'];
  const ts = headers['webhook-timestamp'];
  if (!id || !ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = crypto.createHmac('sha256', key).update(`${id}.${ts}.${rawBody}`).digest('base64');
  return String(headers['webhook-signature'] ?? '').split(' ').some((s) => {
    const [version, sig] = s.split(',');
    return version === 'v1' && sig?.length === expected.length &&
      crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
  });
}

Check your code against the standard's own example: secret whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw, id msg_p5jXN8AQM9LWM0D4loKWxJek, timestamp 1614265330, body {"test": 2432232314} must give v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE= (skip the age check for this test).

Buying units

Needs a key with the billing scope. GET /v1/packages lists what you can buy; then POST /v1/purchases with package_id and a method:

  • checkout: answers a checkout_url on Paystack. The payer pays by card or mobile money there (Paystack handles the prompt and any code); add callback_url to bring them back to your site. Paystack's charge is added on top (surcharge_pesewas). An unpaid checkout expires after 24 hours.
  • send_and_claim: answers a merchant number, an amount and a code. Pay exactly that amount by mobile money to that number and quote the code as the reference. No charge on top.

The units arrive the moment the payment is confirmed, with a purchase.completed webhook; GET /v1/purchases/{id} also shows it. At most 5 unpaid purchases at once.

Opt-outs

When someone asks you to stop, add their number: every later send to it is blocked (opted_out) and never charged. The list is yours alone.

POST /v1/opt-outs          {"to": "0241234567", "note": "Replied STOP by email"}
POST /v1/opt-outs/remove   {"to": "0241234567"}
GET  /v1/opt-outs

Numbers go in the body, never in a URL, so they never land in a web server's logs.

Errors and limits

A failure is {"error": {"code": "insufficient_units", "message": "…"}} with the HTTP status that fits. Act on the code; the message is for people. Every answer carries X-Request-Id.

HTTPmeansdo
400, 413, 422The request is wrong.Fix it; retrying the same request will not help.
401, 403The key is missing, wrong, revoked, lacks the scope, or the account is suspended.Check the key; contact SafeEdge.
402Not enough units.Buy a package.
404, 405No such thing on your account, or the wrong method.
409A conflict (an Idempotency-Key reused for a different request).
429A limit.Wait Retry-After seconds.
500, 503Our side.Retry with the same Idempotency-Key, with back-off.

Every code is listed in the API reference (Error). Limits: reading, 120 requests a minute per key; sending, your account's messages per minute and per 24 hours (see GET /v1/account); 5 sender ID requests a day.

Test mode

A ssk_test_ key behaves exactly like a live one (checks, answers, statuses, webhooks) but goes to the provider's sandbox: nothing is delivered and nothing is charged. A test message moves to delivered with the source sandbox. Test sends count towards your limits and are reported apart in usage.

Support

Email support.dinndata@gmail.com or WhatsApp 0595093277. Quote the X-Request-Id of the answer you are asking about, never your API key.