Skip to content
Maua.Culturewire

Triggers

Receive signed webhooks for new events in your users' apps: modes, the event body, verification, retries, redelivery and test events.

Triggers watch an app through one of your users' connected accounts and send each new event to your server as a signed HTTP POST: a new GitHub issue, a new email in Gmail, a new calendar event. Deliveries are retried with backoff, logged with every attempt, and can be sent again by hand.

To act on an event without running a server of your own (new email, then send a WhatsApp message), build an automation instead. It uses a trigger of its own; see Triggers managed by an automation.

How it works

  1. You create a trigger: a trigger type (for example GITHUB_ISSUE_CREATED), a connected account, a config ({ "owner": "acme", "repo": "widgets" }) and a destination URL.
  2. We detect new events, either from the app's own webhook or by polling its API with the user's credentials.
  3. Each event becomes a delivery: a JSON body signed with the destination's secret and sent to your URL until it answers 2xx.

Every trigger instance runs in one of two modes:

TriggerModesPoll default
GITHUB_ISSUE_CREATEDwebhook, polling60 s
GITHUB_PULL_REQUEST_OPENEDwebhook, polling60 s
GMAIL_MESSAGE_RECEIVEDpolling60 s
GOOGLE_CALENDAR_EVENT_CREATEDpolling300 s
NOTION_PAGE_UPDATEDpolling300 s
LINEAR_ISSUE_CREATEDpolling60 s
SLACK_MESSAGE_POSTEDpolling60 s
  • Webhook mode is instant. It needs the platform's GitHub App webhook to be set up (see GitHub App webhook) and an account connected through the managed auth config, because only the platform's app sends us events. When you leave the mode out, webhook is chosen when it is available and polling otherwise. Asking for webhook mode when it is not available fails with 400 trigger_mode_unavailable and details.reason (source_not_configured, custom_auth_config or not_supported).
  • Polling works everywhere, including local development without a public URL and custom auth configs. The interval is 60 to 86400 seconds (default per type, above). The first poll only records where to start, so you never get a backfill of old events.

Both modes produce the same event ids, so switching a trigger from polling to webhook never delivers the same event twice.

SLACK_MESSAGE_POSTED watches one channel: its config requires channel, the channel id (for example C0123456789, not the #name). Slack polling honours Slack's rate limits, which allow new non-Marketplace apps about one history request per minute per workspace.

Create a trigger

In the dashboard open Triggers, then Create trigger. Pick the trigger, the connected account, fill in the config and choose the destination. Owners, admins and developers can create or change triggers; viewers can read them and the delivery log. The project webhook endpoint is owners and admins only.

Over the API (the same operations exist under /api/v1/triggers):

curl -X POST https://<your-host>/api/v1/triggers \
  -H "Authorization: Bearer $API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "trigger_slug": "GITHUB_ISSUE_CREATED",
    "user_id": "user_123",
    "config": { "owner": "acme", "repo": "widgets" },
    "webhook_url": "https://api.example.com/webhooks/culturewire"
  }'

With the TypeScript SDK:

import { Toolwire } from "@toolwire/sdk";

const toolwire = new Toolwire();

const trigger = await toolwire.triggers.create({
  triggerSlug: "GITHUB_ISSUE_CREATED",
  userId: "user_123",
  config: { owner: "acme", repo: "widgets" },
  webhookUrl: "https://api.example.com/webhooks/culturewire",
});
// The URL's own secret (whsec_...), returned only here: store it now. It is null when you leave
// webhookUrl out, because the project endpoint's secret signs those deliveries.
const secret: string | null = trigger.signing_secret;

Pass userId (we pick the user's newest active account of the toolkit) or connectedAccountId, not both. The config is checked against the trigger's schema, and GitHub triggers also check that the user can read the repository (400 trigger_setup_failed otherwise). A project can have 500 triggers.

Disabling a trigger pauses it: no events are detected and pending retries are not sent. Enabling it again starts from now. A trigger the system disabled (status failed, see below) is enabled the same way once you fixed the cause.

Destinations and signing secrets

A trigger sends events either to its own URL or to the project webhook endpoint, one URL per project that any trigger without its own URL uses. Set it on the Triggers page or with PUT /api/v1/webhook_endpoint.

Each destination URL has its own signing secret, so one receiver URL always verifies with one secret:

  • A trigger with its own URL gets its own secret, returned once as signing_secret in the create response (and in the dashboard's reveal dialog). A trigger created without webhook_url gets "signing_secret": null: the project endpoint's secret signs its deliveries.
  • Updating a trigger (PATCH /api/v1/triggers/{id}, triggers.update) returns a signing_secret only when the change moves it from the project endpoint to its own URL. Changing an existing own URL keeps its secret, and moving back to the project endpoint ("webhook_url": null) drops it; both answer null.
  • The project endpoint's secret is returned once, when PUT /api/v1/webhook_endpoint (webhookEndpoint.set) creates the endpoint. Changing its URL later keeps the secret and answers null.
  • Secrets look like whsec_ followed by 44 base64 characters. Keep them in your receiver's environment, never in code.

Rotate a secret from the trigger page (own URL only) or the endpoint card, or with POST /api/v1/triggers/{id}/rotate_secret and POST /api/v1/webhook_endpoint/rotate_secret, which always return the new signing_secret. During the grace period (grace_period_seconds, 0 to 86400, default 86400) every delivery carries a signature for the new and the previous secret, so your receiver keeps working while you deploy the new one. The destination and the secret are read when each attempt starts, so a URL change or a rotation also applies to pending retries.

Destination URLs must be absolute http(s) URLs of at most 2048 characters, without credentials or a fragment. In production they must use https and must not point at localhost, *.local, *.internal, cloud metadata hosts or private IP addresses. In every environment the host must be a valid DNS name (no underscores) and the port must be 80, 443 or 1024 and above; only localhost, 127.0.0.1 and [::1] are exempt outside production. Redirects are not followed.

The event

Each delivery is a POST with this JSON body:

{
  "id": "dlv_01jd8k3m0v6c2n4p6q8r0s2t4v",
  "type": "GITHUB_ISSUE_CREATED",
  "timestamp": "2026-10-28T09:00:00.000Z",
  "trigger_id": "trg_01jd8h...",
  "toolkit": "github",
  "connected_account_id": "ca_01jc...",
  "user_id": "user-42",
  "event_id": "issue:3001",
  "truncated": false,
  "data": {
    "number": 12,
    "title": "Login button broken",
    "body": null,
    "html_url": "https://github.com/acme/widgets/issues/12",
    "author": "octocat",
    "labels": ["bug"],
    "repository": "acme/widgets"
  }
}
  • id is the delivery id. It stays the same on every retry and redelivery and equals the webhook-id header: use it to ignore duplicates.
  • type is the trigger slug and data its payload. GET /api/v1/trigger_types/{slug} returns the payload's JSON schema (payload_schema); the toolkit catalog lists each trigger's config.
  • data over 256 KB is replaced by { "_truncated": true, "preview": "..." } and truncated is true.
  • Key order is not guaranteed. Verify the raw body first, then parse it.
  • test is true on a test event and absent on real events.

The request headers follow Standard Webhooks (opens in a new tab), so any Standard Webhooks library can verify them too:

POST <webhook_url>
content-type: application/json
user-agent: Maua.Culturewire-Webhooks/1
webhook-id: dlv_01jd8k3m0v6c2n4p6q8r0s2t4v
webhook-timestamp: 1793178000
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4= v1,<signature with the previous secret during rotation>
  • webhook-timestamp is the Unix time in seconds of this attempt (new on every retry).
  • webhook-signature is v1, plus the base64 HMAC-SHA256 of the string <webhook-id>.<webhook-timestamp>.<raw body>. The key is the base64-decoded part of the secret after whsec_. During a rotation there are several signatures, separated by spaces.

Verify deliveries

Always verify before you trust a delivery:

  1. Compute the signature over the raw body, exactly as received, and compare it in constant time with each v1, signature.
  2. Reject timestamps more than 300 seconds away from your clock. This bounds replays.
  3. Within that window, skip any webhook-id you already processed. Deliveries are at least once and not ordered.

Answer 2xx quickly (within 15 seconds) and do slow work afterwards.

With the SDK

verifyWebhook from @toolwire/sdk does steps 1 and 2 and returns the parsed event. It has no dependencies and runs on Node 20 or later, Bun, Deno and edge runtimes. It throws WebhookVerificationError (with a code such as invalid_signature or timestamp_out_of_tolerance) for anything that does not verify.

A plain Node server:

import { createServer } from "node:http";
import { verifyWebhook, WebhookVerificationError } from "@toolwire/sdk";

const secret = process.env.WEBHOOK_SECRET ?? ""; // whsec_...

createServer(async (req, res) => {
  const chunks: Buffer[] = [];
  for await (const chunk of req) chunks.push(chunk as Buffer);
  try {
    const event = await verifyWebhook({
      payload: Buffer.concat(chunks), // the raw body, before any JSON parsing
      headers: req.headers,
      secret,
    });
    // event.id equals the webhook-id header and stays the same on retries: dedupe on it.
    console.info(event.type, event.id, event.data);
    res.writeHead(204).end();
  } catch (err) {
    res.writeHead(err instanceof WebhookVerificationError ? 400 : 500).end();
  }
}).listen(4800);

A Next.js route handler:

// app/api/webhooks/culturewire/route.ts
import { verifyWebhook, WebhookVerificationError } from "@toolwire/sdk";

export async function POST(req: Request): Promise<Response> {
  const payload = await req.text(); // the raw body, before any JSON parsing
  try {
    const event = await verifyWebhook({
      payload,
      headers: req.headers,
      secret: process.env.WEBHOOK_SECRET ?? "", // whsec_...
    });
    // event.id equals the webhook-id header and stays the same on retries: dedupe on it.
    console.info(event.type, event.id, event.data);
    return new Response(null, { status: 204 });
  } catch (err) {
    if (err instanceof WebhookVerificationError) return new Response(null, { status: 400 });
    throw err;
  }
}

Type the payload with a type argument, for example verifyWebhook<{ title: string }>(...) makes event.data.title a string (the type is not checked at run time). To accept two secrets yourself (for example while moving a receiver between destinations), pass an array: secret: [current, previous]. The repository's examples/webhook-receiver is a runnable receiver that reads WEBHOOK_SECRET the same way.

By hand

The same checks with Node's crypto module:

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

/** True when the request is fresh and one of its v1 signatures matches. */
export function verifyByHand(
  rawBody: string, // the exact bytes you received, decoded as UTF-8
  headers: { "webhook-id": string; "webhook-timestamp": string; "webhook-signature": string },
  secret: string, // whsec_...
): boolean {
  const timestamp = Number(headers["webhook-timestamp"]);
  if (!Number.isInteger(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > 300) return false;

  const key = Buffer.from(secret.slice("whsec_".length), "base64");
  const signed = `${headers["webhook-id"]}.${headers["webhook-timestamp"]}.${rawBody}`;
  const expected = createHmac("sha256", key).update(signed).digest();

  // Several space-separated signatures during a secret rotation: any match is enough.
  return headers["webhook-signature"].split(" ").some((entry) => {
    const [version, signature] = entry.split(",");
    if (version !== "v1" || !signature) return false;
    const received = Buffer.from(signature, "base64");
    return received.length === expected.length && timingSafeEqual(received, expected);
  });
}

After it returns true, parse rawBody with JSON.parse and dedupe on id.

Retries and automatic disabling

Any response other than 2xx, a timeout (15 seconds) or a network error fails the attempt. Failed attempts are retried after 10 s, 1 min, 5 min, 30 min, 2 h, 6 h and 12 h (each plus or minus 20 % jitter): at most 8 attempts over about 20 and a half hours. Then the delivery is failed.

Some failures are not retried:

Error codeMeaning
endpoint_goneYour endpoint answered 410 Gone. The trigger is disabled at once.
destination_not_allowedThe URL resolves to a blocked address. The trigger is disabled.
no_destinationThe trigger uses the project endpoint, but none is set.
secret_unreadableThe destination's signing secret could not be read.
trigger_inactiveThe trigger was paused or disabled before the attempt started.
automation_unavailableAutomation triggers only: automations are turned off on this deployment, or the automation has no published version.

Redirects (3xx) count as failed attempts with redirect, and are retried.

After 5 deliveries of a trigger in a row end as failed, the trigger is disabled with status failed and the reason delivery_failures. Any successful delivery resets the count. Polling problems are shown on the trigger too: temporary errors slow polling down, a revoked account shows connection_not_active until the user reconnects, and a missing repository or lost access disables the trigger after 3 polls in a row (poll_failed:not_found, poll_failed:forbidden).

Delivery log and redeliver

Triggers, Delivery log lists every delivery with its status, attempts, last response code and duration, filtered by trigger, status and time. A delivery's page shows the event body and each attempt with its response code, duration, error and the first 2 KB of your response body. Deliveries are kept for 30 days, or for your plan's delivery retention on the hosted platform (see Usage and billing).

Redeliver (owners, admins and developers, or POST /api/v1/trigger_deliveries/{id}/redeliver) sends a settled delivery (success or failed) once more, as one manual attempt with the same id and a fresh signature. It is sent even if the trigger is paused, is never retried, and does not count toward automatic disabling. A delivery that is still pending or being delivered answers 409 delivery_in_progress.

Send a test event

To check your receiver without waiting for real activity, open a trigger and choose Send test event (owners, admins and developers), or call POST /api/v1/triggers/{trigger_id}/test_event with an API key that has trigger:write. It answers 202 with the new delivery, which shows in the delivery log with a Test chip.

// One signed delivery of the trigger type's example payload, marked "test": true.
const delivery = await toolwire.triggers.sendTestEvent("trg_...");
// Later: the delivery with its status (success or failed) and its single attempt.
const detail = await toolwire.triggers.deliveries.retrieve(delivery.id);
console.info(detail.status, detail.test);

A test event is a normal delivery with a few differences:

  • The body is the usual envelope with "test": true, an event_id of test:<id> and the trigger type's example payload as data (obviously fake values such as octocat and example.com; {} for a type without an example). It is signed and sent to the same destination as real events.
  • It works in every status, including disabled and failed: checking a fixed receiver before you enable an auto-disabled trigger again is the main use.
  • It is tried once. A failure is not retried; Redeliver still works.
  • It never changes the trigger: not its status, its failure count toward automatic disabling, or its last event time.
  • It does not count as a trigger event in usage or toward your plan.
  • Each project can send 10 test events per minute (429 rate_limited, policy trigger_test). The audit log records trigger.test_event_sent.

Real events never have the test field, so a receiver can skip test events after verifying the signature with if (event.test) return.

Triggers managed by an automation

Publishing an automation creates a trigger for it. That trigger works like any other: the same modes, polling intervals, event ids, dedupe, delivery log and retention. The differences:

  • It has no destination URL and no signing secret. Each delivery starts a run of the automation instead of a POST, and is recorded as success once the run is created. A redelivered event never starts a second run.
  • GET /triggers and GET /triggers/{id} return it with automation_id set (null on every other trigger). The Triggers page shows its destination as "Automation: " followed by the automation's name, with a link, and offers no actions on it.
  • It can only be changed through its automation. PATCH, DELETE, enable, disable, rotate_secret and test_event on it, and redeliver on its deliveries, answer 409 managed_by_automation with details.automation_id:
{
  "error": {
    "code": "managed_by_automation",
    "message": "This trigger belongs to an automation. Edit the automation instead.",
    "details": { "automation_id": "aut_..." }
  }
}
  • Publishing again updates it (a new trigger type or account replaces it, so the first poll starts from now). Pausing the automation pauses it, and deleting the automation deletes it. Events that arrive while it is paused are not run later.
  • When an automation pauses itself (repeated failures or too many runs), its trigger is paused with the reason automation_failed. Problems of the trigger itself (for example poll_failed:not_found) show on the automation as "Its trigger stopped".
  • Automation deliveries never count toward the 5 failed deliveries that disable a trigger. When the deployment turns automations off, or the automation has no published version, its deliveries fail at once with automation_unavailable and are not run later.
  • It counts toward the project's trigger limit, and its events count as trigger events in usage.

GitHub App webhook

Webhook mode for the GitHub triggers uses the platform's GitHub App. When you run the platform yourself:

  1. In the GitHub App settings, turn Webhook on and set the URL to https://<your-web-host>/api/v1/webhooks/github, with content type application/json.
  2. Generate a webhook secret, set it as the app's Webhook secret and as GITHUB_APP_WEBHOOK_SECRET in the API's environment.
  3. Under Permissions and events, subscribe to Issues and Pull requests.

Requests without a valid X-Hub-Signature-256 are rejected with 401. Without GITHUB_APP_WEBHOOK_SECRET, the endpoint answers 404 and GitHub triggers poll. For local tests, point a tunnel at the web app on port 3000. The step-by-step app setup is in packages/toolkits/src/github/SETUP.md in the repository.

Limits

LimitValue
Triggers per project500, or the plan's limit
Config size8 KB
Poll interval60 to 86400 seconds
Events per poll100 (the rest come next poll)
Event data before truncation256 KB
Delivery timeout15 seconds
Attempts per delivery8
Signature tolerance300 seconds
Secret rotation grace periodup to 24 hours
Delivery log retention30 days, or the plan's
Test events10 per minute per project

On the hosted platform, the plan sets the number of triggers per project (Hobby 5, Pro 100, Team 500, see Usage and billing). Creating one more returns 409 limit_reached. Enabling a webhook-mode trigger checks again that webhook mode is available, and answers 409 trigger_mode_unavailable with details.reason when it is not (for example after the GitHub App was removed from the repository).