API reference

NHZ Gateway API

Base URL https://gateway.nhzglobal.com/api/v1. All requests and responses are JSON over HTTPS.

Authentication

Create a key in Settings → API keys. It is shown once; store it like a password. Send it on every request:

Authorization: Bearer nhz_xxxxxxxxxxxxxxxxxxxxxxxx

A missing or wrong key returns 401.

Send messages

POST /api/v1/messages

{
  "to": ["+14155550123", "+447700900123"],
  "message": "Hi {name}, your order has shipped",
  "channel": "sms",
  "device_id": 3,
  "sim_slot": 0,
  "schedule_at": "2026-12-01T09:00:00Z"
}
FieldRequiredNotes
toYesArray or comma separated string, up to 1,000 numbers. Numbers without a + get your account's default country code (set in Settings).
messageYesUp to 1,600 characters. {name} becomes the contact's name.
channelNosms (default) or whatsapp.
device_idNoSend from one phone. Default: any online phone.
sim_slotNo0 or 1. Default: spread across SIMs.
schedule_atNoISO 8601 date and time to send later.
marketingNotrue for promotional texts: adds your opt-out line and holds the send until your quiet hours end (both set in Settings).

Response 201: the queued messages, plus any numbers skipped as invalid or opted out.

{
  "batch": "01JD3Q...",
  "messages": [{ "id": 9123, "phone": "+14155550123", "status": "queued" }],
  "skipped": [{ "phone": "+447700900123", "reason": "opted out" }]
}

Read messages

GET /api/v1/messages/9123
GET /api/v1/messages?direction=in&since_id=9000&limit=50

Filters: direction (in, out), status, channel, batch, phone, since_id, limit (max 200). Newest first.

Cancel

DELETE /api/v1/messages/9123

Cancels a message that is still queued. Returns {"cancelled": true} or false if it already went.

Devices

GET /api/v1/devices

Your paired phones with online state, battery, SIMs and sending limits.

Verification codes (OTP)

We create the code, send it, and check it. Your app never stores the code.

POST /api/v1/otp
{ "to": "(415) 555-0123", "length": 6, "expires_in": 600 }

# 201
{ "id": 55, "phone": "+14155550123", "status": "pending", "expires_at": "..." }

POST /api/v1/otp/verify
{ "id": 55, "code": "483920" }

# 200
{ "valid": true, "status": "approved" }
messageOptional text with {code}, for example "Your Acme code is {code}".
channelsms (default) or whatsapp, which needs template: an approved authentication template with one body value.
Limits5 wrong tries per code, 5 codes per number per hour, one new code every 30 seconds. Codes skip ahead of bulk campaigns in the phone queue.

Statuses

queuedWaiting for a phone (or for its scheduled time).
dispatchedHanded to a phone or to WhatsApp.
sentLeft the phone or WhatsApp accepted it.
deliveredThe handset confirmed delivery.
readRead by the customer (WhatsApp only).
failedNot delivered; see error.
receivedAn incoming message.

Webhooks

Set a URL in Settings. We POST these events: message.received, message.status, link.clicked (first click on a tracked link) and otp.approved. Each call carries X-NHZ-Event and X-NHZ-Delivery headers. Failed calls retry five times over about 8 hours, and you can see every attempt in Settings.

{
  "event": "message.received",
  "data": { "id": 9130, "channel": "sms", "direction": "in",
            "phone": "+14155550123", "body": "Yes please" },
  "sent_at": "2026-11-20T10:07:00Z"
}

Verify each call: X-NHZ-Signature equals HMAC-SHA256 of the raw body with your webhook secret.

// PHP
$ok = hash_equals(hash_hmac('sha256', file_get_contents('php://input'), $secret),
                  $_SERVER['HTTP_X_NHZ_SIGNATURE'] ?? '');

Limits

120 requests a minute per key. Each phone sends at its own pace (set on the Devices page) to protect the SIM, so large sends queue and go out steadily.