# Webhooks

Get a signed HTTPS call when a sale, customer, product or stock level changes, with retries and a way to catch up.

Source: https://getolet.com/resources/developers/webhooks/
Updated: 2026-11-08

A webhook is a call OLET makes to your server when something changes, so you do not have to poll. You subscribe a URL to one event, and each time that event happens OLET sends a signed `POST` to it. This is what powers instant triggers in tools such as Zapier, Make and n8n.

Changes are picked up by a job that runs every minute, so expect a delivery within about a minute or two of the change.

## What you need

Each event needs the read scope of the resource it is about. A write scope also satisfies its read scope.

| Events | Scope |
| --- | --- |
| `sale.completed`, `sale.refunded` | `sales:read` |
| `customer.created`, `customer.updated`, `customer.deleted` | `customers:read` |
| `product.created`, `product.updated`, `product.deleted` | `catalog:read` |
| `inventory.updated` | `inventory:read` |

Subscribing without the scope answers `403 INSUFFICIENT_SCOPE`. Your OLET plan must also include API access.

## The events

- `sale.completed`: a sale was completed. The data is the sale document.
- `sale.refunded`: a refund was processed. The data is the refund sale document, which points at its parent sale.
- `customer.created`: a customer was created. The data is the customer document, or only the id when the customer has opted out of data sharing.
- `customer.updated`: a customer was changed. Same data rule as `customer.created`.
- `customer.deleted`: a customer was deleted or erased. The data is only the id.
- `product.created`: a product was created. The data is the product document.
- `product.updated`: a product was changed, including its tags, suppliers, variants and components. The data is the product document.
- `product.deleted`: a product was deleted. The data is only the id.
- `inventory.updated`: the stock level of a product at one outlet changed. The data is the stock level with its product id.

## Create, list, get and delete a webhook

Subscribe one URL to one event. The URL must use `https`, be 2000 characters or fewer, carry no username or password, and resolve to a public address.

```bash
curl https://api.oletapp.com/your-store/v1/webhooks \
  -H "Authorization: Bearer olet_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event": "sale.completed", "target_url": "https://example.com/olet-hook"}'
```

```json
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "event": "sale.completed",
    "target_url": "https://example.com/olet-hook",
    "status": "active",
    "created_at": "2026-10-18T09:30:00.000Z",
    "secret": "whsec_..."
  }
}
```

A new webhook answers `201` and carries the signing `secret`. It is shown once. Store it now, because no later call returns it. Asking again for the same event and URL answers `200` with the same `id` and `secret: null`.

You receive only changes that happen after the first webhook for that kind of resource is created. Nothing from before that moment is sent.

| Call | What it does |
| --- | --- |
| `GET /webhooks` | Lists your webhooks, at most 50, in one page. `secret` is `null`. |
| `GET /webhooks/{id}` | Returns one webhook. |
| `DELETE /webhooks/{id}` | Deletes it and its delivery history, and stops further deliveries. Answers `204`. |

A credential sees only its own webhooks. Another credential's id answers `404 NOT_FOUND`. Each credential can hold 50 webhooks.

A URL that is not `https`, is too long, has credentials in it, or points at a private address answers `422 UNPROCESSABLE`, as does the 51st webhook. An event name that does not exist answers `422 VALIDATION_FAILED`. The address is checked again on every delivery.

## What a delivery looks like

OLET sends a `POST` with a JSON body and these headers:

```text
content-type: application/json
user-agent: Olet-Webhooks/1
webhook-id: 00000000-0000-0000-0000-000000000000
webhook-timestamp: 1790000000
webhook-signature: v1,BASE64_SIGNATURE
```

The body is always the same envelope. Only `data` changes with the event.

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "type": "inventory.updated",
  "created_at": "2026-10-18T09:31:12.000Z",
  "truncated": false,
  "data": {
    "product_id": "2489e9ad-2ee2-8e00-8ec9-32d5f69181c0",
    "outlet_id": "ffffffff-ffff-ffff-ffff-ffffffffffff",
    "on_hand": 12,
    "reorder_method": "none",
    "reorder_point": null,
    "reorder_amount": null,
    "reorder_target": null,
    "version": "48213"
  }
}
```

`id` is the event id. It is the same on every retry and for every webhook subscribed to that event, and it matches the `webhook-id` header.

`data` is the same document the matching `GET` call returns, built at the moment of sending. It is the state now, not the state when the event happened. If a product changed twice before the delivery went out, you see the second state.

If `data` would be larger than 256 KiB, it is replaced by `{ "id": "..." }` and `truncated` is `true`. Fetch the resource with its `GET` call when you see that.

## Verify the signature

Every delivery is signed with the [Standard Webhooks](https://www.standardwebhooks.com/) scheme, using the `secret` you received. Verify it before you trust the body. Any Standard Webhooks library works. This example uses `standardwebhooks`.

```js
import express from 'express'
import { Webhook } from 'standardwebhooks'

const app = express()
const wh = new Webhook(process.env.OLET_WEBHOOK_SECRET) // the whsec_ value

app.post('/olet-hook', express.raw({ type: 'application/json' }), (req, res) => {
  let event
  try {
    event = wh.verify(req.body.toString('utf8'), req.headers)
  } catch {
    return res.status(400).end()
  }
  // Hand the event to a queue, then answer quickly.
  res.status(200).end()
})
```

Verify the exact bytes you received, before any JSON parsing. If a framework parses the body and you serialize it again, the signature will not match. Each attempt carries a fresh `webhook-timestamp`, and the libraries reject a timestamp that is several minutes off, so keep your server clock correct.

## Respond and retries

Answer with any `2xx` status within 10 seconds. The response body is ignored.

Anything else is a failure and is tried again. That includes other status codes, a timeout, a failed TLS handshake and a URL that no longer resolves to a public address. A `3xx` is a failure too, because redirects are not followed. Point the webhook at the final URL.

A `429 Too Many Requests` is retried like any other failure, on the same schedule. OLET does not read a `Retry-After` header.

A delivery gets 8 attempts. The times are measured from when the delivery was created, not from the previous attempt:

| Attempt | Time after creation |
| --- | --- |
| 1 | right away |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
| 6 | 6 hours |
| 7 | 12 hours |
| 8 | 24 hours |

Attempts are made by a job that runs every minute, so each can run up to a minute later than the table says. After the eighth failure the delivery is marked failed.

If your server answers `410 Gone`, OLET deletes the webhook at once and stops. Use this to say "unsubscribe me".

A webhook that has gone 3 days without a single `2xx` is turned off, and the account owner is emailed once. To turn it back on, use **Turn back on** in the OLET admin, described below. It resumes from that moment and does not replay what it missed. A successful delivery counts as use of the connection, so a connection that only receives webhooks is not treated as unused while your endpoint keeps answering.

## See and manage webhooks in the OLET admin

Webhooks are created through the API only. The admin shows what a key or app has subscribed to and lets you delete a webhook or turn one back on.

1. Go to **Integrations > API & apps**.
2. Expand the row of the key under **API keys**, or of the app under **Connected apps**.
3. Read its webhooks. Each one shows the event, the target URL, a tag that reads **Active** or **Turned off**, and **Last delivered**.

With no webhooks, the panel reads "No webhooks. Apps you connect create them when you turn on an automation."

Under each webhook is a table of its 20 newest deliveries, with the columns **When**, **Event id**, **Result**, **HTTP code** and **Attempts**. **Result** is **Delivered**, **Retrying**, **Queued**, **Failed** or **Cancelled**. **HTTP code** shows the status your server answered, or a short reason when there was no answer: **Timed out**, **Address not found**, **Address not allowed**, **Invalid address**, **Secure connection failed**, **Could not connect** or **Our error**. For a cancelled delivery the column reads **Paused**, **Turned off**, **Webhook deleted** or **Record deleted**. **Event id** is the first 8 characters of the event id. Times use your store's time zone.

A webhook that was turned off after failing shows "Turned off after 3 days of failed deliveries." To turn it back on, click **Turn back on** on its row. If the key or app is no longer active, this fails and the panel shows an error.

To delete a webhook, click the delete button on its row (it is labeled `Delete webhook` followed by the event name) and confirm with **Delete webhook**. The message reads "The app stops receiving EVENT events." If the target is on `hooks.zapier.com`, we ask Zapier to pause the Zap, see below.

Only store admins can open this page.

## At least once, in no fixed order

OLET delivers at least once, so you can receive the same event twice, and events can arrive out of order.

- Dedupe on `webhook-id` (the same value as the envelope `id`). Keep recent ids and ignore repeats.
- Because `data` is the current state, an old event does not undo a newer one. For `customer.updated`, `product.updated` and `inventory.updated`, compare the `version` inside `data` with the one you stored and ignore the event when it is lower.

## Catch up and get samples

`GET /events` returns recent events in the exact envelope a webhook delivers.

```bash
curl "https://api.oletapp.com/your-store/v1/events?type=sale.completed&limit=50" \
  -H "Authorization: Bearer olet_live_YOUR_API_KEY"
```

| Parameter | Meaning |
| --- | --- |
| `limit` | 1 to 200, default 50. |
| `cursor` | The `next_cursor` from the previous page. |
| `order` | `asc` (default) walks forward. `desc` returns the newest events, first page only, and `next_cursor` is `null`. |
| `type` | One event type. Needs that event's read scope, or `403 INSUFFICIENT_SCOPE`. |

Without `type`, you get only the events your scopes allow. Events and delivery history are kept for 30 days. To catch up after downtime, page forward with `order=asc` and the cursor you saved, and dedupe on `id`. To see a sample payload while you build, call with `order=desc&limit=1`.

An event whose resource has since been removed is left out, so a page can hold fewer items than `limit` while `has_more` is still `true`. Keep following `next_cursor` until `has_more` is `false`.

## Privacy

Customers who have opted out of data sharing, customers who were deleted, and customers who were erased arrive as `{ "id": "..." }` only. The event still fires. A customer who is erased produces `customer.deleted`, and later changes to that customer send nothing. The body of every delivery is built at the moment of sending and never stored, so an erased customer's details are never sent. Sales and products carry a `customer_id` and never customer details.

## Plan changes

While your plan does not include API access, or the account is not active, API calls answer `402`. Webhook events during that time are not delivered, and they are not sent later. When access returns, delivery resumes by itself with no API call needed. Nothing from the gap is replayed, so use `GET /events` to recover it.

A credential with an active webhook never goes idle, so a connection that only receives webhooks keeps working. A webhook that was turned off does not count.

Revoking the API key or connection that created a webhook deletes its webhooks too. So does a key or connection that expires after 90 days idle, which can only happen once none of its webhooks is active.

## When we pause your Zap

When a store admin revokes the key, disconnects the app or deletes the webhook, or when we turn a webhook off after 3 days of failures, and the webhook's URL is on `https://hooks.zapier.com`, we send a `DELETE` request to that URL. Zapier pauses the Zap in response.

This is best effort. We try a few times. If Zapier cannot be reached, the Zap is not paused, and the webhook is still removed.

No other URL ever gets this request. Your own `DELETE /webhooks/{id}` call and a `410` answer from your server do not trigger one.

## When a Make scenario is off

Make has no pause request, so a scenario that is switched off keeps queueing deliveries in Make. When Make's queue is full it answers `400`, the delivery is retried, and after 3 days without a `2xx` the webhook is turned off and the store admin is emailed. Switch the scenario on, then turn the webhook back on under **Integrations > API & apps**, as described above.

## Where to go next

See [pagination and polling](/resources/developers/pagination-and-polling/) for walking a list, [authentication](/resources/developers/authentication/) for scopes, or the full [API reference](/resources/developers/reference/) for the webhook payload schemas.
