API Docs

Webhooks

Get delivery, sender name and purchase updates pushed to your server.

Instead of polling, give NBM SMS a URL on your server and it will POST a small JSON message whenever something you care about changes. Every callback has the same shape — an entity saying what changed, its id and the new status.

Registering a webhook URL

Webhook URLs are set in the portal (API section), not through the API. There are two kinds:

SettingReceives
Account default webhookEvery message delivery callback, whichever key sent the message. Also the fallback for sender name and purchase callbacks.
Per-key webhookSender name and purchase callbacks for requests made with that key. If the key has none, the account default is used.

Sender name requests and purchases made from the portal (not the API) always use the account default.

How callbacks are delivered

  • POST with Content-Type: application/json, to an HTTPS URL.
  • Reply with any 2xx within 10 seconds. Do slow work after replying, or in a queue.
  • A failed or slow delivery is logged but not retried.

Message status callback

Sent when a message reaches delivered or undelivered. Earlier steps (sending, sent…) aren't pushed — poll List messages if you need them.

Payload
entitystringrequired
Always messages.
iduuidrequired
The message id.
statusstringrequired
delivered or undelivered.
POST to your account webhook
{
  "entity": "messages",
  "id": "6b2f6e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
  "status": "delivered"
}

Sender name status callback

Sent when a sender name you requested is approved, declined, disabled or enabled again.

Payload
entitystringrequired
Always sender-names.
iduuidrequired
The sender name id.
statusstringrequired
requested, approved or declined.
is_disabledbooleanrequired
Whether the name is currently switched off. Changes independently of status.
POST to the key's webhook
{
  "entity": "sender-names",
  "id": "9a1c1e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
  "status": "approved",
  "is_disabled": false
}

Purchase status callback

Sent when a credit purchase is paid.

Payload
entitystringrequired
Always purchases.
iduuidrequired
The purchase id.
statusstringrequired
pending or paid.
POST to the key's webhook
{
  "entity": "purchases",
  "id": "3d4e6e2a-4b0e-4e9a-9a2e-1a2b3c4d5e6f",
  "status": "paid"
}

Receiving callbacks

Minimal receivers that reply fast and then fetch the real record:

Node.js (Express)
import express from "express";

const app = express();
app.use(express.json());

app.post("/hooks/nbm-sms", async (req, res) => {
  // 1. Answer straight away: NBM waits at most 10 seconds.
  res.sendStatus(204);

  // 2. Then do the work.
  const { entity, id, status } = req.body;
  if (entity === "messages") {
    // Fetch the message to get the full, current record.
    const r = await fetch(`https://sms.nbmbrand.com/api/v1/messages/${id}`, {
      headers: { Authorization: `Bearer ${process.env.NBM_SMS_API_KEY}` },
    });
    const { data } = await r.json();
    await markOrderNotification(data.id, data.status); // your code
  }
});

app.listen(3000);
PHP (Laravel)
<?php
// routes/web.php (Laravel) — exclude this path from CSRF protection.
Route::post('/hooks/nbm-sms', function (Illuminate\Http\Request $request) {
    $entity = $request->input('entity');
    $id     = $request->input('id');
    $status = $request->input('status');

    // Queue the work so the response goes back immediately.
    dispatch(new App\Jobs\HandleNbmSmsCallback($entity, $id, $status));

    return response()->noContent(); // 204
});
Python (Flask)
from flask import Flask, request
import os, requests

app = Flask(__name__)

@app.post("/hooks/nbm-sms")
def nbm_sms():
    event = request.get_json(force=True)
    if event.get("entity") == "messages":
        r = requests.get(
            f"https://sms.nbmbrand.com/api/v1/messages/{event['id']}",
            headers={"Authorization": f"Bearer {os.environ['NBM_SMS_API_KEY']}"},
            timeout=10,
        )
        message = r.json()["data"]
        # ... update your records with message["status"]
    return "", 204