Webhooks
Naqllah sends a POST to your app's notification address for every event in a store that installed your app, signed with the webhook secret.
Events and what they need
You receive an event if you chose it in the app form and the merchant granted webhooks.read and the read scope the event requires.
| Event | Requires | Sent when |
|---|---|---|
order.created |
orders.read + webhooks.read |
A new order is created. |
order.paid |
orders.read + webhooks.read |
An order is paid. |
order.shipped |
orders.read + webhooks.read |
An order ships, in full or in part. |
order.cancelled |
orders.read + webhooks.read |
An order is cancelled. |
inventory.adjusted |
products.read + webhooks.read |
Any movement on a product's quantity. |
order.refunded |
orders.read + webhooks.read |
An order was refunded, in full or in part. |
return.created |
orders.read + webhooks.read |
A shopper or the merchant opened a return request. |
order.updated |
orders.read + webhooks.read |
An order's status or payment status changed. |
product.created |
products.read + webhooks.read |
A product was added. |
product.updated |
products.read + webhooks.read |
A product was edited. |
product.deleted |
products.read + webhooks.read |
A product was deleted or archived. |
customer.created |
customers.read + webhooks.read |
A shopper created an account. |
cart.abandoned |
customers.read + webhooks.read |
A consenting customer left a cart. |
app.installed |
Nothing: every app with a notification address | The app is installed on a store. |
app.uninstalled |
Nothing: every app with a notification address | The app is uninstalled. |
app.scopes_updated |
Nothing: every app with a notification address | The merchant approves new scopes. |
shipment.requested |
Nothing: every app with a notification address | The store sent an order to your carrier app for shipping. |
shipment.cancel_requested |
Nothing: every app with a notification address | An order sent to your carrier app went to another carrier or was cancelled. |
return.approved |
Nothing: every app with a notification address | The merchant approved a return of an order your carrier app shipped: book the reverse pickup. |
app.data_redact |
Nothing: every app with a notification address | 48 hours after a store uninstalled your app: delete what you kept about that store and its shoppers within 30 days. |
app.config_updated |
Nothing: every app with a notification address | The merchant changed your app's setup values. |
fulfillment.order.routed |
Nothing: every app with a notification address | The store sent an order to your fulfilment app. |
app.trial_ending |
Nothing: every app with a notification address | A store's free trial of your app ends in three days. |
Payload
The JSON body carries a unique notification id, the event name, the store id, the event time, and its data in data. Its headers:
| Header | Description |
|---|---|
X-TGR-Signature-V2 | The signature to verify: t=<send time>,v1=<HMAC-SHA256 of t, a dot and the body>, made at each attempt. Refuse a t more than 5 minutes from your clock. |
X-TGR-Signature | The older signature: sha256= followed by the HMAC-SHA256 of the body alone, with the webhook secret. Kept for integrations built before the timestamped one. |
X-TGR-Event | The event name. |
X-TGR-Delivery | The notification id, the same value as id in the body. |
X-TGR-Attempt | The attempt number, starting at 1. |
Content-Type | application/json |
{
"id": "6d1f0b2a-7e4c-4a9b-8f3d-2c5e1a9b7d40",
"event": "order.paid",
"tenant_uuid": "9b2f6c1e-4d3a-4f7b-a1c2-5e8d0f9a7b31",
"occurred_at": "2026-11-04T09:15:41+03:00",
"data": {
"order_id": 5521,
"order_number": "NQ-10482",
"status": "processing",
"payment_status": "paid",
"payment_method": "card",
"currency": "SAR",
"total": "489.00",
"items": [
{
"product_id": 318,
"sku": "TS-BLK-M",
"quantity": 2,
"unit_price": "89.00"
}
],
"shipping": {
"city": "الرياض"
},
"created_at": "2026-11-04T09:14:02+03:00",
"paid_at": "2026-11-04T09:15:40+03:00"
}
}
Sent by the Naqllah platform itself on install, uninstall and scope changes, to the same notification address, signed the same way in X-Naqllah-Signature-V2 (and X-Naqllah-Signature) with the event name in X-Naqllah-Event. Retried 4 times, 1 min, 5 min, 30 min apart.
Verifying signatures
Verify every notification before trusting it with X-TGR-Signature-V2, which comes as t=<unix>,v1=<hex>: t is the send time in Unix seconds and v1 the HMAC-SHA256, with the webhook secret, of t, a dot and the body as received. X-TGR-Signature (sha256=<hex>, over the body only) is still sent for integrations built before it.
- Read the raw request body before parsing JSON: any change in spacing or order changes the signature.
- Read t and v1 from the header, then compute HMAC-SHA256 with the webhook secret over t, a dot, and the raw body.
- Compare it with v1 in constant time, and answer 401 if they differ or if t is more than 5 minutes from your clock.
BODY='{"id":"6d1f0b2a-…","event":"order.paid","data":{…}}'
T=$(date +%s)
SIG=$(printf '%s.%s' "$T" "$BODY" | openssl dgst -sha256 -hmac "$NAQLLAH_WEBHOOK_SECRET" | sed 's/^.* //')
curl -X POST "https://your.app/hooks" \
-H "Content-Type: application/json" \
-H "X-TGR-Event: order.paid" \
-H "X-TGR-Signature-V2: t=$T,v1=$SIG" \
--data "$BODY"
<?php
$raw = file_get_contents('php://input');
$header = $_SERVER['HTTP_X_TGR_SIGNATURE_V2'] ?? '';
if (! preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/D', $header, $m) || abs(time() - (int) $m[1]) > 300) {
http_response_code(401); // missing, malformed, or sent more than 5 minutes ago
exit;
}
$expected = hash_hmac('sha256', $m[1] . '.' . $raw, getenv('NAQLLAH_WEBHOOK_SECRET'));
if (! hash_equals($expected, $m[2])) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
if (already_handled($event['id'])) { // the same id again: a retry
http_response_code(200);
exit;
}
handle($event);
http_response_code(200);
import crypto from 'node:crypto';
import express from 'express';
const app = express();
// the raw body: the signature covers the exact bytes sent
app.post('/hooks', express.raw({ type: 'application/json' }), (req, res) => {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(req.get('X-TGR-Signature-V2') || '');
if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return res.sendStatus(401);
const expected = crypto
.createHmac('sha256', process.env.NAQLLAH_WEBHOOK_SECRET)
.update(m[1] + '.')
.update(req.body)
.digest('hex');
if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(m[2]))) return res.sendStatus(401);
const event = JSON.parse(req.body);
if (alreadyHandled(event.id)) return res.sendStatus(200); // a retry
handle(event);
res.sendStatus(200);
});
import hashlib, hmac, os, re, time
from flask import Flask, abort, request
app = Flask(__name__)
@app.post("/hooks")
def hooks():
raw = request.get_data() # the exact bytes sent
m = re.fullmatch(r"t=(\d+),v1=([0-9a-f]{64})", request.headers.get("X-TGR-Signature-V2", ""))
if not m or abs(time.time() - int(m.group(1))) > 300:
abort(401)
expected = hmac.new(
os.environ["NAQLLAH_WEBHOOK_SECRET"].encode(), m.group(1).encode() + b"." + raw, hashlib.sha256
).hexdigest()
if not hmac.compare_digest(expected, m.group(2)):
abort(401)
event = request.get_json()
if already_handled(event["id"]): # a retry
return "", 200
handle(event)
return "", 200
Retries
If your answer is not a 2xx within 5 seconds we send it again: 6 attempts in all, 1 min, 5 min, 30 min, 2 h, 6 h apart, then we stop.
Answer 2xx quickly, then process the event in the background. Redirects (3xx) are not followed, and your response body is not read.
Ordering
Notifications may arrive in a different order from the events, for example when one is retried. Order them by occurred_at, and treat each as a signal rather than the full truth.
- Before acting, read the current state from the API, for example the order itself.
- Ignore a notification older than the state you already have.
Duplicates and idempotency
Every retry carries the same id in the body and in X-TGR-Delivery. Keep the ids you processed, and ignore a notification whose id you know.
- Each store event is sent once per order or movement and event; a retry is the same notification, not a new one.
- The signature covers the whole body, id and time included, so neither can change without verification failing.
- Keep ids for at least 24 hours: the retry window spans several hours.
- Do not reject a notification because
occurred_atis old: a retry carries the original event time. Its t inX-TGR-Signature-V2is the time of that attempt, so a request captured and sent again later fails the 5-minute check.
Checklist for your receiving address
- Read the raw body, verify the timestamped signature in constant time, and refuse a send time more than 5 minutes from your clock.
- Answer 2xx within 5 seconds, then process in the background.
- Store the ids you processed for at least 24 hours, and skip a repeated one.
- Do not depend on the order of arrival.
- Keep the webhook secret on the server, and rotate it if it leaks.
Version v1.0.0 Changelog Service status openapi-v1.json Support