Webhooks guide
A webhook is an https address on your server that Penta Order calls with a signed JSON message whenever an order, dish or customer changes. Answer with any 2xx status within 10 seconds and the event counts as delivered.
Events
| Event | When it is sent |
|---|---|
order.created | An order was placed and paid (or pay later). |
order.accepted | The restaurant accepted the order. |
order.preparing | The kitchen started the order. |
order.ready | Ready for collection or the driver. |
order.out_for_delivery | A driver has the order. |
order.completed | Collected, delivered or served. |
order.cancelled | Cancelled after it was accepted. |
order.rejected | The restaurant turned the order down. |
menu.item.updated | A dish's availability changed. |
customer.created | A customer placed their first order with you. |
Order events carry the whole order in data, in the same shape as GET /v1/api/orders/{orderId}. The “Send test” button sends a ping event.
What a delivery looks like
POST /penta-webhooks HTTP/1.1
Content-Type: application/json
User-Agent: PentaOrder-Webhooks/1.0
Penta-Event: order.created
Penta-Delivery: 5b0e7c1e-…
Penta-Signature: t=1764151200,v1=9f2c…
{
"id": "evt_8c1d…",
"type": "order.created",
"createdAt": "2026-11-26T10:00:00.000Z",
"restaurantId": "…",
"data": {
"id": "…",
"number": 1042,
"state": "placed",
"fulfilment": "collection",
"total": { "amount": 2590, "currency": "GBP" },
"lines": [ { "name": "Lamb Karahi", "quantity": 2, "allergens": ["milk"], … } ],
…
}
}Check the signature
Each endpoint has its own signing secret (whsec_…), shown once when you add the endpoint or make a new one. The Penta-Signature header is t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256 of <t>.<raw body> with the secret. To check it:
- Read the raw request body before any JSON parsing.
- Compute HMAC-SHA256 of
t + "." + bodywith your secret, as hex. - Compare it with v1 in constant time.
- Refuse it if t is more than 5 minutes from your clock, so an old message can't be replayed.
Node.js
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.PENTA_WEBHOOK_SECRET; // whsec_… from Settings > Developers
// Use the raw body: the signature is over the exact bytes we sent.
app.post("/penta-webhooks", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("Penta-Signature") ?? "";
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const t = Number(parts.t);
const expected = crypto
.createHmac("sha256", SECRET)
.update(`${t}.${req.body.toString("utf8")}`)
.digest("hex");
const given = Buffer.from(parts.v1 ?? "", "hex");
const ok =
given.length === 32 &&
crypto.timingSafeEqual(given, Buffer.from(expected, "hex")) &&
Math.abs(Date.now() / 1000 - t) <= 300; // refuse anything older than 5 minutes
if (!ok) return res.status(400).send("Bad signature");
const event = JSON.parse(req.body.toString("utf8"));
// event.id is the same on every retry: skip ones you have already handled.
console.log(event.type, event.data.id);
res.sendStatus(200); // answer within 10 seconds; do slow work afterwards
});
app.listen(3000);PHP
<?php
$secret = getenv('PENTA_WEBHOOK_SECRET'); // whsec_… from Settings > Developers
$body = file_get_contents('php://input'); // the raw body, before any decoding
$header = $_SERVER['HTTP_PENTA_SIGNATURE'] ?? '';
$parts = [];
foreach (explode(',', $header) as $pair) {
[$k, $v] = array_pad(explode('=', $pair, 2), 2, '');
$parts[trim($k)] = trim($v);
}
$t = (int) ($parts['t'] ?? 0);
$expected = hash_hmac('sha256', $t . '.' . $body, $secret);
if (!hash_equals($expected, $parts['v1'] ?? '') || abs(time() - $t) > 300) {
http_response_code(400);
exit('Bad signature');
}
$event = json_decode($body, true);
// $event['id'] is the same on every retry: skip ones you have already handled.
error_log($event['type'] . ' ' . ($event['data']['id'] ?? ''));
http_response_code(200);Retries and turning off
- A delivery that doesn't get a 2xx within 10 seconds is tried again after 1 min, 5 min, 30 min, 1 h, 3 h, 6 h, 12 h: 8 tries in all, over about a day.
- Redirects are not followed. Use the final address.
- The event
idis the same on every retry, and events can arrive more than once or out of order. Store the ids you have handled and usecreatedAtand the order'sstaterather than arrival order. - If 3 events in a row fail every try, the endpoint is turned off and the restaurant owner gets an email. Turn it back on and resend failed events from Settings > Developers, where the delivery log shows every attempt and the status code your server answered.
Addresses we call
Endpoints must be https addresses on the public internet. Local, private-network and cloud metadata addresses are refused when you add them and again each time we connect.
Subscribe from code (REST hooks)
With a key that has webhooks:manage, POST /v1/api/webhooks with { "url": "https://…", "events": ["order.created"] } returns the endpoint's id and secret; DELETE /v1/api/webhooks/{id} removes it. This is how the Zapier app subscribes. See the API reference.