Guides
Webhooks
Add an endpoint
Add 1 in your dashboard under Developers, or with webhooks.create and a key holding the webhooks:write scope. The URL must be public and use https. The response carries the endpoint's signing secret once, so store it with your other secrets. webhooks.test sends a ping to check your receiver.
curl -X POST "https://3commerce.com/api/v1/webhooks" \
-H "Authorization: Bearer 3c_live_…" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/hooks/3commerce", "events": ["order.created", "order.fulfilled"]}'Events
order.created: A shopper paid for an order with your products in it.order.fulfilled: An order of yours shipped, marked by you or by its supplier.order.refunded: Money went back to a shopper for an order, in full or in part.return.requested: A shopper asked to return items from an order.return.updated: A return moved a step: approved, rejected, received, or refunded.product.pulled: A library re-sync took 1 of your products off sale, because its supplier stopped selling it.gift_card.issued: A gift card was issued, by you or by a shopper buying one.discount.redeemed: A shopper paid for an order with 1 of your discount codes.site.published: Your shop site went live, or was taken offline.domain.verified: A custom domain finished verifying and now serves your site.commission.earned: A shopper paid for another shop’s products through your storefront.
What we send
Each event is a POST with a JSON body: an id, the type, when it happened, and its data. Order events carry your share of the order, as Orders returns it, with its lines and shipping address. seller names the storefront that sold it, if 1 did.
{
"id": "1b7f0c2e-…",
"type": "order.created",
"created_at": "2026-11-27T10:12:44.000Z",
"data": {
"order": {
"id": "4f1c2a9e-…",
"number": "3C-104829",
"status": "paid",
"email": "maya.chen@example.com",
"subtotal": 128,
"discount": 12.8,
"discount_code": "WELCOME10",
"shipping": 0,
"shipping_service": "standard",
"tax": 9.22,
"gift_card_amount": 0,
"refunded": 0,
"commission": 12.8,
"net": 103.2,
"currency": "USD",
"shipping_address": { "line1": "…", "city": "…", "countryCode": "US" },
"seller": { "slug": "corner-store", "name": "Corner Store" },
"line_items": [{ "title": "Merino crew sweater", "options": "Size M", "quantity": 1, "unit_price": 128 }]
}
}
}Data by event
| Event | data |
|---|---|
order.created, order.fulfilled | { order }: the order as above. |
order.refunded | { refund: { id, amount }, order }: what just went back, and the order after it. |
discount.redeemed | { discount: { code, amount }, order: { id, number } }: sent beside order.created. |
return.requested, return.updated | { return }: id, order_id, order_number, email, reason, notes, status, response, subtotal, restocking_fee, refund_amount, and when it moved. |
product.pulled | { product: { id, slug, title, status, stock }, reason }: why the re-sync took it off sale. |
gift_card.issued | { gift_card }: id, the code masked to its last 4, amount, currency, source, recipient_email, source_order_number. Sent to the 3Commerce shop, which issues every card. |
site.published | { site: { subdomain, url, published } }: sent when it goes live and when it goes offline. |
domain.verified | { domain, site }: the domain that now serves the site. |
commission.earned | { order_number, amount, currency, shops: [{ order_id, shop, commission }] }: what your storefront earned selling other shops’ products. |
Verify the signature
The 3Commerce-Signature header reads t=1764238364,v1=5f2c…. v1 is the HMAC-SHA256 of the timestamp, a period, and the raw body, keyed with your secret. Compare it in constant time, and refuse an old timestamp, so a recorded event cannot be replayed.
import { createHmac, timingSafeEqual } from 'node:crypto'
// Read the raw body: parsing and re-serializing JSON changes the bytes that were signed.
export function verify(rawBody, header, secret) {
const parts = Object.fromEntries(header.split(',').map((part) => part.split('=')))
const expected = Buffer.from(createHmac('sha256', secret).update(`${parts.t}.${rawBody}`).digest('hex'))
const given = Buffer.from(parts.v1 ?? '')
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300
return fresh && given.length === expected.length && timingSafeEqual(expected, given)
}Retries
Answer with any 2xx within 10 seconds. Anything else, a redirect included, counts as a failure. We try 8 times in all, waiting twice as long each time, over about 11 hours. The same event keeps its id and the 3Commerce-Event-Id header across retries, so you can skip 1 you already handled.