Webhooks deliver commerce events to systems you control. EdgeCart writes events to the outbox in the same transaction as the change, and the outbox Worker delivers them asynchronously.
Create an endpoint
Use the Admin API:
POST /api/webhook-endpoints
Content-Type: application/json
{
"url": "https://example.com/hooks/edgecart",
"events": ["order.created", "payment.captured"]
}Use exact event names, or ["*"] for all events. Patterns such as order.* are
not supported.
Rotate the signing secret with:
POST /api/webhook-endpoints/:id/rotate-secretInspect delivery attempts with GET /api/webhook-deliveries.
Verify the signature
Each delivery carries:
x-edgecart-signature: t=<timestamp>,v1=<hmac>The HMAC is SHA-256 over <timestamp>.<raw body>. Use the raw request body, not
a parsed and re-serialized object.
import { createHmac, timingSafeEqual } from "node:crypto";
function verify(rawBody: string, header: string, secret: string) {
const parts = Object.fromEntries(
header.split(",").map((part) => part.split("=") as [string, string]),
);
const expected = createHmac("sha256", secret)
.update(`${parts.t}.${rawBody}`)
.digest("hex");
return timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}In a Worker, use crypto.subtle.importKey and crypto.subtle.sign instead.
Retries and deactivation
- Delivery is at least once. Deduplicate by event ID in the payload.
- Failed deliveries retry with backoff. The queue retries five times before the dead-letter queue.
- A
410 Goneresponse deactivates the endpoint. - Return a 2xx quickly; do slow work asynchronously.
Events
EdgeCart emits events for orders, payments, fulfillments, order changes, and
promotion/campaign changes. Plugin async hooks (order:created, order:paid,
order:fulfilled, order:cancelled, refund:created) use the same outbox.
See the event catalog for the full list, and the Observability module for the delivery model.