# Webhooks

> NinjaBuy Business events, their payloads, signature verification and retries.

Source: https://www.ninjabuy.com/business/docs/webhooks

We POST an event to your server when an order reaches us from your store, when auto-buy pays for it, buys it or stops on it, when it is cancelled or ships, and when we change a listing we keep in sync, so you never have to poll. Signed, and retried for about a day.

## Set up an endpoint

1. Add an https route to your server that reads the raw body and answers `2xx` within 10 seconds. Do the work after answering.
2. Add it on your Business account's [Webhooks page](https://www.ninjabuy.com/business/developers/webhooks) and pick its events. Store the `whsec_` secret it shows: it is shown once.
3. Verify every request (below), then deduplicate on the event `id`.
4. Send yourself a test event of each type you handle, from the same page.

- The API is open on request. Our team sets up your Business account and issues its API keys.

  [Contact sales](https://www.ninjabuy.com/business#contact)

## Where an endpoint can point

- An https URL on the public internet. A private, loopback or link-local address in the URL is refused when you save it, and every time we connect we refuse a host name that resolves to one.
- No user name or password in the URL: the signature is how you know a request is ours.
- Redirects are not followed: answer at the URL itself.
- Up to 16 endpoints per account, each with its own events and secret.

## The event

Every event has the same envelope. data holds the type's own fields.

- `id` string

  Starts evt\_. The same on every retry and resend, and in the webhook-id header.

- `type` string

  One of the events below.

- `api_version` string

  The version data is written in. There is one so far, 2026-11.

- `created_at` string

  When it happened, which can be before you receive it.

- `test` boolean

  true for test events.

- `data` object

  What happened, and the ids to find it by.

A delivery

```
POST /hooks/ninjabuy HTTP/1.1Host: acme-goods.comContent-Type: application/jsonUser-Agent: NinjaBuy-Webhooks/1.0webhook-id: evt_k4m2x6z8b0d2f4h6j8l0n2p4r6t8v0x2webhook-timestamp: 1793685600webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=​{  "id": "evt_k4m2x6z8b0d2f4h6j8l0n2p4r6t8v0x2",  "type": "order.shipped",  "api_version": "2026-11",  "created_at": "2026-11-03T06:00:00Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "shipment": "j97a4c6e8g0i2k4m6o8q0s2u4w6y8a0c",    "tracking": [      {        "number": "YT2630812345678",        "url": "https://t.17track.net/en#nums=YT2630812345678"      }    ],    "carrier": "Other"  }}
```

Every order event names the order the same way:

- `order` string

  Our id for the order; for an order you sent with the API, the ord\_ id it answered.

- `source` string

  ebay, shopify, or api for an order you sent with the API.

- `external_id` string

  The order's own id where it was sold: eBay's order id, the Shopify order's gid, or the external\_id you sent.

- `name` string|null

  Shopify's order name, like #1001; null for eBay and the API.

- `store` string|null

  The Shopify store's domain, your eBay username, or the connected WooCommerce site that sent an API order; null for an API order sent with a key you made yourself.

Listing events come from your eBay listings and from the products you pushed to your Shopify store, kept by the same sync rules, and name the listing the same way:

- `listing` string

  Our id for the listing we keep in sync.

- `channel` string

  ebay for a listing on your eBay account, shopify for a variant we pushed to your store.

- `store` string|null

  Your eBay username, or the Shopify store's domain.

- `channel_listing_id` string|null

  eBay's listing id (null until it is published), or the Shopify variant's gid.

- `sku` string

  The SKU on the marketplace.

- `title` string|null

  The listing's title, when we have it.

- `source` object

  The NinjaBuy product and variant it is bought as.

- `reason` string

  The sync's own sentence for the change.

## Events

### order.created

An order reached us from your eBay account or Shopify store. status is accepted when every line is a NinjaBuy listing, unmapped when one is not (reason names it), or cancelled when eBay had cancelled it before we read it. A Shopify order refused for an unmapped line and sent again sends this again.

order.created

```json
{  "id": "evt_k1a7c3e5g7i9k1m3o5q7s9u1w3y5a7c9",  "type": "order.created",  "api_version": "2026-11",  "created_at": "2026-11-01T09:14:02Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "status": "accepted",    "reason": null,    "lines": [      {        "sku": "680512345678-5187209554",        "title": "Clear MagSafe case for iPhone 16",        "quantity": 1,        "mapped": true      }    ]  }}
```

### order.paid

Auto-buy paid for an order from your NinjaBuy balance. paid\_for is goods when it bought the order's items, and shipping when it paid for the parcel to your buyer once they reached our warehouse; amount is what left your balance, in CNY. ninjabuy\_order and ninjabuy\_order\_number are the NinjaBuy order it paid.

order.paid

```json
{  "id": "evt_k1b8d4f6h8j0l2n4p6r8t0v2x4z6b8d1",  "type": "order.paid",  "api_version": "2026-11",  "created_at": "2026-11-01T09:14:05Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "ninjabuy_order": "m57c1q8r3s9t2v5w7x0y4z6a8b1c3d5e",    "ninjabuy_order_number": 10482,    "paid_for": "goods",    "amount": { "amount": "126.68", "currency": "CNY" }  }}
```

### order.bought

We paid the supplier for every item of an order auto-buy paid for, so the goods are on their way to our warehouse.

order.bought

```json
{  "id": "evt_k1c9e5g7i9k1m3o5q7s9u1w3y5a7c9e2",  "type": "order.bought",  "api_version": "2026-11",  "created_at": "2026-11-01T15:30:00Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "ninjabuy_order": "m57c1q8r3s9t2v5w7x0y4z6a8b1c3d5e",    "ninjabuy_order_number": 10482  }}
```

### order.held

Auto-buy stopped on an order and waits for you. hold is funds when your balance is shortfall short (a top-up carries on by itself), margin when today's cost would break your minimum margin, or blocked when something waiting can't fix stopped it (code says what). step says whether it stopped buying the goods or paying for the parcel. Sent once per stop.

order.held

```json
{  "id": "evt_k1d0f6h8j0l2n4p6r8t0v2x4z6b8d0f3",  "type": "order.held",  "api_version": "2026-11",  "created_at": "2026-11-01T09:20:11Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "hold": "funds",    "step": "buy",    "code": "INSUFFICIENT_FUNDS",    "reason": "Your balance cannot cover this payment.",    "shortfall": { "amount": "31.76", "currency": "CNY" }  }}
```

### order.cancelled

The buyer's marketplace cancelled an order before it shipped.

order.cancelled

```json
{  "id": "evt_k2b8d4f6h8j0l2n4p6r8t0v2x4z6b8d0",  "type": "order.cancelled",  "api_version": "2026-11",  "created_at": "2026-11-01T10:02:40Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods"  }}
```

### order.shipped

The parcel's tracking is on the order in your eBay account or Shopify store, which tells your buyer. carrier is the carrier code we gave eBay; null for Shopify, which reads the carrier from the tracking link.

order.shipped

```json
{  "id": "evt_k4m2x6z8b0d2f4h6j8l0n2p4r6t8v0x2",  "type": "order.shipped",  "api_version": "2026-11",  "created_at": "2026-11-03T06:00:00Z",  "test": false,  "data": {    "order": "k17f3c0b6v9wq2y0t4x8m1n5h7ab2c3d",    "source": "ebay",    "external_id": "12-11832-45907",    "name": null,    "store": "acme_goods",    "shipment": "j97a4c6e8g0i2k4m6o8q0s2u4w6y8a0c",    "tracking": [      {        "number": "YT2630812345678",        "url": "https://t.17track.net/en#nums=YT2630812345678"      }    ],    "carrier": "Other"  }}
```

### product.cost\_changed

The landed cost of a listing we keep in sync moved: the seller's price, or our shipping rate. If your sync rules changed the price or paused the listing, that follows as its own event (product.repriced, product.paused); if they kept the price, nothing follows.

product.cost\_changed

```json
{  "id": "evt_k8q0d2f4h6j8l0n2p4r6t8v0x2z4b6d8",  "type": "product.cost_changed",  "api_version": "2026-11",  "created_at": "2026-11-04T02:10:00Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "cost": {      "from": { "amount": "9.40", "currency": "USD" },      "to": { "amount": "10.36", "currency": "USD" }    },    "reason": "The landed cost changed at the seller."  }}
```

### product.repriced

We changed the listing's price on the marketplace, by your sync rules.

product.repriced

```json
{  "id": "evt_k8q1e3g5i7k9m1o3q5s7u9w1y3a5c7e9",  "type": "product.repriced",  "api_version": "2026-11",  "created_at": "2026-11-04T02:10:00Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "price": {      "from": { "amount": "18.99", "currency": "USD" },      "to": { "amount": "20.99", "currency": "USD" }    },    "reason": "The cost rose 10.2%, within your 20% limit: repriced to keep your markup."  }}
```

### product.out\_of\_stock

The seller sold out, or dropped the variant, and your rules set the listing's stock to 0 without pausing it. There is no event for a restock yet.

product.out\_of\_stock

```json
{  "id": "evt_k2b9n1p3r5t7v9x1z3b5d7f9h1j3l5n7",  "type": "product.out_of_stock",  "api_version": "2026-11",  "created_at": "2026-11-04T02:11:30Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "quantity": { "from": 12, "to": 0 },    "reason": "The seller sold out."  }}
```

### product.paused

We paused the listing: we stop keeping it in sync until you resume it. paused\_reason says why. For cost\_rise, margin\_floor, sold\_out, variant\_gone and listing\_gone we set its stock to 0 at its old price; reconnect, ebay\_refused and shopify\_refused mean the marketplace refused our update, so the listing there is as it was.

product.paused

```json
{  "id": "evt_k3c0o2q4s6u8w0y2a4c6e8g0i2k4m6o8",  "type": "product.paused",  "api_version": "2026-11",  "created_at": "2026-11-04T02:12:10Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "paused_reason": "cost_rise",    "reason": "The cost rose 31.0%, over your 20% limit. Resume it to reprice and keep your markup."  }}
```

### product.resumed

A paused or removed listing is active again: you resumed it, listed or pushed it again, or your store let us update it again.

product.resumed

```json
{  "id": "evt_k5e2q4s6u8w0y2a4c6e8g0i2k4m6o8q0",  "type": "product.resumed",  "api_version": "2026-11",  "created_at": "2026-11-04T08:40:00Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "reason": "You resumed it."  }}
```

### product.removed

The marketplace no longer has the listing, so we stopped syncing it.

product.removed

```json
{  "id": "evt_k6f3r5t7v9x1z3b5d7f9h1j3l5n7p9r1",  "type": "product.removed",  "api_version": "2026-11",  "created_at": "2026-11-05T01:00:00Z",  "test": false,  "data": {    "listing": "k57d2m9q4r8s1t6v3w0x5y7z2a4b6c8e",    "channel": "ebay",    "store": "acme_goods",    "channel_listing_id": "110591533867",    "sku": "680512345678-5187209554",    "title": "Clear MagSafe case for iPhone 16",    "source": { "product": "680512345678", "sku_id": "5187209554" },    "reason": "eBay no longer has this listing: The offer is not available."  }}
```

### Coming soon

These follow once we tell you about the check of your items at our warehouse. You can't subscribe to them yet.

- order.checked: An order's items reached our warehouse and were checked, with their photos.
- qc.issue: Our check found a problem with an item and waits for your choice.

## Signatures

Deliveries are signed the [Standard Webhooks](https://www.standardwebhooks.com/) way, so a library you may already use verifies them. Three headers come with every delivery:

| Header            | What it holds                                                                                                                                                                                                                                               |
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| webhook-id        | The event id.                                                                                                                                                                                                                                               |
| webhook-timestamp | When we sent this attempt, in Unix seconds.                                                                                                                                                                                                                 |
| webhook-signature | v1, then a comma and the base64 HMAC-SHA256 of id.timestamp.body under your secret. For 24 hours after you rotate the secret, two of them, separated by a space: one under each secret. Rotating again within those 24 hours retires the older one at once. |

The key is your secret after `whsec_`, base64-decoded. Sign the raw body exactly as it arrived; refuse a timestamp more than five minutes off, so a captured request cannot be replayed.

## Verify a delivery

With the standardwebhooks library, or in a few lines of your own:

```js
// npm install standardwebhooks expressimport express from "express"import { Webhook } from "standardwebhooks"​const webhook = new Webhook(process.env.NINJABUY_WEBHOOK_SECRET) // whsec_...const app = express()​// The raw body: a parsed and re-serialised body no longer matches.app.post("/hooks/ninjabuy", express.raw({ type: "application/json" }), (req, res) => {  let event  try {    event = webhook.verify(req.body.toString("utf8"), req.headers)  } catch {    return res.sendStatus(400)  }  res.sendStatus(204) // answer first, then do the work  queue.push(event) // deduplicate on event.id: a retry repeats it})
```

## Retries and order

Anything but a `2xx` within 10 seconds is a failure, and we try again, 8 attempts in all, each with the same webhook-id and a new timestamp and signature:

| Attempt | After the one before |
| ------- | -------------------- |
| 1       | At once              |
| 2       | 5 seconds            |
| 3       | 5 minutes            |
| 4       | 30 minutes           |
| 5       | 2 hours              |
| 6       | 5 hours              |
| 7       | 10 hours             |
| 8       | 10 hours, the last   |

- After the last attempt the delivery is failed. Resend it from the endpoint's recent deliveries on the Webhooks page (the 25 newest): the same event, sent at once, one at a time per delivery and at most 5 tests and resends waiting per account. Turning the endpoint off and on again resends every failed delivery of the last 3 days.
- A test event is sent once and never retried.
- An endpoint whose deliveries kept failing for 5 days, none delivered, is turned off, and we email you. A delivered test event, a new URL or a day without a failure starts that count over. Turning it back on sends what it missed in the last 3 days.
- We keep each event and every attempt to deliver it, with your server's answer, for at least 30 days; older ones are deleted as new events arrive.
- Events can arrive twice and out of order. Deduplicate on id, and when order matters, look the order or listing up and trust what it says now rather than the event.
