# Webhooks

> Receive workspace events at your endpoint, verify signatures, and handle retries.

Webhooks send workspace events to an HTTPS endpoint you host as soon as they happen. To start a script when another service calls Reminix, use a [webhook trigger](/docs/schedules-and-triggers/#webhook-triggers) instead. The workspace’s owner and its admins manage endpoints in the app under **Settings → Developers**. Add a URL and copy the signing secret, which we show only once. Events then start arriving. You can edit an endpoint’s URL or events later, and it keeps the same signing secret.

## Managing endpoints through the API

Software can manage endpoints too, with a credential that has these scopes:

| To               | Scope                      |
| ---------------- | -------------------------- |
| Manage endpoints | `workspace.webhooks:write` |
| Read endpoints   | `workspace.webhooks:read`  |

With a personal access token, every member can read endpoints. The workspace’s owners and admins manage them, and members can manage test endpoints. A guest can’t do either.

```bash
curl -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://example.com/hooks" }' \
  https://api.reminix.com/v1/workspace/webhook-endpoints
```

The response is a `201` with the new endpoint. Its `Location` header holds the endpoint’s path. The endpoint’s signing secret is in `secret`, and the API returns it only this once:

```json
{
  "id": "we_3f0c1a2e-4b5d-4c6e-8f70-1a2b3c4d5e6f",
  "url": "https://example.com/hooks",
  "description": null,
  "enabled": true,
  "eventTypes": null,
  "environment": "production",
  "consecutiveFailures": 0,
  "lastHttpStatus": null,
  "lastAttemptAt": null,
  "createdAt": "2026-08-20T12:00:00.000Z",
  "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"
}
```

The API can also:

* list endpoints
* change an endpoint’s URL or events with `PATCH`, which keeps its secret
* re-enable an endpoint we switched off after repeated failures
* send a test event
* list deliveries and redeliver them

Sending a test event and redelivering answer `200` when we tried the delivery right away. Then `ok` and `httpStatus` say how your endpoint answered. They answer `202` when the delivery went to the queue, with `queued: true`. Redelivering to a disabled endpoint fails with `409` and the code `conflict`. Re-enable the endpoint first.

The [API reference](/docs/reference/) has every operation.

AI agents connected to the workspace can read endpoints and delivery history, send test events and redeliver. They can’t add, change, remove or re-enable endpoints, because that changes where your workspace’s data goes. Only a person can do that.

## A delivery

Each delivery is an HTTP `POST` with a JSON body:

```json
{
  "id": "evt_51c2d3e4-f5a6-4b7c-8d9e-0f1a2b3c4d5e",
  "type": "workspace.member.joined",
  "createdAt": "2026-08-20T12:00:00.000Z",
  "data": {
    "userId": "usr_4f8a2c1e-7b3d-4e9f-a6c5-2d1b0e9f8a7c",
    "email": "casey@example.com"
  }
}
```

Each delivery also carries three signature headers:

```http
webhook-id: del_8a1b2c3d-4e5f-4a6b-9c7d-8e9f0a1b2c3d
webhook-timestamp: 1755691200
webhook-signature: v1,MEQCIB…
```

`webhook-id` identifies the delivery and stays the same when we retry it, so use it to ignore duplicates. The `id` in the body identifies the event.

If you have several endpoints, each gets its own delivery of the same event, so deduplicate by the event’s `id` to process it once. That also covers the rare case where an event reaches you more than once as separate deliveries, for example when we resend it after an outage.

## Verifying signatures

Before you trust a delivery, check that we sent it, that nobody changed it, and that it’s recent. The SDKs do all three checks with your endpoint’s secret (`whsec_…`) and give you the event:

* TypeScript

  ```ts
  import { verifyWebhook, WebhookVerificationError } from "@reminix/sdk";

  // A fetch-style handler (Hono, Workers, Next.js route handlers…).
  export async function POST(request: Request) {
    try {
      // The RAW body: verify before parsing it.
      const event = await verifyWebhook(
        await request.text(),
        request.headers,
        process.env.WEBHOOK_SECRET!,
      );
      // handle event…
      return new Response("ok");
    } catch (error) {
      if (error instanceof WebhookVerificationError) {
        return new Response("bad signature", { status: 400 });
      }
      throw error;
    }
  }
  ```

* Python

  ```python
  import os

  from flask import Flask, request
  from reminix import WebhookVerificationError, verify_webhook

  app = Flask(__name__)


  @app.post("/webhooks")
  def webhooks():
      try:
          # The RAW body: verify before parsing it.
          event = verify_webhook(
              request.get_data(), request.headers, os.environ["WEBHOOK_SECRET"]
          )
      except WebhookVerificationError:
          return "bad signature", 400
      # handle event…
      return "ok"
  ```

If you’ve already created a client, the same check is `reminix.webhooks.verify(…)`. The SDKs refuse a delivery older than 5 minutes, so nobody can replay an old one. To change that limit, set `toleranceSeconds` in TypeScript or `tolerance_seconds` in Python.

We sign deliveries the same way [Svix](https://docs.svix.com/receiving/verifying-payloads/how) does, so any standard Svix library can verify them. In other languages, verify the signature yourself:

1. Take the secret without its `whsec_` prefix and Base64-decode it. That’s the HMAC key.
2. Compute the HMAC-SHA256 of `` `${webhookId}.${timestamp}.${body}` `` with that key, and Base64-encode it.
3. The signature is `v1,` followed by that value.

Always verify the **raw** body, because re-serialising the JSON changes it and breaks the signature. Reject timestamps more than a few minutes old.

## Respond quickly, process later

Respond with a `2xx` within 10 seconds, or the delivery counts as failed. If processing takes longer, acknowledge the delivery first and do the work afterwards.

## Retries and failures

If a delivery fails, we retry it with backoff, up to 6 attempts in total. Each retry keeps the same `webhook-id`. A delivery fails when your endpoint:

* times out
* doesn’t respond
* returns a `5xx`, `408` or `429`

Any other response, such as a `400` or a `404`, means your endpoint got the request and refused it. Retrying wouldn’t help, so that delivery fails straight away.

If 20 attempts in a row fail, across all of the endpoint’s deliveries, we switch the endpoint off. Once it’s working again, re-enable it under **Settings → Developers** or through the API. It keeps its signing secret.

Under **Settings → Developers**, an endpoint’s **Deliveries** shows each delivery’s state and attempts. Through the API, a delivery’s `status` is its state: `pending`, `delivered` or `failed`. `lastHttpStatus` is the HTTP status code your endpoint last answered with. You can also send a test event (`type: "ping"`) and redeliver any recorded delivery. A redelivery gets a new `webhook-id` but keeps the event’s `id`, so deduplicating by event still works.

## Events

| Type                      | Sent when                           | `data`                                                                                                    |
| ------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------- |
| `run.succeeded`           | A run succeeds.                     | `runId`, `script` (`id`, `slug`), `version`, `status`, `environment`, `durationMs`, `via`, `triggerDepth` |
| `run.failed`              | A run fails.                        | the same, with `error`                                                                                    |
| `run.cancelled`           | A run ends as cancelled.            | the same, with `error` saying why                                                                         |
| `script.published`        | Someone publishes a script version. | `script` (`id`, `slug`), `version`                                                                        |
| `workspace.member.joined` | Someone accepts an invitation.      | `userId`, `email`                                                                                         |
| `ping`                    | You send a test from Settings.      | a test message                                                                                            |

A run ends as cancelled when someone cancels it, when an approver denies it, when its approval expires, or when it can’t start after approval. A test run doesn’t send any run events.

Event payloads only ever gain fields, so write parsers that ignore fields they don’t know. `GET /v1/workspace/event-types` lists every event type and what it means.

## Choosing events

An endpoint receives every event unless you choose otherwise. In **Settings → Developers**, pick “Only these” when you add the endpoint. Through the API, pass `eventTypes` when you create it:

```bash
curl -X POST https://api.reminix.com/v1/workspace/webhook-endpoints \
  -H "Authorization: Bearer YOUR_API_KEY" -H "content-type: application/json" \
  -d '{"url":"https://example.com/hooks","eventTypes":["workspace.member.joined"]}'
```

A test event (`ping`) always reaches the endpoint you’re testing.
