Files
openbot/docs/webhooks.md
T
NB 9e019602c6 Add webhook triggers to routines (#1520)
* Add webhook triggers and routine notifications

* Name webhook release notes for the feature branch

* Make each webhook part of its routine

Remove the host-level event source. A webhook trigger now belongs to its
routine. The host makes the URL and the secret. The editor shows the secret
one time, and the user can rotate it.

- Split the event store into RoutineStore triggers, WebhookRouteStore and
  WebhookDestinationStore. Connect destinations to routines with a link table.
  Add RoutineRecords, so that main does not call AgentService for routine
  records.
- Revoke the relay route in the same transaction when a routine is deleted or
  changed to a schedule. Retry the revocation until it succeeds.
- Tell open editors when a background sync stores a webhook URL.
- Use one inline webhook trigger, notifications and activity in the desktop,
  web and mobile routine editors. Remove the Events server settings page.
- Add "webhook" as a routine analytics trigger type.
- Update contracts, Team API events-v1, i18n, docs, PRIVACY.md and the
  release notes.

* Fix the knip and channel test failures of the webhook routines

- Remove the export from 23 webhook names that no other file uses.
- Use the backend event type limit in main instead of a second copy.
- Stub the events group in the app test harness. A channel on this
  computer reads its routine count through it.

* Use one trigger menu and a webhook card for routines

Replace the Schedule/Webhook toggle with a grouped trigger menu on
desktop and mobile. Each schedule and the webhook have an icon and one
line that tells when the routine runs. Show the webhook trigger as one
card with Endpoint, Signing secret and Events rows.

* Simplify the routine editor

Merge the webhook activity into the routine history: it shows runs,
ignored webhook requests and failed notifications with a Retry action,
and reloads when the runs change. Show notifications as a plain field
with compact rows and icon actions. Hide the event filters of a webhook
routine until the user selects Filter events. Align the history rows
with the field labels and remove dead run row styles.

* Keep the schedule row as tall as an input with the trigger menu

* Make the webhook card rows full width

* Remove routine run notifications from webhook routines

Webhook routines keep the endpoint, the signing secret, event filters,
receipts and the ignored requests in the routine history. Outbound
destinations, the delivery outbox and its retry worker are removed.
Migration 29 is not released, so it is edited in place.

Also align the webhook card header icon with the row labels.

* Fix review findings and remove unused webhook code

- Keep the stored timezone when a routine is saved again.
- Let a webhook routine with the "skip" policy drop its held runs.
- Never free a webhook route ID in the account service. Give a routine a new route ID when the
  account service refuses the old one.
- Check route ownership before the Signal rate limit and body read. Share one Slack and webhook
  delivery budget for each host.
- Keep Slack and Discord ingress when the webhook ticket fails.
- Run one route sync at a time, and only when routes can change.
- Return 503 when the host cannot decrypt a secret, and 500 for internal events-route failures.
- Use one filter value codec on desktop and mobile. Keep filter inputs focused while typing.
- Remove unused types, exports, decoders, signers and repeated checks.
- Add `| undefined` to new optional props for the types ratchet.

* Fix NorbiAI findings for webhook routines

- The released agent and channel routine routes do not delete or test a
  webhook routine. These routes have no administrator check. Only the
  events surface sets the webhook access.
- A route sync that fails runs again after 30 seconds. The delay doubles
  up to 15 minutes until a sync succeeds.
- An ignored channel webhook publishes a routine change, so an open
  editor shows it in History.
- A receipt older than 7 days does not count as a duplicate.

* Use event routes only for web admins and keep one ingress socket

- The web client uses the events routes only for an owner or admin. A
  member keeps the released routine routes, so the routine list does not
  fail with 403.
- The first Slack or Discord holder reconnects the ingress socket when
  webhooks already hold it. Before, it opened a second socket and did not
  close the first one.

* Fix NorbiAI findings for webhook size, mobile refresh, and route retention

- Answer 413 with no receipt when the routine instruction and the event are longer than the message limit.
- Reload mobile channel webhook routines and webhook history on routine change events.
- Say in PRIVACY.md that revoked route rows stay permanently.

* Retry the webhook ticket on a shared socket and hold webhook runs during a restart

- When Slack or Discord share the ingress socket and the webhook ticket failed, open the socket again with a backoff until Signal confirms the webhook route.
- While a restart waits for idle agents, answer 503 to webhook requests and write no receipt.
2026-10-07 20:57:46 +02:00

6.7 KiB

Webhooks

A webhook routine starts when an external service sends a signed request to the routine's URL. An agent routine and a channel routine both support webhooks. A host administrator configures them in the routine editor. The host must be online to receive requests.

Set up a webhook routine

  1. Open the routine editor of an agent or a channel.
  2. Set When to run to Webhook.
  3. Optional: enter an event type. With no event type, all event types start the routine.
  4. Optional: add filters.
  5. Save the routine. The host makes the URL and the signing secret.
  6. Copy the secret into the secret store of the sending service. OpenBot shows it one time only.
  7. Copy the URL. The URL is empty until the account service registers the route. The host must be signed in to its OpenBot account.

Each webhook routine has its own URL and secret. A host can have at most 64 webhook routines.

To replace the secret, make a new one in the routine editor and update the sender. The old secret stops working immediately. A secret has the format whsec_<43 base64url characters>.

When you change the routine to Schedule, or delete the routine, its URL stops working. If you change it back to Webhook, the routine gets a new URL and a new secret.

The URL also changes when you sign in to a different OpenBot account on the host. The secret stays the same. Copy the new URL into the sending service.

Send a request

Send a POST request with Content-Type: application/json to the routine URL. The body has this shape:

{
  "type": "deployment.completed",
  "occurredAt": "2026-10-07T10:00:00.000Z",
  "data": { "environment": "production", "revision": "abc123" }
}
Field Rule
type Required. A string of 1 to 256 characters.
occurredAt Optional. A date string. If you do not send it, OpenBot uses the receipt time.
data Optional. Any JSON value. If you do not send it, the value is null.

The body must be UTF-8 and at most 64 KiB.

Event type and filters

In the routine editor, select Filter events to add an event type or a filter. With no event type and no filter, each signed request starts the routine.

If the routine has an event type, type must be equal to it. A filter has a JSON Pointer into data and a value. The value is a string, number, boolean, or null. The value at the pointer must be equal to the filter value, with the same JSON type. For example, /environment with production reads data.environment. All filters must match. Use ~1 for / and ~0 for ~ in a pointer. An empty pointer selects all of data. A routine can have at most 128 filters.

Headers and signature

Header Value
X-OpenBot-Timestamp The current Unix time in seconds
X-OpenBot-Delivery-Id A unique ID for this event. Use 1 to 256 ASCII letters, digits, ., _, :, or -. The first character is a letter or a digit.
X-OpenBot-Signature sha256= and the lowercase hexadecimal HMAC-SHA256

The HMAC key is the routine secret. The signed bytes are <timestamp>.<deliveryId>.<body>. Use the exact body bytes that you send. Do not parse and serialize the body again after you sign it. The timestamp must be within 5 minutes of the host clock.

Example with Node.js:

import { createHmac, randomUUID } from "node:crypto";

const body = JSON.stringify({ type: "deployment.completed", data: { environment: "production" } });
const deliveryId = randomUUID(); // Keep this ID and the body for a retry.
const timestamp = String(Math.floor(Date.now() / 1000));
const signature = createHmac("sha256", process.env.OPENBOT_WEBHOOK_SECRET)
  .update(`${timestamp}.${deliveryId}.${body}`)
  .digest("hex");
const response = await fetch(process.env.OPENBOT_WEBHOOK_URL, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-OpenBot-Timestamp": timestamp,
    "X-OpenBot-Delivery-Id": deliveryId,
    "X-OpenBot-Signature": `sha256=${signature}`,
  },
  body,
});
if (response.status !== 200 && response.status !== 202) {
  throw new Error(`OpenBot did not accept the event: ${response.status}`);
}

Responses

Status Meaning Retry
202 The host saved the event. The routine started, or the host ignored the event because the event type or a filter did not match, or because the routine is paused. No
200 The routine already has this delivery ID. No
400 The body is not valid. No. Correct the body.
401 A header or the signature is not valid, or the timestamp is not within 5 minutes of the host clock. No. Correct the secret, the headers, or the clock.
404 The host does not know the route. No
413 The body is larger than 64 KiB, or the routine instruction and the event together are longer than 100,000 characters. No. Send less data or shorten the instruction.
415 Content-Type is not application/json. No
429 Too many requests to this route from your address. Yes, later
503 The host is offline, busy, or did not answer in 2.5 seconds. The relay does not know the route, the host cannot read the secret, or the agent or channel cannot take a run now. Yes, later

A 202 response does not mean that the run is complete. Look at the routine history for the run result. The relay does not keep requests while the host is offline. If you do not retry, the event is lost.

Retries and duplicates

The delivery ID is the deduplication key for each routine. To retry, send the same delivery ID and the same body with a new timestamp and a new signature. A repeated delivery ID gets 200 and does not start a second run. This also applies to an event that the routine ignored. The host keeps receipts for 7 days. After that time, the same delivery ID starts a new run.

What the agent receives

The run instruction is the routine instruction, followed by the event. The event is marked as external data, not as instructions. It contains the delivery ID, the routine ID, type, occurredAt, the receipt time, and data. Event data can go to the model provider of the routine, like all routine input. The data cannot give tools to the agent or skip approvals.

History

The routine history shows each request that the host ignored, with the reason: the event type or a filter did not match, or the routine was not active.

Data retention

  • Receipts: 7 days. A receipt has the delivery ID, the event type, the result, and the run ID. It does not have the request body.
  • Deleting a routine deletes its receipts.

Security

  • Only host administrators can manage webhook routines.
  • The host verifies the signature before it decodes the body. The relay does not have the secret.
  • Secrets are encrypted with the operating system's secret storage. They are not in logs, errors, or activity.