Webhooks
Webhooks
Cartirra posts signed events to your endpoint when orders, payments, refunds, payouts and customers change. Verify, deduplicate, answer fast.
Instead of polling, let Cartirra tell your server when something happens. Add an endpoint under Developers → Webhooks in the dashboard. Each mode (test and live) has one endpoint and its own signing secret (whsec_…).
Events
| Event | Sent when |
|---|---|
order.created | An order is placed (its payment succeeded) |
order.updated | An order's status, payment status or details change |
payment.succeeded | A payment completes |
payment.failed | A payment fails |
payment.expired | A payment window closes unpaid |
refund.succeeded | A refund reaches the shopper |
refund.failed | A refund can't be completed |
payout.paid | A payout lands in your bank account |
payout.failed | A payout fails and the money returns to your balance |
customer.created | A shopper agrees to share their details with you, or a guest places their first order |
customer.updated | A shopper's shared name, email or phone changes |
customer.consent_revoked | A shopper stops sharing their details with you: delete any copies of their email and phone you keep |
bill.opened | Pay at table: a bill is opened for a table |
bill.updated | A bill's total, split or note changes, or money paid outside Cartirra is recorded |
bill.payment_received | A guest's payment toward a bill arrives |
bill.closed | A bill is fully paid, or a manager closes it |
bill.voided | A bill is voided |
order.issue_reported | A shopper reports a problem with an order |
order.issue_updated | A problem report is reviewed, resolved, rejected or withdrawn, or a refund is linked to it |
warranty.created | A warranty is created: from a checkout line when the order is paid, or added afterwards |
warranty.updated | A warranty's serial number, dates or terms change |
warranty.voided | A warranty is voided |
webhook.test | You press Send test event in the dashboard |
The request
Cartirra sends a POST with a JSON body and these headers:
| Header | Value |
|---|---|
Cartirra-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256> |
Cartirra-Event-Id | The event id, evt_… |
Cartirra-Event-Type | For example order.created |
Cartirra-Delivery-Id | This delivery (an event is delivered once per endpoint) |
{
"id": "evt_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b",
"object": "event",
"type": "order.created",
"livemode": false,
"created": "2026-10-24T09:30:00.000Z",
"data": { "object": { "id": "ord_0193a1b2c3d47e5f8a9b0c1d2e3f4a5b", "reference": "ORD-1042" } }
}
data.object is the resource as it was when the event happened. Each event's page in the reference shows its full payload.
Verify the signature
Always verify before trusting a webhook. The signature is an HMAC-SHA256, keyed with your endpoint's whsec_ secret, of the string <t>.<raw request body>.
- Read the raw body exactly as received. Parsing and re-serialising the JSON changes it and breaks the signature.
- Split
Cartirra-Signatureintotandv1. - Reject the request if
tis more than 5 minutes from now (replay protection). - Compute the HMAC and compare it with
v1in constant time.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const secret = process.env.CARTIRRA_WEBHOOK_SECRET; // whsec_…
function verify(rawBody, header, toleranceSeconds = 300) {
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const timestamp = Number(parts.t);
if (!timestamp || Math.abs(Date.now() / 1000 - timestamp) > toleranceSeconds) return false;
const expected = crypto.createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
const given = Buffer.from(parts.v1 ?? '', 'hex');
return given.length === 32 && crypto.timingSafeEqual(given, Buffer.from(expected, 'hex'));
}
app.post('/webhooks/cartirra', express.raw({ type: 'application/json' }), (req, res) => {
if (!verify(req.body.toString('utf8'), req.get('Cartirra-Signature') ?? '')) return res.sendStatus(400);
const event = JSON.parse(req.body.toString('utf8'));
res.sendStatus(200); // answer first, then do the work
queue.add(event); // e.g. fulfil the order in a background job
});
<?php
$secret = getenv('CARTIRRA_WEBHOOK_SECRET'); // whsec_…
$payload = file_get_contents('php://input');
$header = $_SERVER['HTTP_CARTIRRA_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $parts);
$timestamp = (int) ($parts['t'] ?? 0);
$expected = hash_hmac('sha256', $timestamp . '.' . $payload, $secret);
if (!$timestamp || abs(time() - $timestamp) > 300 || !hash_equals($expected, $parts['v1'] ?? '')) {
http_response_code(400);
exit;
}
$event = json_decode($payload, true);
http_response_code(200);
// handle $event['type'] …
Answer quickly
Return any 2xx within 10 seconds. Anything else, including a timeout or a redirect, counts as a failure. Do slow work (sending emails, calling other services) after responding, in a background job.
Retries
A failed delivery is retried up to 8 times with exponential backoff, starting at 10 seconds (10 s, 20 s, 40 s and so on), for about 21 minutes in all. After that the delivery is marked failed and your team gets a dashboard notification. You can resend any event from Developers → Webhooks → Events in the dashboard.
Duplicates and order
- Expect duplicates. A retry can arrive after your server already handled the event (for example if your
2xxwas lost). Store eachidyou've processed and skip repeats. - Don't rely on order. Events can arrive out of order. When the order matters, read the current state from the API, for example
GET /v1/orders/{id}, instead of applying the event's snapshot blindly.
Catch up on missed events
GET /v1/events lists every event for your business and mode, newest first, and GET /v1/events/{id} shows an event with its delivery attempts. Use them to reconcile after an outage on your side.
Security checklist
- Use an
https://URL. Live endpoints can't point at private or local addresses. - Verify every signature, and reject old timestamps.
- Keep the
whsec_secret on your server; rotate it from the dashboard if it leaks. - Treat the payload as a hint, and read amounts and statuses from the API before you act on anything money-related.