# Data source webhooks

> Send events to a webhook data source so its monitors can turn them into signals, and create one through the API.

A [webhook data source](https://pulso.run/docs/concepts/data-sources.md#webhook) has its own URL. Every event you send to it goes through the filters of each active monitor on that source, and each match creates a signal.

## Endpoint

```http
POST /webhooks/:id/:token
```

Copy the full URL from the **Endpoint URL** field of the data source, or take `url` from [the API](https://pulso.run/docs/api/data-source-webhooks.md#create-a-webhook-source-through-the-api). The token in the path is the only credential, so keep the URL secret. No API key is needed.

## Request

Send a JSON object, form fields (`application/x-www-form-urlencoded`) or `multipart/form-data`. The body can be up to 1 MiB (1,048,576 bytes). An empty body is accepted and stored as an empty object.

```bash
curl -X POST "https://pulso.run/webhooks/<id>/<token>" \
  -H "Content-Type: application/json" \
  -d '{"event": "refund.created", "refund": {"id": "re_123", "amount": 40, "reason": null}, "customer": {"email": "ana@example.com"}}'
```

Monitors see the event as one row. Nested objects are flattened with dots, so the example above gives these columns:

| Column | Value |
|---|---|
| `event` | `refund.created` |
| `refund.id` | `re_123` |
| `refund.amount` | `40` |
| `refund.reason` | `null` |
| `customer.email` | `ana@example.com` |

Use those column names in the monitor's filters, uniq by columns and playbook, for example `{{signal.customer.email}}`.

## Responses

`201 Created`: the event was stored and is being processed.

```json
{
  "success": true,
  "event_id": "01JD8Q4Z0Y3M2K7V5N6T9W1XRA",
  "received_at": "2026-11-20T09:15:02Z"
}
```

`202 Accepted`: the request came from a Pulso outgoing webhook (it carries the `X-Pulso-Webhook-Event` header) and was ignored, so signals don't loop between accounts.

```json
{ "ignored": true, "reason": "sent by an outgoing webhook" }
```

Errors:

| Status | Body | When |
|---|---|---|
| `400` | `{"error": "Invalid JSON payload: …"}` | The body isn't valid JSON, or it repeats a key. |
| `400` | `{"error": "The body must be a JSON object"}` | The body is a JSON list or a bare value. |
| `404` | `{"error": "Webhook endpoint not found"}` | The id or the token is wrong, or the data source isn't a webhook. |
| `413` | `{"error": "Payload too large (at most 1048576 bytes)"}` | The body is over 1 MiB. |

## See what arrived

The data source page shows its **Recent events** as they arrive. If an event doesn't create a signal, check that the monitor is active and that its filters match the flattened column names.

## Create a webhook source through the API

```bash
curl -X POST https://pulso.run/api/v1/webhook_sources \
  -H "Authorization: Bearer ak_..." -H "Content-Type: application/json" \
  -d '{"name": "Refunds"}'
```

Answers `201` with `{ "webhook_source": … }`:

```json
{
  "webhook_source": {
    "id": "01M7ZJ3DXSQ8YS1EHDA656QNDK",
    "name": "Refunds",
    "url": "https://pulso.run/webhooks/01M7ZJ3DXSQ8YS1EHDA656QNDK/…",
    "last_event_at": null,
    "monitors": [],
    "updated_at": "2026-11-20T09:14:02Z"
  }
}
```

`GET /api/v1/webhook_sources/:id` reads it, and `PATCH /api/v1/webhook_sources/:id` with `name` renames it; the URL stays the same. Creating and renaming need `data_sources:write` and an admin, and are in the data source's audit log; reading needs `data_sources:list`.

`url` is the only credential, so it comes only to admins through a key or connection with `data_sources:write`. `last_event_at` says when it last got an event, to check the sending system reaches it. `monitors`, with `monitors:read`, are those on it, with the fields each reads.

To turn the events into signals, [create a monitor](https://pulso.run/docs/api/monitors.md#create-a-monitor) with the source as `data_source_id` and the fields that tell events apart as `row_identifiers`.

## With an assistant

> **You:** Our shop should tell Pulso about each refund. Open a signal for those over 500 €.
>
> **Assistant:** *calls `create_webhook_source`*
> I created **Refunds**. Have the shop post each refund as JSON to <https://pulso.run/webhooks/…>; keep that URL secret.
>
> *calls `list_categories`, `create_monitor` and `replace_monitor_playbook`*
> And **Big refunds**, on that source, raising a signal per `refund.id` when `refund.amount` is over 500. It's inactive. Activate it?
