Skip to main content

Workflow triggers

A trigger starts a workflow runner run when something happens. Five kinds exist: signed inbound webhooks, cron schedules, gateway events, chat messages and forms. Every trigger points at one pinned version of a saved workflow definition, so a trigger never carries a plan of its own and a definition change never reaches a trigger until you move it to the new version.

A webhook trigger can also take its events straight from Slack mentions, Microsoft Teams messages, Outlook and Gmail mailboxes and Outlook and Google calendars, with each service's own signature check and a mapping of who may start it, see Slack, Teams, mail and calendar triggers.

Triggers need a database and a Spanway enterprise license that includes both the workflow_runner and the workflow_triggers features. Without them every /v1/triggers route answers 403, including the public webhook route, and no trigger fires.

Scenario​

A support team gets a ticket webhook from its ticketing tool for every new ticket. They want each ticket triaged by a saved workflow without anyone pressing a button. A signed webhook trigger receives the delivery, maps the ticket title onto the workflow input, and starts a run as the support lead's key with a two dollar budget. If the ticketing tool misbehaves and sends a flood, the per-minute limit holds, and after too many failures the trigger turns itself off and alerts the team.

Steps​

  1. Save the triage workflow as a definition and note its id and version.

  2. In the Admin UI open Workflow Runs under Agentic, switch to the Triggers tab and click New trigger. Pick Signed webhook, the saved workflow and version it starts, the key it runs as, the run budget and the most fires per minute, and save. Copy the signing secret and the webhook URL, which show once. From the API the same trigger looks like this.

    curl -X POST http://localhost:4000/v1/triggers/new \
    -H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
    -d '{
    "name": "support tickets",
    "source": {"kind": "webhook"},
    "definition_id": "def-support-triage",
    "definition_version": 3,
    "actor_key": "sk-my-key",
    "run_budget_usd": 2.0
    }'
  3. Paste the webhook URL and the secret into the ticketing tool. A delivery signed with the Standard Webhooks headers looks like this.

    SECRET="whsec_..."; ID="msg_$(date +%s)"; TS=$(date +%s); BODY='{"ticket":{"title":"Printer on fire"}}'
    KEY=$(printf '%s' "${SECRET#whsec_}" | base64 -d | xxd -p -c 256)
    SIG=$(printf '%s' "$ID.$TS.$BODY" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$KEY" -binary | base64)
    curl -X POST "http://localhost:4000/v1/triggers/webhook/$TRIGGER_ID" -H "Content-Type: application/json" \
    -H "webhook-id: $ID" -H "webhook-timestamp: $TS" -H "webhook-signature: v1,$SIG" -d "$BODY"
  4. Click the trigger's name to open its sheet and watch Fire history. Each fire shows its Status, Outcome and a Run link to the run ledger. Send a test fire queues a fire with a sample payload without waiting for a real ticket.

Expected result​

The create call answers 200 with the trigger and, for a webhook, the signing secret once. The webhook URL is /v1/triggers/webhook/<trigger_id> on your gateway.

{"trigger": {"trigger_id": "trg_01J...", "name": "support tickets", "kind": "webhook", "enabled": true, "definition_id": "def-support-triage", "definition_version": 3}, "signing_secret": "whsec_..."}

A verified delivery answers 200 with {"fire_id": "fire_01J...", "status": "pending", "run_id": null}, and a few seconds later the fire history shows the run id. A replayed webhook-id returns the original fire instead of starting a second run.

How a fire becomes a run​

Every source writes a fire row first, deduplicated by a unique key per trigger. A dispatcher job on every replica claims pending fires, reloads the trigger, checks its limits and its key, and starts the run through the same start path as POST /v1/workflows/runner/start. The fire id is stored on the run, so a fire that is claimed twice after a replica crash finds the run it already started instead of starting another one. The runner's step gate, kill switch, budgets and retries then apply as they do to any run.

Every run gets the same input envelope, so step messages can read it with {{input.<path>}} placeholders. The pinned version's input contract must declare trigger and payload as object fields and may not require any other field, otherwise creating the trigger answers 422:

{"trigger": {"id": "trg-1", "kind": "webhook", "fire_id": "f-1", "fired_at": "2026-10-19T12:00:00+00:00"},
"payload": {"ticket": {"title": "Printer on fire"}}}
Kindpayload
webhookThe JSON object the sender posted. Headers are never copied
cron{"scheduled_for": "<instant>", "missed": <n>}
eventThe event's body, described under Gateway events
chat{"message": "<text>"}
form{"fields": {...validated values}}

The payload is stored sealed with SPANWAY_SALT_KEY until the run exists, then dropped from the fire, so it lives only in the run input. Fire history shows status, outcome and run id, never the payload.

Map a fire onto any definition's input​

A definition whose input contract has its own fields, such as one a workflow template installed, can still be started by a trigger. Set input_mapping to name, for each input field, a dotted path into the envelope above. The run input is then only the mapped fields, and the envelope itself is not sent:

{"input_mapping": {"ticket": "payload.issue.body", "source": "trigger.kind"}}

Every mapped field must be in the pinned version's input contract and every required field must be mapped, otherwise creating or updating the trigger answers 422. A path starts with trigger or payload and has at most eight more parts. A path the fire does not carry, or whose value is null, leaves its field out, so a fire missing a required field is refused as input_invalid. An update replaces the mapping, and leaving input_mapping out of an update removes it.

Which key a run uses​

Webhook, cron and event triggers run unattended, so you bind one of your own virtual keys with actor_key (the raw key or its hash) and set run_budget_usd, both required. The key is reloaded and checked before every start, so a deleted, blocked, expired or over budget key, or a blocked team or organization, refuses the fire. A key that moved to another organization, or was reassigned to another user, refuses the fire, because an unattended trigger only ever acts as the key of the user who bound it. Rotating or regenerating the key moves bound triggers to the new key and writes an audit row per trigger. Triggers never run as the master key or a dashboard session.

Chat and form triggers run as the caller. A virtual key runs as itself, and a dashboard session names one of its user's own keys in run_as_key. The caller must be able to see the trigger, and the run's step gate checks that the caller may call every agent, so a trigger never gives anyone more access than their own key has.

Create a trigger​

curl -X POST http://localhost:4000/v1/triggers/new \
-H "Authorization: Bearer sk-my-key" -H "Content-Type: application/json" \
-d '{
"name": "support tickets",
"source": {"kind": "webhook"},
"definition_id": "def-support-triage",
"definition_version": 3,
"actor_key": "sk-my-key",
"run_budget_usd": 2.0
}'

A webhook trigger's response carries signing_secret once. Only its last four characters are kept in clear as secret_hint, and no other route returns the secret. The creator must be able to see the definition, it must not be halted, and the key the runs will use must pass the runner's gate for every step, and a webhook whose definition reaches a custom agent with write tools can only be created by a proxy admin, because webhook payloads are untrusted text that becomes part of a prompt.

FieldMeaning
sourceOne of the kinds below
definition_id, definition_versionThe pinned definition version the trigger starts
visibilityprivate (default), team with owner_team_id (team admins only) or org (proxy admins only). Applies to who can see and use chat and form triggers. An org trigger is visible inside the organization it runs in, and one with no organization is visible only to its owner, proxy admins and admin viewers until an edit by someone in an organization gives it one
actor_key, run_budget_usdRequired for webhook, cron and event triggers
event_reachEvent triggers only, see below
max_fires_per_minute1 to 600, default 60

Webhooks​

Inbound webhooks are off by default. Turn them on with general_settings.workflow_triggers.inbound_webhooks: true and set PROXY_BASE_URL, which builds the URL shown to the trigger's managers. Senders post to POST /v1/triggers/webhook/{trigger_id} with no Spanway key and sign each delivery with the Standard Webhooks scheme: an HMAC-SHA256 over {webhook-id}.{webhook-timestamp}.{body}, sent as webhook-signature: v1,<base64>.

SECRET="whsec_..."; ID="msg_$(date +%s)"; TS=$(date +%s); BODY='{"ticket":{"title":"Printer on fire"}}'
KEY=$(printf '%s' "${SECRET#whsec_}" | base64 -d | xxd -p -c 256)
SIG=$(printf '%s' "$ID.$TS.$BODY" | openssl dgst -sha256 -mac HMAC -macopt "hexkey:$KEY" -binary | base64)
curl -X POST "http://localhost:4000/v1/triggers/webhook/$TRIGGER_ID" -H "Content-Type: application/json" \
-H "webhook-id: $ID" -H "webhook-timestamp: $TS" -H "webhook-signature: v1,$SIG" -d "$BODY"

The gateway answers 200 with the fire_id, and the run usually starts within one dispatcher tick. Checks run cheapest first:

  • a per replica limit on inbound requests and a per client IP limit, before any lookup,
  • a body cap (the trigger's max_body_bytes, at most 256 KiB), enforced while reading so a wrong Content-Length cannot get past it,
  • the signature, with a timestamp within five minutes of the gateway clock and a constant time comparison against the current secret and, during rotation, the previous one,
  • the trigger's own per minute limit, counted only for deliveries that verified,
  • a JSON object body.

Unknown, disabled and wrongly signed deliveries all get the same 401 with {"error": "invalid signature"} and write nothing. A delivery sent again with the same webhook-id returns the original fire_id without a second fire, which makes sender retries safe and stops replays.

Apps that sign with X-Hub-Signature-256​

Many source control and developer tools send their own outbound webhooks signed with X-Hub-Signature-256: sha256=<hex>, an HMAC-SHA256 of the body alone. To receive those directly, create the webhook trigger with "source": {"kind": "webhook", "scheme": "hub_signature"} and paste the whole whsec_... secret, prefix included, into the app's webhook secret field. Pick the scheme in the Admin UI trigger form under Signing scheme, or set it through the API.

This scheme carries no signed timestamp or delivery id, so the gateway dedupes on a digest of the body. Any delivery with the same body as an earlier one returns the original fire_id, including app redeliveries. A verified delivery with X-GitHub-Event: ping answers 204 and starts nothing. Prefer standard_webhooks when the sender supports it, since its timestamp window also limits how long a captured delivery stays useful.

Slack, Teams, Outlook, Gmail and Google Calendar​

The schemes slack, teams, microsoft_graph, gmail and google_calendar receive events from those services directly, answer their setup checks and refuse any sender or place that is not in the trigger's access mapping. Slack and Teams triggers take the secret the service issued as provider_secret, and a Gmail trigger keeps no secret because Google signs each push. See Slack, Teams, mail and calendar triggers.

POST /v1/triggers/rotate_secret returns a new secret once. Only the user whose key the trigger runs as, or a proxy admin, can rotate it. The old one keeps verifying for grace_seconds (default 3,600, up to 86,400), so you can move senders over without losing deliveries.

Cron​

{"kind": "cron", "cron": "0 9 * * 1-5", "timezone": "Europe/Berlin", "overlap": "skip"}

The expression has five fields and the timezone is an IANA name. Two consecutive fires closer than min_cron_interval_seconds (default 60) are refused. Every replica polls for due triggers and advances each one with a compare-and-set in the same statement that inserts the fire, keyed by the scheduled instant, so one instant starts one run however many replicas run. After downtime a trigger fires once with the number of missed instants in payload.missed and its next fire is computed from now, so it does not burst. With overlap: "skip" a fire is skipped while the run of an earlier fire is still pending or running. allow lets runs overlap.

Gateway events​

{"kind": "event", "subscriptions": [{"type": "budget.threshold_crossed", "min_spend_ratio": 0.9}]}
TypeWhenFilter fields
budget.threshold_crossedA key, user, team, customer or organization crossed its soft or hard budgetbudget_types, min_spend_ratio
eval.regressionA scheduled eval or an online scoring rule with an alert threshold regressed, whether or not alerting is configured. Online rule events carry the pass rate of the worst series and its previous windowsource_ids
incident.opened, incident.updated, incident.resolvedA status page incident changedmin_impact
key.rotated, key.rotation_failedThe scheduled key rotation job rotated a key or failed toteam_ids

GET /v1/triggers/event_types lists them with the JSON schema of each filter. Budget, eval and key events carry identifiers and numbers only. Incident events also carry the incident's title and its affected model groups, as written on the status page. A key is named by a short keyed digest of its hash, never by its alias, hash or value, and an email is never included. Budget events are deduplicated per entity per day, and crossings of project, tag or agent budgets are told apart by the key, team and user behind them.

event_reach decides which events a trigger sees. owner (the default) receives events from its own organization that its owning team or user produced. org receives every event in its organization and needs an org admin. proxy receives gateway wide events, such as incidents and eval regressions, and needs a proxy admin.

Producers never wait on the database. An event is dropped at once when no trigger subscribes to its type, deduplicated across replicas, and written to a durable outbox. A relay job turns each outbox event into one fire per matching trigger, keyed by the event id, so delivery is at least once and a fire is never created twice for the same event. If the database is briefly unreachable the event is held in memory and written later.

Chat and forms​

Chat and form triggers are data plane routes, turned off with DISABLE_LLM_API_ENDPOINTS like agent invocation.

curl -X POST http://localhost:4000/v1/triggers/chat -H "Authorization: Bearer sk-my-key" \
-H "Content-Type: application/json" -H "Idempotency-Key: 7f1c" \
-d '{"trigger_id": "trg-chat", "message": "Summarize yesterday'"'"'s incidents", "wait": true}'

The run starts while you wait. With wait the reply carries the step outputs when the run finishes within the trigger's wait_seconds (up to 60), otherwise it returns the run id to follow on GET /v1/workflows/runner/runs/{run_id}/steps. An Idempotency-Key returns the first fire for a repeated request instead of starting another run.

A form declares its fields as text, long text, number, select or boolean, and GET /v1/triggers/form/schema returns them for rendering. POST /v1/triggers/form/submit checks required fields, lengths, number bounds and select options and answers 422 with the message per field before anything starts. Anonymous forms are not supported, every caller needs a key or a session, and read-only roles can view a form but not submit it or chat.

Failures and auto-disable​

OutcomeMeaning
startedThe run started
skipped / rate_limitedThe trigger fired more than max_fires_per_minute
skipped / overlapA run of an earlier cron fire is still going
refused / trigger_disabledThe trigger was disabled, deleted or no longer validates
refused / tenant_mismatchThe bound key now belongs to another organization
refused / actor_denied (key reassigned)The bound key now belongs to another user
refused / actor_denied / gate_denied / definition_unavailableThe key, an agent or the definition refused the run
failed / attempts_exhaustedA passing condition did not clear within five attempts
refused / source_deniedA Slack, Teams, mail or calendar event came from a sender, place or workspace outside the trigger's access mapping. It never counts toward auto-disable and keeps none of the message

A runner that is turned off, a key that cannot be checked right now, an agent kill switch, a disabled agent and a halted definition are retried with backoff and never count against the trigger. Refused chat and form fires go back to the caller and never count either, since they come from the caller's own key or input. Five refusals in a row of a webhook, cron or event trigger turn it off with the refusal as disabled_reason, write an audit row and send a workflow_trigger_disabled alert. POST /v1/triggers/enable turns it back on and clears the count. Deleting the definition a trigger starts, or uninstalling the template that created it, turns the trigger off right away with disabled_reason set to definition_deleted or template_uninstalled, so point it at another definition before you turn it back on.

Admin UI​

The Triggers tab of the Workflow Runs page under Agentic lists the triggers you can see with their kind, the saved workflow and version they start, whether they are on and when a schedule fires next. New trigger opens a form that changes with the kind you pick.

  • Signed webhook asks for the largest body it accepts. After you create it, the signing secret and the webhook URL show once, so copy them then.
  • Schedule asks for a cron expression, a time zone and what to do when the previous run is still going.
  • Gateway event asks whose events it hears and for the subscriptions as a JSON list, and lists every event type you can subscribe to.
  • Chat message asks how many seconds to wait for the reply.
  • Form asks for a title and the fields as a JSON list.

Every kind picks the saved workflow and version it starts, an optional input mapping, the most fires per minute and who can see it. Webhook, schedule and event triggers also pick the key they run as from your own keys and need a run budget, and the form explains both. A trigger's name opens its detail sheet with its state, webhook URL, the end of its secret, its run budget and its failures in a row, the fire history page by page with a link from each fire to its run, and the Manage actions. Edit, Turn off and Delete (after a confirmation) are there for anyone who manages it. Turn on, Rotate signing secret and Send a test fire with a sample payload are there only for the person whose key it runs as and for proxy admins, and everyone else sees a note saying so. A rotated secret shows once, and the old one keeps working for an hour. A chat trigger shows a message box and a form trigger shows its form, and both ask which of your keys the run uses, because a dashboard session cannot run steps itself. Read-only roles see the triggers and their history but no button that changes anything. Without both the workflow_runner and workflow_triggers features, the tab names them.

Who can do what​

ActionWho
List and read triggersOwners, members of a team trigger's team, members of the trigger's organization for org triggers, proxy admins and admin viewers
Read fire history, the webhook URL and the secret hintThe trigger's owner, its team admins and proxy admins, plus admin viewers for reading
Create, update, delete and disableRoles that can write, on triggers they manage. Updating a webhook, cron or event trigger binds the editor's own key
Enable, rotate the secret of and test a webhook, cron or event triggerThe user whose key it runs as, or a proxy admin
Test a chat or form triggerRoles that can write, on triggers they manage, with their own virtual key
Use a chat or form triggerRoles that can write and can see it, as their own key

A custom role grants triggers.read and triggers.write. Read and write routes never share a path, so triggers.read never opens a write or an interactive start.

MethodPathPurpose
GET/v1/triggers/listTriggers you can see
GET/v1/triggers/infoOne trigger
GET/v1/triggers/firesFire history of a trigger
GET/v1/triggers/event_typesEvent types and their filters
POST/v1/triggers/newCreate a trigger
POST/v1/triggers/updateReplace a trigger's settings, keeping its kind and secret
POST/v1/triggers/deleteDelete a trigger and its fire history
POST/v1/triggers/enable, /v1/triggers/disableTurn a trigger on or off
POST/v1/triggers/rotate_secretIssue a new webhook secret, or store the new one Slack or Teams issued
POST/v1/triggers/testQueue a fire with a sample payload of at most 256 KiB, counted toward the per minute limit
POST/v1/triggers/webhook/{trigger_id}Signed inbound webhook, no key
POST/v1/triggers/chatSend a message to a chat trigger
GET/v1/triggers/form/schemaA form trigger's fields
POST/v1/triggers/form/submitSubmit a form trigger

Creating, updating, deleting, enabling, disabling (including auto-disable), rotating, testing and rebinding a trigger each write an audit row on Spanway_WorkflowTrigger. Audit rows hold the secret hint, never the secret or the bound key's hash. Each started run carries trigger_id, trigger_fire_id and trigger_kind in its metadata and initiated_by: trigger:<id> in its audit row.

Retention and data subject requests​

Fire rows are deleted after general_settings.workflow_triggers.fire_retention_days (default 30), or earlier with maximum_workflow_trigger_fire_retention_period or maximum_spend_logs_retention_period, whichever is shorter, so fires never outlive the spend logs. Processed outbox events are deleted on the same schedule. Erasing a user through data subject requests deletes the triggers they own or bound a key to, with their fire history, the fires their keys sent to other people's chat and form triggers, and outbox events scoped to them. It also removes the user, and the outside identity mapped to them, from the access mapping of other people's connected service triggers. A trigger left with nobody mapped, or with no place anyone may read, is turned off with the reason access_mapping_erased. Exports list those triggers and fires without payloads, and the access mapping entries that name the user under workflow_trigger_access.

Settings​

All under general_settings.workflow_triggers.

SettingDefaultEffect
enabledtrueRun the trigger jobs and accept trigger writes
inbound_webhooksfalseServe the public signed webhook route, so outside systems can start workflows. Off by default because it opens a route that needs no gateway key. Off, POST /v1/triggers/webhook/{trigger_id} answers 404 and webhook triggers never fire. A platform admin turns it on after putting the gateway behind the network rules they want
inbound_max_rps_per_pod50Inbound webhook requests per second per replica
inbound_max_per_ip_per_minute600Inbound webhook requests per client IP per minute
cron_poll_seconds15How often each replica looks for due cron triggers
dispatch_poll_seconds2How often each replica claims pending fires
index_ttl_seconds30How long a replica caches the event types triggers subscribe to
fire_retention_days30Days fire rows and processed events are kept
min_cron_interval_seconds60Shortest allowed gap between two cron fires

Settings that fail to validate turn triggers off and log the error. The per minute limits are shared across replicas when Redis is configured and counted per replica otherwise.

Errors​

StatusWhat it meansFix
403 license messageThe license lacks workflow_triggers or workflow_runner.Add the features to the license or ask sales@spanway.ai.
403 "Your role can read workflow triggers but not change them"A read only role tried to create, edit or operate a trigger.Use a role with workflows.write.
401 {"error": "invalid signature"} on a webhook deliveryThe signature is missing or wrong, it was signed with a secret rotated more than an hour ago, or the trigger id is wrong or the trigger is off. The answer is the same in every case, so a caller cannot probe for trigger ids.Check the trigger id and its State, and update the sender with the current secret from Rotate signing secret.
404 on a webhook deliveryInbound webhooks are disabled on this gateway.Turn on the inbound_webhooks setting.
409 "Workflow triggers are disabled on this gateway"The workflow_triggers.enabled setting is off.Turn it on in the settings.
409 "The trigger changed while you edited it; reload and try again"Someone saved the trigger between your read and your update.Reload and apply your change again.
413The body is larger than the trigger's max_body_bytes or the gateway cap, or the sample payload is too large.Raise the limit on the trigger or send a smaller body.
422The trigger kind cannot change, the key is not an active virtual key, the plan allows no more triggers, or the stored trigger no longer validates.Follow the detail, for example create a new trigger instead of changing the kind.
429 {"error": "too many requests"} on a webhook deliveryThe gateway, the sender's address or the trigger got more deliveries in one minute than its limit allows.Raise the trigger's limit or slow the sender.
429 "The trigger fired more than its per-minute limit" on a chat message or formMore chat messages or form submissions than the trigger's limit arrived in one minute.Raise the limit or wait a minute.
Trigger turned itself offToo many fires failed in a row.Read the last failures in Fire history, fix the cause and click Turn on.

Logs​

The trigger jobs write these lines to the gateway log. None of them carries the fire payload. The same rows are in the log reference.

LevelLineMeaningAction needed
ERRORgeneral_settings.workflow_triggers is invalid, triggers are off: <error>The settings block does not validate, so no trigger fires.Fix the setting the error names and restart.
WARNINGworkflow trigger <trigger id> disabled: <reason>A trigger turned itself off, for example after repeated failures or a stored config that no longer validates. The change is in the audit log as system:workflow_triggers.Fix the cause and click Turn on.
WARNINGworkflow trigger disabled alert failed: <error>The alert about a turned off trigger was not delivered.Check the alerting integration.
WARNINGworkflow trigger fire <fire id> could not be settled: <error>A fire's result could not be saved and is retried.Check the database if it repeats.
WARNINGworkflow trigger event was not published: <error>, workflow trigger event <id> was not queued: <error> or workflow trigger event <id> kept for retry: <error>A gateway event an event trigger listens for was delayed.Check the database if it repeats.
ERRORworkflow trigger event buffer is full; dropping <id>Events arrived faster than they could be saved, and the oldest was dropped.Check the database and the load on this replica.
WARNINGworkflow trigger outbox event <id> failed: <error> or ERROR workflow trigger outbox event <id> has an unknown shapeOne stored event could not be delivered to its triggers.Check the database, the event stays in the outbox until it is handled.
WARNINGCould not register workflow trigger metrics: <error>The trigger metrics are missing from /metrics.Check that only one process registers them.