تخطَّ إلى المحتوى الرئيسي

Webhooks

Events, signatures and retries.

You receive a POST with a JSON body for every event you subscribed to. OAuth apps pick their events on the app page; business API keys create subscriptions through /webhooks with webhooks:manage.

EventScopeWhen
pos.order.paidorders:read + customers:readA point-of-sale sale was paid
pos.order.refundedorders:read + customers:readA point-of-sale refund
growth.invoice.paidinvoices:read + customers:readAn invoice was paid
growth.contact.createdcustomers:readA new customer
growth.loyalty.stamp / .points / .reward_readyloyalty:read + customers:readLoyalty stamp, points, reward ready
growth.ecommerce.ordersales_orders:read + customers:readAn online store order
reservation.created / .cancelled / .seatedreservations:readA table booking created, cancelled or seated
review.submittedreviews:readA customer submitted a review after a visit
invoice.postedinvoices:readA customer invoice was posted
bill.postedvendor_bills:readA vendor bill was posted
installment.dueinvoices:readAn instalment fell due
manufacturing.donemanufacturing:readA manufacturing order was completed
delivery.assigned / .picked_up / .arrived / .delivered / .faileddeliveries:readA delivery trip assigned, picked up, arrived, delivered or failed
growth.package.sold / .renewed / .low / .expiringcustomers:readA package sold, renewed, running low or expiring
app.uninstalled—Your app was uninstalled or suspended (apps only)
POST /your/endpoint
x-pos-event: reservation.created
x-pos-delivery: evt_reservation_created_2c41d0a9f3_118.wh_…
x-pos-timestamp: 1763372400
x-pos-signature-256: sha256=5d1c…

{
  "id": "evt_reservation_created_2c41d0a9f3_118",
  "event": "reservation.created",
  "createdAt": "2026-11-17T10:00:00.000Z",
  "data": { "reservation_id": 118, "state": "confirmed", "start": "2026-11-20T17:00:00Z", "party_size": 4, "source": "website", "branch_id": 1 }
}

Verify the signature first

The signature is HMAC-SHA256 with the subscription secret over the timestamp, a dot, then the body exactly as received. Refuse anything more than 300 seconds old and compare in constant time.

Node.js
import { createHmac, timingSafeEqual } from "node:crypto";

// rawBody: the request body as received (a Buffer or string), BEFORE JSON.parse.
export function verifyCortexWebhook(rawBody, headers, secret) {
  const timestamp = headers["x-pos-timestamp"];
  const signature = headers["x-pos-signature-256"] ?? "";
  const age = Math.abs(Date.now() / 1000 - Number(timestamp));
  if (!timestamp || !Number.isFinite(age) || age > 300) return false;
  const expected = "sha256=" + createHmac("sha256", secret)
    .update(`${timestamp}.${rawBody}`)
    .digest("hex");
  const a = Buffer.from(signature);
  const b = Buffer.from(expected);
  return a.length === b.length && timingSafeEqual(a, b);
}
Python
import hashlib, hmac, time

def verify_cortex_webhook(raw_body: bytes, headers: dict, secret: str) -> bool:
    timestamp = headers.get("x-pos-timestamp", "")
    signature = headers.get("x-pos-signature-256", "")
    try:
        if abs(time.time() - int(timestamp)) > 300:
            return False
    except ValueError:
        return False
    signed = timestamp.encode() + b"." + raw_body
    expected = "sha256=" + hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(signature, expected)

Delivery and retries

  • Any 2xx acknowledges. Anything else is retried after 1 minute, 5 minutes, 25 minutes, 2 hours, then 10 hours.
  • The same event may arrive twice. The id in the body is stable for an event: drop the ones you have seen.
  • Answer fast, then process in the background.
  • Booking and review events arrive within about two minutes and carry no customer name or phone: read the details from /reservations/{id} or /reviews/{id} with the matching scope.