> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sahlfinancial.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhook endpoints

> Create, list, test and delete webhook endpoints with an API key, see every event you can subscribe to, and verify the signature.

You can manage your webhook endpoints from your own backend, with an API key, without anyone signing in to the console. Open to every plan. Scope for every call below: `webhooks:manage`. Each key is limited to 60 calls a minute on these routes.

| Endpoint | Does |
| - | - |
| `GET /v1/partner/webhooks/events` | Lists every event name an endpoint can subscribe to. |
| `GET /v1/partner/webhooks` | Lists your endpoints, newest first. |
| `POST /v1/partner/webhooks` | Registers an endpoint. Answers 201. |
| `DELETE /v1/partner/webhooks/{endpoint_id}` | Removes an endpoint. Answers 204. |
| `POST /v1/partner/webhooks/{endpoint_id}/test` | Sends a signed `test.ping` and shows your server's reply. |
| `GET /v1/partner/webhook-deliveries` | The delivery log, newest first. |
| `GET /v1/partner/webhook-deliveries/summary` | Outcomes over the last 24 hours and 7 days. |
| `GET /v1/partner/webhook-deliveries/{delivery_id}` | One delivery: payload, attempts, last answer. |
| `POST /v1/partner/webhook-deliveries/{delivery_id}/replay` | Sends it again now. |

All routes act on the workspace of the key and never on one named by the caller. Another workspace's endpoint id answers 404 `not_found`. The console's own `/v1/webhooks` routes need a signed-in admin and are separate: they are in the [Console API](https://docs.sahlfinancial.com/console-api/overview.md).

> [!NOTE]
>
> There is no route to edit an endpoint with a key. To change its URL or events, delete it and create a new one, or use the console.

## Events

`GET /v1/partner/webhooks/events` returns the list below, as a JSON array of strings.

| Event | Sent when | Guide |
| - | - | - |
| `kyc.documents_read` | `POST /v1/kyc/extract` with a `reference` finishes. | [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md) |
| `kyc.case_verified` | `POST /v1/kyc/verify` with a `reference` finishes. | [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md) |
| `kyc.case_assessed` | `POST /v1/kyc/assess` with a `reference` finishes. | [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md) |
| `kyc.eid_completed` | The first `GET /v1/kyc/eid/{key}` that sees a finished check. | [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md) |
| `kyb.completed` | After each `POST /v1/kyb/ma/onboard`. | [KYB Morocco](https://docs.sahlfinancial.com/guides/kyb-morocco.md#webhooks) |
| `ice.checked` | After each `POST /v1/kyb/ma/ice-check`. | [KYB Morocco](https://docs.sahlfinancial.com/guides/kyb-morocco.md#webhooks) |
| `statement.extracted` | A queued statement (more than 6 pages) has been read or has failed. | [Bank statements](https://docs.sahlfinancial.com/guides/statements.md#webhook) |
| `request.opened` | The applicant opens a [document request](https://docs.sahlfinancial.com/guides/document-requests.md) link for the first time. | [Document requests](https://docs.sahlfinancial.com/guides/document-requests.md#webhooks) |
| `request.submitted` | The applicant submits. | [Document requests](https://docs.sahlfinancial.com/guides/document-requests.md#webhooks) |
| `request.completed` | A submitted request has every document read or failed. | [Document requests](https://docs.sahlfinancial.com/guides/document-requests.md#webhooks) |
| `request.expired` | A request is found past its expiry date. | [Document requests](https://docs.sahlfinancial.com/guides/document-requests.md#webhooks) |
| `document.completed`, `document.failed`, `document.review_required` | A document processed in the console reaches that state. | |
| `review.approved`, `review.rejected`, `review.corrected` | A reviewer acts in the console. | |
| `case.created`, `case.updated`, `case.scored` | A case is created, changed or scored in the console. | |
| `onboarding.completed` | A partner onboarding session completes. | |

The events in the first eleven rows share one envelope: `event`, `event_id`, `occurred_at` and `tenant_id`, then their own keys. The console events in the last rows have a smaller payload without `event` or `event_id` (for example `document.completed` carries `document_id`, `job_id`, `status`, `document_type` and `page_count`). Route on the `X-Sahl-Event` header, which every delivery carries.

Payloads carry ids, your reference, statuses and check keys. They never carry a name, a date of birth, a balance or a document's contents. Events are sent for both environments, and the payload says which.

## Create an endpoint

| Field | Required | Rules |
| - | - | - |
| `url` | yes | `https`, resolving to a public address. Private, loopback and cloud metadata addresses are refused when you save and again before every send. Redirects are not followed. |
| `events` | yes | At least one event name from the list above. An unknown name answers 422 `unknown_webhook_event`, with the allowed list. |
| `secret` | no | 16 to 255 characters. Leave it out and Sahl generates one. |
| `description` | no | Free text. |

```bash cURL theme={"dark"}
curl -X POST https://app.sahlfinancial.com/api/v1/partner/webhooks \
  -H "Authorization: Bearer $SAHL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hooks.example.com/sahl",
    "events": ["kyb.completed", "statement.extracted", "request.completed"],
    "description": "Production receiver"
  }'
```

```javascript JavaScript theme={"dark"}
const res = await fetch("https://app.sahlfinancial.com/api/v1/partner/webhooks", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SAHL_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://hooks.example.com/sahl",
    events: ["kyb.completed", "statement.extracted", "request.completed"],
    description: "Production receiver",
  }),
});
const endpoint = await res.json();
// Store endpoint.secret now: it is not shown again.
```

```python Python theme={"dark"}
import os, requests

endpoint = requests.post(
    "https://app.sahlfinancial.com/api/v1/partner/webhooks",
    headers={"Authorization": f"Bearer {os.environ['SAHL_API_KEY']}"},
    json={
        "url": "https://hooks.example.com/sahl",
        "events": ["kyb.completed", "statement.extracted", "request.completed"],
        "description": "Production receiver",
    },
).json()
# Store endpoint["secret"] now: it is not shown again.
```

```json theme={"dark"}
{
  "id": "3a7c0000-0000-4000-8000-000000000006",
  "tenant_id": "00000000-0000-4000-8000-000000000000",
  "url": "https://hooks.example.com/sahl",
  "events": "kyb.completed,statement.extracted,request.completed",
  "is_active": true,
  "description": "Production receiver",
  "created_at": "2026-11-24T10:00:00+00:00",
  "updated_at": "2026-11-24T10:00:00+00:00",
  "secret": "whsec_..."
}
```

`secret` is the signing secret, `whsec_` followed by 48 characters. It is in the create answer only, and only when Sahl generated it. If you sent your own `secret` the answer carries `"secret": null`. Store it in a secret manager. In the list answers `events` is one comma-separated string.

An invalid URL answers 422 with a code in `detail.code`: `webhook_url_scheme` (not https), `webhook_url_invalid`, `webhook_url_unresolvable` (the name does not resolve) or `webhook_url_private_address`.

## List, test and delete

```bash theme={"dark"}
curl -H "Authorization: Bearer $SAHL_API_KEY" https://app.sahlfinancial.com/api/v1/partner/webhooks

curl -X POST -H "Authorization: Bearer $SAHL_API_KEY" \
  https://app.sahlfinancial.com/api/v1/partner/webhooks/$ENDPOINT_ID/test

curl -X DELETE -H "Authorization: Bearer $SAHL_API_KEY" \
  https://app.sahlfinancial.com/api/v1/partner/webhooks/$ENDPOINT_ID
```

The test answers what your server said:

```json theme={"dark"}
{"success": true, "status_code": 204, "response_body": "", "error": null}
```

`success` is true for any status below 400. `error` says why nothing was sent when the URL was refused ("Refused, not sent: ..."). The test delivery is a `test.ping`, signed like a real one, with the header `X-Sahl-Event: test.ping`. It is not shaped like the other events (see [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md#test-ping)).

## Delivery log and replay

Scope `webhooks:manage` too. These routes show what Sahl sent to your endpoints and let you send it again. They cover your workspace only: another workspace's delivery is a 404 like a missing one. The environment is `X-Sahl-Environment` or `?environment=` (`sandbox` by default): it is the one the event's payload names, and an event that names none is listed in both.

A delivery's outcome is `delivered`, `pending` (not sent yet, or failed and waiting for the retry job: see `next_retry_at`) or `failed` (every attempt used).

### List the deliveries

| Query | Rules |
| - | - |
| `endpoint_id` | Only this endpoint's deliveries. |
| `event` | Only this event name. |
| `status` | `delivered`, `failed` or `pending` (else 422 `invalid_status`). |
| `since` | Queued at or after this time (ISO 8601). |
| `limit` | 1 to 100. Default 50. |
| `cursor` | The `next_cursor` of the previous page (else 422 `invalid_cursor`). |

```bash cURL theme={"dark"}
curl "https://app.sahlfinancial.com/api/v1/partner/webhook-deliveries?status=failed&limit=20" \
  -H "Authorization: Bearer $SAHL_API_KEY"
```

```javascript JavaScript theme={"dark"}
const res = await fetch(
  "https://app.sahlfinancial.com/api/v1/partner/webhook-deliveries?status=failed&limit=20",
  { headers: { Authorization: `Bearer ${process.env.SAHL_API_KEY}` } },
);
const { data, has_more, next_cursor } = await res.json();
```

```python Python theme={"dark"}
import os, requests

page = requests.get(
    "https://app.sahlfinancial.com/api/v1/partner/webhook-deliveries",
    headers={"Authorization": f"Bearer {os.environ['SAHL_API_KEY']}"},
    params={"status": "failed", "limit": 20},
).json()
for d in page["data"]:
    print(d["id"], d["event"], d["status"], d["http_status_code"])
```

```json theme={"dark"}
{
  "data": [
    {
      "id": "d41e0000-0000-4000-8000-00000000000c",
      "event": "kyb.completed",
      "status": "failed",
      "endpoint_id": "3a7c0000-0000-4000-8000-000000000006",
      "environment": "production",
      "attempt_count": 6,
      "http_status_code": 500,
      "next_retry_at": null,
      "created_at": "2026-11-24T09:00:00Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

`attempt_count` counts replays too. `http_status_code` is the last attempt's status. `id` is also the `X-Sahl-Delivery` header you receive.

`GET /v1/partner/webhook-deliveries/summary` counts the deliveries queued in the last 24 hours and 7 days per outcome:

```json theme={"dark"}
{
  "environment": "sandbox",
  "last_24h": {"delivered": 41, "pending": 1, "failed": 0, "total": 42},
  "last_7d": {"delivered": 260, "pending": 1, "failed": 3, "total": 264}
}
```

### One delivery

`GET /v1/partner/webhook-deliveries/{delivery_id}`:

```json theme={"dark"}
{
  "id": "d41e0000-0000-4000-8000-00000000000c",
  "idempotency_key": "d41e0000-0000-4000-8000-00000000000c",
  "event": "kyb.completed",
  "status": "failed",
  "environment": "production",
  "endpoint": {"id": "3a7c0000-0000-4000-8000-000000000006", "url": "https://hooks.example.com/sahl", "is_active": true, "description": "Production receiver"},
  "attempts": {
    "count": 6,
    "max_automatic": 6,
    "remaining_automatic": 0,
    "first_attempt_at": "2026-11-24T09:00:00Z",
    "last": {"http_status_code": 500, "excerpt": "Internal Server Error"},
    "replays": []
  },
  "next_retry_at": null,
  "will_retry": false,
  "signature_timestamp": null,
  "payload": {"event": "kyb.completed", "event_id": "...", "kyb_id": "..."},
  "created_at": "2026-11-24T09:00:00Z"
}
```

`payload` is the JSON body exactly as sent (ids, references and statuses only). `attempts.last.excerpt` is the first 200 characters of your receiver's answer or of the error, with secrets removed. `attempts.replays` lists the replays made with this API, latest first (`at`, `signature_timestamp`, `delivered`, `http_status_code`). `idempotency_key` is the `X-Sahl-Delivery` value, the same on every attempt and replay: de-duplicate on it.

### Replay

```bash theme={"dark"}
curl -X POST https://app.sahlfinancial.com/api/v1/partner/webhook-deliveries/$DELIVERY_ID/replay \
  -H "Authorization: Bearer $SAHL_API_KEY"
```

```json theme={"dark"}
{
  "id": "d41e0000-0000-4000-8000-00000000000c",
  "idempotency_key": "d41e0000-0000-4000-8000-00000000000c",
  "delivered": true,
  "status": "delivered",
  "http_status_code": 204,
  "response_excerpt": "",
  "signature_timestamp": 1795600000,
  "attempt_count": 7,
  "next_retry_at": null
}
```

The replay sends the same payload and the same `X-Sahl-Delivery` id, with a fresh signature and a fresh `X-Sahl-Timestamp` (see [Verify the signature](#verify-the-signature)), and answers with your receiver's reply. It makes one attempt. A failed replay goes back on the automatic retry schedule while attempts remain (`next_retry_at`). Because the id is unchanged, a receiver that de-duplicates on `X-Sahl-Delivery` handles it as the same event.

| Status | `detail.code` | Cause |
| - | - | - |
| 404 | `not_found` | Unknown delivery, another workspace's, or one of a deleted endpoint (its deliveries are gone). |
| 409 | `endpoint_disabled` | The endpoint is switched off. |
| 409 | `delivery_in_progress` | The first send is still under way. Try again shortly. |
| 429 | `replay_rate_limited` | More than 10 replays a minute with one key, or more than 5 an hour for one delivery. |

## Verify the signature

Every delivery carries these headers:

| Header | Value |
| - | - |
| `X-Sahl-Event` | The event name. |
| `X-Sahl-Delivery` | A unique id per delivery, the same across its retries. (Not on a `test.ping`.) |
| `X-Sahl-Timestamp` | Unix seconds when this attempt was signed. |
| `X-Sahl-Signature-V2` | `sha256=` plus the hex HMAC-SHA256, keyed with your secret, of `"<timestamp>.<raw body>"`. |
| `X-Sahl-Signature` | `sha256=` plus the hex HMAC-SHA256 of the raw body alone. Kept for older receivers. It cannot stop a replay. |

Read the raw bytes before you parse the JSON, compare in constant time, and reject a timestamp that is too far from your clock. The window below, 5 minutes, is your choice and not a Sahl rule. Each retry is signed again, so its timestamp is fresh.

```javascript JavaScript theme={"dark"}
import { createHmac, timingSafeEqual } from "node:crypto";

const TOLERANCE_SECONDS = 300;

// rawBody: the body exactly as received (Buffer or string). headers: lowercase names.
export function verifySahlWebhook(rawBody, headers, secret, nowSeconds = Math.floor(Date.now() / 1000)) {
  const timestamp = headers["x-sahl-timestamp"];
  const received = headers["x-sahl-signature-v2"];
  if (!/^\d+$/.test(timestamp ?? "") || !received) return false;
  if (Math.abs(nowSeconds - Number(timestamp)) > TOLERANCE_SECONDS) return false;
  const expected =
    "sha256=" + createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest("hex");
  const a = Buffer.from(received);
  const b = Buffer.from(expected);
  return a.length === b.length && timingSafeEqual(a, b);
}
```

```python Python theme={"dark"}
import hashlib, hmac, time

TOLERANCE_SECONDS = 300


def verify_sahl_webhook(raw_body: bytes, headers: dict, secret: str, now: float | None = None) -> bool:
    """raw_body is the request body exactly as received. headers keys are lowercase."""
    timestamp = headers.get("x-sahl-timestamp", "")
    received = headers.get("x-sahl-signature-v2", "")
    if not timestamp.isdigit() or not received:
        return False
    if abs((now or time.time()) - int(timestamp)) > TOLERANCE_SECONDS:
        return False
    signed = timestamp.encode() + b"." + raw_body
    expected = "sha256=" + hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(received, expected)
```

## Delivery and retries

A delivery succeeds on any 2xx answer. Redirects are not followed and your server has 30 seconds to answer. A delivery that does not get a 2xx is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours: 6 attempts in all, the first included. After the sixth failure it stays failed. Delivery is at least once and not ordered: de-duplicate on `X-Sahl-Delivery` or on `event_id`, answer quickly with a 2xx and do the work afterwards. The full description, with a receiver example, is in [Webhooks](https://docs.sahlfinancial.com/guides/webhooks.md#delivery-and-retries).

## Errors

| Status | Cause |
| - | - |
| 401 | Missing, invalid, revoked or expired key. |
| 403 | The key lacks `webhooks:manage`. |
| 404 `not_found` | Unknown endpoint id, or another workspace's. |
| 422 `unknown_webhook_event` | An event name that does not exist, or an empty list. |
| 422 `webhook_url_*` | The URL is not https or does not resolve to a public address. |
| 429 `rate_limit_exceeded` | More than 60 calls a minute with one key. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.