Developer docs

Webhooks

Get told when something changes

Naamaa calls your URL when an order, a payment or stock changes. Deliveries follow the Standard Webhooks format and are signed, so you can check that they really come from Naamaa.

Add an endpoint

  1. Open API & MCP (AI) in the enterprise portal and go to Webhooks.
  2. Add the HTTPS URL of your server (plain http is refused) and choose the events you want.
  3. Choose live or sandbox. Live events go only to live endpoints, sandbox events only to sandbox endpoints.
  4. Copy the signing secret (whsec_…). It is shown once. Use Send test event to try your receiver.
  1. 1Order changescommitted first
  2. 2Signed POSTwebhook-id · timestamp · signature
  3. 3Your server verifiesHMAC-SHA256, 5 min window
  4. 42xx in 10 selse retried for ~24 h
One event, from your order to your server.
Webhook endpoints and their delivery log.
Webhook endpoints and their delivery log.

What we send

A POST with a JSON body and these headers.

Headers
POST /your/webhook HTTP/1.1
Content-Type: application/json
User-Agent: Naamaa-Webhooks/1
webhook-id: 7c1f3b0e-5b0e-4d6e-9a53-1c2d3e4f5a6b
webhook-timestamp: 1796186700
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2/d+B5V4nFZ0tQs=
Body
{
  "type": "order.status_changed",
  "id": "9d2b7a30-77a4-4a0e-8d0e-3f0f1b0c2a11",
  "createdAt": "2026-12-02T10:15:00+05:30",
  "businessId": "…",
  "mode": "live",
  "data": {
    "order": {
      "id": "…",
      "orderNumber": "…",
      "status": "DELIVERED",
      "previousStatus": "OUT_FOR_DELIVERY",
      "channel": "API",
      "total": 450.0
    }
  }
}

Events

Choose any of these eight for each endpoint.

type
order.createdA new order was placed.
order.status_changedAn order moved to a new status; the data carries previousStatus.
order.cancelledAn order was cancelled.
payment.succeededA payment was confirmed by the gateway.
payment.failedA payment failed.
payment.link_expiredA payment link expired unpaid.
inventory.low_stockStock fell to the low-stock level.
inventory.out_of_stockStock reached zero.

data uses the same shapes as the REST API. Customer phone, email and address are included only if your business type allows customers:read.

Verify the signature

Check every delivery before you trust it. The signature is an HMAC-SHA256 over three values joined by dots.

  1. Read the raw request body as bytes, before any JSON parsing. Parsing and re-serialising changes it.
  2. Build the signed text: {webhook-id}.{webhook-timestamp}.{body}.
  3. The key is the signing secret without the whsec_ prefix, decoded from base64.
  4. Compute HMAC-SHA256, encode it as base64, and compare it to each value in webhook-signature that starts with v1,. There can be two values while a secret is being rotated. Compare in constant time.
  5. Reject the delivery if webhook-timestamp is more than 5 minutes from your clock.
import crypto from 'node:crypto';

/** rawBody: the exact request body as a string. headers: lower-case header names. */
export function verifyNaamaaWebhook(rawBody, headers, secret /* whsec_… */) {
  const id = headers['webhook-id'];
  const timestamp = headers['webhook-timestamp'];
  const signatures = headers['webhook-signature'];
  if (!id || !timestamp || !signatures) throw new Error('Missing webhook headers');

  // Reject anything more than 5 minutes from now (replays).
  const sent = Number(timestamp);
  if (!Number.isFinite(sent) || Math.abs(Date.now() / 1000 - sent) > 300) {
    throw new Error('Timestamp outside the 5 minute window');
  }

  const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64');
  const expected = crypto.createHmac('sha256', key).update(`${id}.${timestamp}.${rawBody}`).digest();

  // "v1,<base64> v1,<base64>": two values while a secret is being rotated.
  for (const part of signatures.split(' ')) {
    const [version, sig] = part.split(',');
    if (version !== 'v1' || !sig) continue;
    const given = Buffer.from(sig, 'base64');
    if (given.length === expected.length && crypto.timingSafeEqual(given, expected)) {
      return JSON.parse(rawBody);
    }
  }
  throw new Error('Signature does not match');
}

// Express: keep the body raw for this route
//   app.post('/webhook', express.raw({ type: 'application/json' }), (req, res) => {
//     const event = verifyNaamaaWebhook(req.body.toString('utf8'), req.headers, process.env.NAAMAA_WEBHOOK_SECRET);
//     res.sendStatus(200);
//   });

Official libraries

You can use the official Standard Webhooks libraries instead (JavaScript, Python, PHP, Go, Ruby, Java, C#, Rust and more), listed at github.com/standard-webhooks/standard-webhooks. Pass them the whole whsec_… secret and the three headers.

Replying and retries

Answer with any 2xx status within 10 seconds. Do your slow work after replying.

Anything else, or no answer, is retried after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours: about 24 hours in all.

A delivery can arrive more than once. Use webhook-id to ignore a repeat.

An endpoint that fails every attempt for 3 days is switched off and the owner is told. The portal shows each delivery and lets you resend one.