# Webhooks

> Get signed Besday webhooks when orders are paid, delivered, completed or cancelled. Event types, payload, HMAC-SHA256 signature check and retry schedule.

Source: https://besday.com/docs/api/webhooks · Updated 2026-12-03 · OpenAPI: https://besday.com/api/v1/openapi.json

Webhooks tell your server when an order changes, so you do not have to poll. Besday sends an HTTPS POST with a JSON event, signed with your endpoint’s secret.

## Set up an endpoint

1. Expose an https URL on your server (port 443) that accepts POST and answers 2xx within 10 seconds.
2. Register it with `POST /v1/webhook_endpoints` and store the `secret` it returns (shown once).
3. Send a test event with `POST /v1/webhook_endpoints/{id}/test` and check that your server verifies it.

## Event types

| Event | Sent when |
|---|---|
| `order.paid` | The order was paid (from credits, or by card for older orders). Sent together with the status event that follows. |
| `order.awaiting_acceptance` | A real creator has the order and must accept it (they have 48 hours). |
| `order.awaiting_product` | The creator accepted and is waiting for the product you ship to them. |
| `order.in_production` | The creator is making the video (status `active`). |
| `order.delivered` | A version of the video was delivered. Review it, then approve or ask for changes. |
| `order.revision_requested` | You asked for changes; the creator is working on them. |
| `order.disputed` | A dispute was opened on the order; Besday support is reviewing it. |
| `order.completed` | The order is complete: approved by you, or automatically after the review window. |
| `order.cancelled` | The order was cancelled (declined, expired, or cancelled with a refund to credits). |
| `ping` | A test event sent by POST /v1/webhook_endpoints/{id}/test. |

## Payload

`data.object` is the order as it was when the event happened, in the same shape as `GET /v1/orders/{id}`; `data.previous_status` is the status before.

```json
{
  "id": "evt_0c1d2e3f4a5b6c7d",
  "object": "event",
  "type": "order.delivered",
  "api_version": "2026-12-03",
  "created_at": "2026-12-06T18:40:00.000Z",
  "data": {
    "object": {
      "object": "order",
      "id": "prj_01HZX8Q4V2",
      "status": "delivered",
      "creator": {
        "id": "cr_7f3a9c21",
        "slug": "maya-w",
        "name": "Maya W.",
        "kind": "real"
      },
      "duration_seconds": 30,
      "aspect_ratio": "9:16",
      "quantity": 1,
      "add_ons": [
        {
          "kind": "captions",
          "quantity": 1,
          "unit_price_credits": 19
        }
      ],
      "price_credits": 168,
      "product_url": "https://yourbrand.com/products/vitamin-c-serum",
      "brief": {
        "goal": "sales",
        "goal_other": null,
        "platforms": [
          "tiktok",
          "instagram_reels"
        ],
        "audience": "Women 25–40 with sensitive skin",
        "key_messages": [
          "Fragrance-free",
          "Visible glow in 2 weeks"
        ],
        "hooks": [
          "I stopped wearing foundation because of this"
        ],
        "must_say": "Use code MAYA15",
        "must_avoid": "Medical claims",
        "call_to_action": "Tap the link to try it",
        "script": null,
        "reference_links": [],
        "anything_else": null
      },
      "note": null,
      "requires_shipping": true,
      "delivery_days": 3,
      "campaign_id": null,
      "paid_at": "2026-12-03T17:03:40.000Z",
      "accept_by": "2026-12-05T17:03:40.000Z",
      "accepted_at": "2026-12-03T19:12:00.000Z",
      "delivery_due_at": "2026-12-07T15:00:00.000Z",
      "delivered_at": "2026-12-06T18:40:00.000Z",
      "approved_at": null,
      "cancelled_at": null,
      "cancellation_reason": null,
      "created_at": "2026-12-03T17:02:11.000Z",
      "updated_at": "2026-12-04T15:00:00.000Z",
      "dashboard_url": "https://besday.com/app/brands/projects/prj_01HZX8Q4V2"
    },
    "previous_status": "active"
  }
}
```

## Request headers

| Header | Value |
|---|---|
| `Besday-Signature` | `t=<unix seconds>,v1=<hex HMAC-SHA256>` |
| `Besday-Event-Id` | The event id (`evt_…`), the same on every retry. |
| `Besday-Event-Type` | The event type. |
| `Content-Type` | `application/json` |
| `User-Agent` | `Besday-Webhooks/1.0` |

## Verify the signature

Compute HMAC-SHA256 of `<t>.<raw body>` with your endpoint secret, compare it in constant time with `v1`, and reject timestamps more than 5 minutes old. Use the raw body bytes, before any JSON parsing.

Node.js:

```javascript
import crypto from "node:crypto";
import express from "express";

const app = express();
app.post("/webhooks/besday", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("Besday-Signature") ?? "";
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto.createHmac("sha256", process.env.BESDAY_WEBHOOK_SECRET)
    .update(`${t}.${req.body}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
  const ok = fresh && v1 && v1.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
  if (!ok) return res.status(400).send("bad signature");
  const event = JSON.parse(req.body);
  // Deliveries are at least once: skip event.id values you have seen.
  console.log(event.type, event.data.object.id);
  res.sendStatus(200);
});
```

Python:

```python
import hashlib, hmac, os, time
from flask import Flask, request, abort

app = Flask(__name__)

@app.post("/webhooks/besday")
def besday_webhook():
    parts = dict(p.split("=", 1) for p in request.headers.get("Besday-Signature", "").split(","))
    t, v1 = parts.get("t", "0"), parts.get("v1", "")
    expected = hmac.new(os.environ["BESDAY_WEBHOOK_SECRET"].encode(),
                        f"{t}.".encode() + request.get_data(), hashlib.sha256).hexdigest()
    if abs(time.time() - int(t)) > 300 or not hmac.compare_digest(expected, v1):
        abort(400)
    event = request.get_json()
    print(event["type"], event["data"]["object"]["id"])
    return "", 200
```

## Retries and ordering

- A delivery that does not get a 2xx within 10 seconds is retried after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h, 24 h: 8 tries in all, then it is marked failed.
- Delivery is at least once: deduplicate on the event `id`.
- Events can arrive out of order; compare `data.object.updated_at`, or fetch the order to read its current status.
- Redirects are not followed. The URL must resolve to public internet addresses.
- Events are written in the same database transaction as the status change, so you never get an event for a change that did not happen.

## Endpoints

### Create a webhook endpoint

`POST /api/v1/webhook_endpoints`

Registers an https URL for order events. The answer includes the signing secret, once.

- Scope: `read_write`
- Returns: 201 `webhook_endpoint`
- Supports `Idempotency-Key`

Body parameters (JSON):

| Name | Type | Required | Description |
|---|---|---|---|
| `url` | string | yes | https URL on port 443 that resolves to public addresses. |
| `events` | string[] | no | Event types to send, or `["*"]` (default) for all: `order.paid`, `order.awaiting_acceptance`, `order.awaiting_product`, `order.in_production`, `order.delivered`, `order.revision_requested`, `order.disputed`, `order.completed`, `order.cancelled`. |
| `description` | string | no | Your label, up to 200 characters. |

cURL:

```bash
curl -X POST "https://besday.com/api/v1/webhook_endpoints" \
  -H "Authorization: Bearer $BESDAY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "url": "https://yourapp.com/webhooks/besday",
  "events": [
    "order.delivered",
    "order.completed",
    "order.cancelled"
  ],
  "description": "Production"
}'
```

Node.js:

```javascript
const res = await fetch("https://besday.com/api/v1/webhook_endpoints", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BESDAY_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "https://yourapp.com/webhooks/besday",
    "events": [
      "order.delivered",
      "order.completed",
      "order.cancelled"
    ],
    "description": "Production"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
```

Python:

```python
import os, uuid, requests

res = requests.post(
    "https://besday.com/api/v1/webhook_endpoints",
    headers={
        "Authorization": f"Bearer {os.environ['BESDAY_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
      "url": "https://yourapp.com/webhooks/besday",
      "events": [
        "order.delivered",
        "order.completed",
        "order.cancelled"
      ],
      "description": "Production"
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
```

Response (201):

```json
{
  "object": "webhook_endpoint",
  "id": "we_3f9d0c8e",
  "url": "https://yourapp.com/webhooks/besday",
  "description": "Production",
  "events": [
    "order.delivered",
    "order.completed",
    "order.cancelled"
  ],
  "created_at": "2026-12-03T17:20:00.000Z",
  "secret": "whsec_Wq3m…(shown once)"
}
```

Errors: `parameter_invalid`, `url_not_allowed`, `limit_reached`.


### List webhook endpoints

`GET /api/v1/webhook_endpoints`

Your brand’s webhook endpoints (secrets are never shown again).

- Scope: `read`
- Returns: 200 a list of `webhook_endpoint` objects

cURL:

```bash
curl "https://besday.com/api/v1/webhook_endpoints" \
  -H "Authorization: Bearer $BESDAY_API_KEY"
```

Node.js:

```javascript
const res = await fetch("https://besday.com/api/v1/webhook_endpoints", {
  headers: {
    Authorization: `Bearer ${process.env.BESDAY_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
```

Python:

```python
import os, uuid, requests

res = requests.get(
    "https://besday.com/api/v1/webhook_endpoints",
    headers={
        "Authorization": f"Bearer {os.environ['BESDAY_API_KEY']}",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
```

Response (200):

```json
{
  "object": "list",
  "data": [
    {
      "object": "webhook_endpoint",
      "id": "we_3f9d0c8e",
      "url": "https://yourapp.com/webhooks/besday",
      "description": "Production",
      "events": [
        "order.delivered",
        "order.completed",
        "order.cancelled"
      ],
      "created_at": "2026-12-03T17:20:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```


### Send a test event

`POST /api/v1/webhook_endpoints/{id}/test`

Sends a signed `ping` event now and reports what your endpoint answered.

- Scope: `read_write`
- Returns: 200 `webhook_test`

Path parameters:

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | The endpoint id. |

cURL:

```bash
curl -X POST "https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e/test" \
  -H "Authorization: Bearer $BESDAY_API_KEY"
```

Node.js:

```javascript
const res = await fetch("https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e/test", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BESDAY_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
```

Python:

```python
import os, uuid, requests

res = requests.post(
    "https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e/test",
    headers={
        "Authorization": f"Bearer {os.environ['BESDAY_API_KEY']}",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
```

Response (200):

```json
{
  "object": "webhook_test",
  "endpoint_id": "we_3f9d0c8e",
  "event_id": "evt_77aa01",
  "delivered": true,
  "status_code": 200,
  "error": null
}
```

Errors: `not_found`.


### Delete a webhook endpoint

`DELETE /api/v1/webhook_endpoints/{id}`

Stops sending events to the endpoint. Pending deliveries to it are dropped.

- Scope: `read_write`
- Returns: 200 `deleted`

Path parameters:

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | The endpoint id. |

cURL:

```bash
curl -X DELETE "https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e" \
  -H "Authorization: Bearer $BESDAY_API_KEY"
```

Node.js:

```javascript
const res = await fetch("https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e", {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.BESDAY_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
```

Python:

```python
import os, uuid, requests

res = requests.delete(
    "https://besday.com/api/v1/webhook_endpoints/we_3f9d0c8e",
    headers={
        "Authorization": f"Bearer {os.environ['BESDAY_API_KEY']}",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
```

Response (200):

```json
{
  "object": "webhook_endpoint",
  "id": "we_3f9d0c8e",
  "deleted": true
}
```

Errors: `not_found`.

