Webhooks

Docs

Webhooks

ShipBill calls your server when something happens — a payment succeeds, an invoice is paid, a subscription renews — with a signed event. Your server checks the signature, and acts.

Add an endpoint

In Settings → Webhook, add your address and choose its events (all, or some). Copy its signing secret (whsec_…) to your server. A profile can have up to ten endpoints in each mode, each with its own events, secret, and delivery log; test-mode events go only to test-mode endpoints. The same is available as /v1/webhook-endpoints.

The address must be public https on port 443. ShipBill doesn't follow redirects, and waits 10 seconds for an answer.

Receive and verify

Node · Express
import express from "express";
import { WebhookSignatureError, webhooks } from "@shipbill/node";

const app = express();

// The raw body, exactly as received: the signature covers these bytes.
app.post("/webhooks/shipbill", express.raw({ type: "application/json" }), async (req, res) => {
  let event;
  try {
    event = webhooks.verify(req.body, req.headers["shipbill-signature"], process.env.SHIPBILL_WEBHOOK_SECRET);
  } catch (error) {
    if (error instanceof WebhookSignatureError) return res.status(400).send(error.message);
    throw error;
  }
  if (await alreadyHandled(event.id)) return res.sendStatus(200); // events can arrive more than once

  if (event.type === "payment.succeeded") {
    const payment = event.data.object;
    await fulfil(payment.reference, payment.line_items); // your order, and what was bought
  }
  await markHandled(event.id);
  res.sendStatus(200);
});
  • Verify the raw body. The signature covers the exact bytes; a body parsed and re-serialised won't match.
  • Answer 2xx quickly. Do slow work after answering, or in a queue.
  • Skip events you've handled. Delivery is at least once: the same id can arrive again.
  • Don't rely on order. Each event carries the whole object as it was, enough to act on alone; the API is the authority if in doubt.

The signature

Each delivery has a ShipBill-Signature header: t=<unix seconds>,v1=<hex>, where v1 is the HMAC-SHA256 of <t>.<raw body> with your signing secret. Refuse a timestamp more than five minutes from now, so a captured delivery can't be replayed.

By hand
# ShipBill-Signature: t=1791105600,v1=310bdaff…
signed  = t + "." + raw_body
expected = hex(HMAC_SHA256(key = signing_secret, message = signed))
accept if expected equals any v1 value (compare in constant time)
       and |now - t| <= 300 seconds

To check your own code, this must verify:

Secretwhsec_test_4eC39HqLyjWDarjtT1zdp7dc
Body{"id":"evt_test","type":"webhook.test"}
Headert=1791105600,v1=310bdaff3676541813a3f3bca3c49012b9bcd5d0c1810de0ed2a8a03b6dd41dc

Other headers: ShipBill-Event-Id (the event's ID), Content-Type: application/json, and User-Agent: ShipBill-Webhooks/1.

The payload

JSON
{
  "id": "evt_…",
  "type": "payment.succeeded",
  "created": 1791105600,
  "livemode": true,
  "api_version": "2026-10-01",
  "data": {
    "object": { "id": "pay_…", "object": "payment", "status": "succeeded", "reference": "order_1001", … }
  }
}

data.object is the payment, checkout session, invoice, or subscription exactly as the API returns it. Every type is in Events. Within an api_version, payloads only gain fields.

Retries

Anything other than a 2xx, or no answer within 10 seconds, is retried: after 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, then every 12 hours — about three days in all. An endpoint that has failed for three days is disabled and the owner is emailed; enable it again on its page.

Testing, replaying, and rotating

  • Send test event on an endpoint's page delivers a webhook.test event to that endpoint.
  • Resend any past event from the delivery log, to the endpoint it went to or another. Test events and resends are one try each and never count towards disabling an endpoint.
  • Rotate secret: for 24 hours both secrets sign each delivery, as two v1 values, so you can update your server without missing anything.

Developing on your own computer

ShipBill never calls private or local addresses, in test mode either. While you develop, either expose your server through an https tunnel and add that address as a test-mode endpoint, or read events instead of receiving them:

Node
// The same handler, fed from the API every few seconds. Events from the API need no signature check.
for await (const event of shipbill.events.list({ created_after: lastSeen })) {
  if (!(await alreadyHandled(event.id))) await handle(event);
}

The same call catches up after downtime: retries last about three days, and GET /v1/events returns everything since a time you give, up to 30 days back: events are kept 30 days.

Last checked against the product on 12 October 2026.

NextTestingTest mode, test payments and what follows them, developing on your own computer, and moving subscriptions through time.