Skip to content

Webhook triggers API

A webhook trigger lets an external system start an agent run by calling a unique inbound URL. It is the event-driven counterpart to the time-based scheduler: instead of a clock, an inbound HTTP POST fires the run.

Each trigger has:

  • a unique URL path POST /hooks/{token} on the public inference host (https://ai-api.myra.eu), where {token} is a 128-bit random hex string, and
  • a secret, sent in the X-AIG-Webhook-Secret request header.

The run executes as the agent's owner (agent.created_by) — the same run-as-owner identity the scheduler uses — with exactly the tools that owner configured on the agent. The caller supplies only the token, the secret, and a payload; the agent, owner, tenant and gateway are all resolved server-side from the stored trigger, so a caller can never target another agent, owner or tenant.

Only a hash of the secret is stored (sha256); the plaintext secret is shown once at creation and cannot be retrieved afterwards.


Firing a trigger (public, no session)

POST https://ai-api.myra.eu/hooks/{token}
X-AIG-Webhook-Secret: {secret}
Content-Type: application/json

{ "any": "json or text payload" }

Configure your sender with the API host directly

The receiver lives on the public inference host (https://ai-api.myra.eu). A request that reaches the app host (https://ai.myra.eu/hooks/{token}) is answered with a 307 redirect to the API host — a browser or curl follows it, but many webhook senders (Stripe, GitHub, GitLab, …) treat any 3xx as a failed delivery and will not re-POST. Always register the API-host URL the product shows you; never the app host.

Accepted request shape:

Part Accepted Rejected → status
Method POST only any other → 405
Path /hooks/{token}, {token} = 16–64 hex chars malformed → 404 {"error":"not found","code":"not_found"}
X-AIG-Webhook-Secret non-empty, sent once; must match the trigger secret missing/empty/repeated → 401; wrong → 403
Body any UTF-8, ≤ 32 KiB > cap → 413 (a body over 64 KiB is refused at the edge without a code, see Rejection behaviour); non-UTF-8 → 400
Trigger lookup the trigger row is readable transient database fault → 500 {"error":"internal error","code":"internal_error"} (retry)
Rate per-client-IP failed-authentication budget, then per-trigger and per-tenant limits (see below) exceeded → 429
Tenant suspension (needs AIG_TENANCY_ENABLED) the trigger's tenant is not suspended; checked after the per-trigger and per-tenant limits and before the body is read suspended → 403 {"error":"forbidden","code":"forbidden"}, byte-identical to a disabled trigger, nothing enqueued, no failed-authentication charge; state unreadable → 503 temporarily_unavailable (retry)
Backpressure ≤ 50 unstarted runs already queued for the trigger exceeded → 429; count unreadable (transient DB error) → 503 (retry)
Agents feature the tenant's Agents feature must be enabled (agent triggers) disabled → 503
Trigger still enabled at enqueue (agent triggers) the trigger is re-checked on the locked row when the run is written disabled or deleted meanwhile → 403 (as a disabled trigger); the row held by a concurrent change for more than a few seconds → 503 (retry)

Rate limits. Three independent limits apply, so one caller's traffic cannot block another's:

  • Failed authentication, per client IP: 60 failures (malformed path, missing/wrong secret, unknown or disabled token) per fixed 60-second window (IPv6: per /64 — see How the public rate limits behave). Once spent, further calls from that client IP get 429 until the window passes, even with a valid secret. Successful calls never count against it. The client IP is the leftmost X-Forwarded-For entry (the edge's peer address if absent), so callers behind the same CDN edge do not share a budget. That address is taken from a client-supplied header, so a caller that reaches the origin directly can spend another address's failure budget or rotate addresses to dodge its own; neither weakens authentication, because no call is accepted (202) without the secret, which is compared in constant time. All malformed or blank forwarded addresses share one bucket.
  • Per trigger: 60 accepted-secret calls per sliding 60 seconds.
  • Per tenant: 600 accepted-secret calls per sliding 60 seconds across all of the tenant's triggers.

These limits are only reached after the secret is verified, so a missing or wrong secret never gets a 429 from them; only the per-client-IP failure budget can, and it treats known and unknown tokens the same.

Success returns 202 Accepted:

{ "status": "queued", "run_id": "…" }

The run is enqueued, not executed on the inbound connection. It is picked up by the scheduler on its next tick, so end-to-end latency is ≤ ~one scheduler tick (about a minute) plus the run's own execution time. Delivery is at-most-once: each fire is its own durable run, so a burst of N calls yields N runs (no collapse), and a crash mid-run marks that run failed rather than re-running it. Under sustained overload the queue drains FIFO; the 429 backpressure above bounds how far it can grow. There is no de-duplication — if your producer retries, it enqueues another run, so make retries idempotent on your side.

For an agent trigger — and a workflow trigger too (see Firing a workflow trigger) — the run and the trigger's last_fired_at are written in one transaction, behind a re-check that the trigger is still enabled: either both are stored (and the response is 202), or neither is (and the response is an error — 403, 503 or 500), so a producer retry after an error does not duplicate a stored run. The one exception is a 500 caused by the database connection dropping while the commit was in flight: the run may then have been stored — as with any HTTP producer, make retries idempotent on your side (see "no de-duplication" above). A fire that arrives while the trigger is being disabled or deleted waits for that change and is then refused with 403; no run is created for it.

A fire for an agent that is paused after an owner hand-over (Confirming a hand-over) is refused with the same 403; no run is created. Triggers work again once the new owner confirms.

A fire for an agent that is flagged or disabled by its governance review is refused with the same 403; no run is created. Triggers work again once a reviewer approves the agent. Runs already queued before the flag still drain and end as failed with the reason AGENT_REVIEW_BLOCKED.

The same holds for an agent paused by automatic protection: the fire is refused with 403, no run is created, and queued webhook runs of that agent are not executed.

Rejection behaviour (fail-closed)

A suspended tenant's trigger answers the same 403 forbidden as a disabled one (same status, body and headers), but not the same side effects: a suspended call is charged against the per-trigger and per-tenant windows, a disabled trigger against the failed-authentication budget. A suspension state that cannot be read answers 503 temporarily_unavailable. Neither counts against the failed-authentication budget. The suspension check only runs with the tenancy switch on (AIG_TENANCY_ENABLED); with it off nothing changes for suspension. The workflow tenant-mismatch refusal does not depend on the switch. (tests: tests/unit/test_webhook_inbound_handler.lua "MAP-4357 agent: suspended -> 403 forbidden", "MAP-4357 workflow: suspended -> 403 forbidden, byte-identical to disabled trigger", "MAP-4357 workflow tenant mismatch -> 403 forbidden, nothing fired"; frontend/tests/contracts/map4357-suspended-webhooks.spec.ts "suspended: both triggers -> 403 forbidden, byte-identical to an unknown token; nothing enqueued")

Every rejection enqueues no run. To avoid a token-existence oracle, an unknown token, a disabled trigger, and a wrong secret all return an identical 403 {"error":"forbidden","code":"forbidden"}; a missing or empty secret header returns 401 with code webhook_secret_required, and a repeated one 401 with invalid_webhook_secret, before any lookup. Every JSON error produced by the handler carries a top-level code (for example rate_limited, payload_too_large, bad_utf8, invalid_payload, number_not_exact, number_invalid, invalid_idempotency_key, idempotency_key_too_long, too_many_pending_runs, temporarily_unavailable); the status and the error sentence are unchanged. There is one exception. A body over the edge limit (64 KiB on /hooks/) is refused by the front end before the handler runs, with 413 {"error":"payload_too_large"} and no code. A body of 32–64 KiB reaches the handler and gets the coded 413 {"error":"payload too large","code":"payload_too_large"}. Key off status 413 (or the error token), not code, for oversize bodies. A spooled body the server cannot read answers 503 temporarily_unavailable (retry) rather than being treated as empty. See Typed codes on the webhook receiver and the chat-bridge endpoints. The secret and its hash are never echoed in a response or written to a log.

Security note — the payload is untrusted data

The webhook body becomes the agent's user turn, wrapped in an explicit data-not-instructions envelope. A model can still be influenced by a user turn, so every agent run started by a webhook carries a server-derived untrusted-content mark (level snapshot, see Untrusted content holds). The mark comes from the stored run, never from a request field or header. On a marked run a call that sends data to an address the model chooses (fetch_url, agentic_fetch, web_search) and a write or destructive connector call is held for approval instead of running, so an injected instruction cannot exfiltrate data unattended. Legitimate work, such as reading through a connector, runs unattended. An agent that already ran unattended before the mark was introduced keeps the tools its consent snapshot granted on a plain webhook run. Even so, only expose a trigger for an agent whose tool access you are willing to drive with external input, or set the no-egress profile below for the strictest handling.

Held for approval

A webhook fire answers 202 with a run_id. If the run calls a connector tool that needs approval (a write or destructive tool), the run suspends instead of running the call. The approver of the hold (the agent owner) is notified by email, by push and, when they have linked a chat bridge, by a chat direct message, and decides in the Activity view or through /admin/v1/me/tool-approvals.

  • Approve: the call runs exactly once and the run continues.
  • Reject: the call is not run, the denial is passed to the run, and the run continues.
  • Expiry (no decision in time): the call is not run, the run fails, and the agent owner is notified by email.

A direct agent webhook run carries the untrusted-content mark described above, so the holds apply to its egress tools and its write or destructive connector calls. If the agent requires a task envelope, the run is scoped by the static envelope you configured on the trigger (see Task envelope); with none configured, every connector call is refused with task_envelope_missing (the approval and outside-task holds never apply to such a call, not even under on_outside_task: "approval"; a tool on the agent's own gate list is not held either: a call the task envelope refuses is refused at once and never held for approval. In a held batch, a same-name sibling call the envelope refuses is shown to the reviewer and refused at execution).

A workflow started by a webhook is marked the same way. Its Fetch node refuses or holds a model-derived URL for the workflow owner, and its Connector node holds a call whose arguments a model wrote; see the Fetch node. A Fetch inside a loop body is held per iteration like one in a plain step (a Connector node cannot be placed in a loop body). A call on a run without an owner is refused (403 untrusted_egress_refused) rather than held; such a run cannot start or resume, so only an owner removed mid-run reaches this. A Fetch URL with a fixed host is confined to that origin on every marked run: a redirect to another origin is held for the workflow owner (the approval binds the redirect target's origin) instead of being followed. An upgrade on the same host from http to https (port 80 to 443, or the same explicit port) is the same origin and is followed; a downgrade or any other port change is a different origin, and a second off-origin redirect is refused (422 once the approval is spent). See the Fetch node.

No-egress profile (no_egress)

Set no_egress: true when creating a trigger to run its fires at the strict level of the untrusted-content mark. The run keeps every tool the agent was configured with; nothing is stripped. What changes is that the grandfathered exemption does not apply, so every egress is held for approval, even for an agent that ran unattended before.

Tool On a no_egress webhook run
fetch_url / agentic_fetch / web_search held for approval (untrusted_egress); the grandfather exemption is ignored
External MCP connector, write or destructive tool held for approval
External MCP connector, read tool runs under the connector's consent, envelope and parameter rules
Sub-agent delegation the child inherits the strict mark; its egress calls are held for approval on the parent's run (one review for the parent); a child that cannot hand the hold to its parent has them refused
Image generation, video, background removal run: they use the provider configured on the gateway, not an address the model chooses
Code interpreter runs: the sandbox is Myra-owned and has no network access

Webhook runs of earlier releases that set no_egress had these tools removed, including the code interpreter. The profile no longer removes tools: code execution is now available for such runs, and egress is governed by the holds above instead.

Local project tools (read_file / write_file / edit_file / knowledge search) are available as before.

The profile is opt-in and never forced (default false). It is enforced server-side and is fail-closed: a run inherits the flag its trigger had when it fired (snapshot), so re-toggling the trigger does not change already-queued runs. An unreadable or unexpected stored value is treated as strict.


Managing triggers (admin plane)

Admin endpoints require an authenticated admin session and gateway access; the base URL is https://ai-api-admin.myra.eu/admin/v1. The base URL's gateway must be reachable by the caller (another tenant's gateway is 404), and the tenant's Agents feature must be on (403 { "error": "feature_disabled", "feature": "agents" }; a failed read of that flag is 503).

Route Permission Who may act on a trigger
GET …/webhook-triggers none beyond gateway access the agent's owner, or a tenant_admin / admin
POST, PATCH, DELETE AGENTS_AUTHOR (built-in: member, KI-Manager, tenant_admin, admin, or a custom role granting it; viewer / demouser are refused 403) the agent's owner, or a tenant_admin / admin

An agent the caller may not manage answers 404 { "error": "agent not found", "code": "agent_not_found" } on the list and create routes, the same answer as an unknown agent. Create is also refused 403 { "error": "impersonation_forbidden", "code": "impersonation_forbidden" } while an administrator impersonates a user.

The same operations are available in the admin UI under an agent's Triggers tab, in the Webhooks section (create — which reveals the secret once — list, enable/disable, delete, and copy the /hooks/{token} URL). The endpoints below are the exact calls that panel makes.

Create

POST /admin/v1/gateways/{gateway}/agents/{agent}/webhook-triggers
{ "name": "PagerDuty alerts", "prompt": "Summarize this alert.", "no_egress": true,
  "task_envelope": { "v": 1, "connectors": { "<connector id>": { "*": { "customer": ["ACME"] } } } } }
// prompt optional; no_egress optional (default false — see the no-egress profile above);
// task_envelope optional (absent or null = none — see Task envelope below)

201 returns the secret once:

{
  "id": "…",
  "name": "PagerDuty alerts",
  "enabled": 1,
  "agent_id": "…",
  "no_egress": 1,
  "task_envelope": null,                 // the configured envelope object, or null
  "url_path": "/hooks/ab12…",
  "secret": "…",                         // shown ONCE — store it now
  "secret_header": "X-AIG-Webhook-Secret"
}

400 { "error": "an externally hosted agent cannot have a webhook trigger", "code": "agent_external" } if the agent is an externally hosted agent (it has no model run to fire). 400 if name is missing, not a string, empty or longer than 255 bytes, prompt is not a string or is longer than 60000 chars, or task_envelope is present but not a valid envelope object (code: "invalid_task_envelope" with a reason, see Why an envelope is rejected), or no_egress is not a boolean (it is validated strictly — a truthy string/number is rejected, not coerced). There is no rotation endpoint; to change the secret, delete the trigger and create a new one. no_egress is set at creation; to change it, recreate the trigger.

The trigger and its webhook_trigger.created audit-log record are one transaction: if the audit record cannot be written, the trigger is not created either (a webhook URL never exists without a record of who minted it). The record carries the agent's own tenant and gateway, the actor, and the trigger's id / name / enabled / agent — never the token or the secret hash. If the agent was deleted after the request was checked, the answer is 404 { "error": "agent not found", "code": "agent_not_found" } and nothing is created; a create that kept colliding with concurrent database activity, waited out a lock, or found no database connection answers 503 (nothing created, retry); any other database fault is the opaque 500 { "error": "internal error", "request_id": "<id>" }.

List

GET /admin/v1/gateways/{gateway}/agents/{agent}/webhook-triggers

Returns each trigger's id (needed for the PATCH/DELETE {id} routes), agent_id, url_path, name, enabled, no_egress, task_envelope (object or null), secret_header, last_fired_at, and created_at — never the secret or its hash. Empty list is []. A stored envelope that no longer parses is shown as task_envelope: null with an extra task_envelope_invalid: true; runs of that trigger are refused (fail closed).

Changing the enabled state or the task envelope

PATCH /admin/v1/gateways/{gateway}/agents/{agent}/webhook-triggers/{id}
{ "enabled": false }
{ "task_envelope": { "v": 1, "connectors": { … } } }   // set or replace
{ "task_envelope": null }                                // clear

The body takes enabled (a boolean) and/or task_envelope; a key that is absent is left unchanged. A body with neither, a non-boolean enabled, or an invalid task_envelope is 400 and nothing is written. An invalid task_envelope answers with the same body as on create (see Why an envelope is rejected). Both keys in one request are applied together, in one transaction, with one audit-log record. The audit record carries only whether an envelope is set and a short fingerprint of it, never the envelope itself.

Disabling is a real kill switch: it also cancels any already-queued (pending) runs for that trigger, and a fire that is in flight while you disable is refused. A disabled trigger's URL returns 403. A run the scheduler has already started is not stopped — only queued runs are cancelled. A cancelled run is marked cancelled (a kill-switch outcome, not a gateway fault): it is not filed as a server error and does not page anyone.

The state change, the cancellation of the pending runs and the audit-log record are one transaction: they are stored together or not at all. If any part fails — including the audit record — nothing changes: the trigger keeps its previous state and its queued runs stay queued. The response is the trigger as stored (same shape as the list entries).

Task envelope

An agent can require a task envelope for its MCP connector calls. A webhook run has no workflow trigger to derive one from, so the owner configures a static envelope on the trigger (task_envelope on create or PATCH):

{ "v": 1, "connectors": { "<connector id>": { "*": { "customer": ["ACME"] } } } }
  • Every run of the trigger is stamped with it. A queued run uses the scope stored when the run starts, so a PATCH to the envelope applies to runs that start afterwards, not to the moment the request was accepted. The webhook request body never defines or alters the scope: a payload that names another customer, or carries task_envelope or connectors keys, is ignored for scoping.
  • Absent (null) differs from invalid. With none configured, a required template refuses every connector call with task_envelope_missing; a stored value that no longer parses is also refused (fail closed).
  • A call outside the scope is refused as outside_task, or held for approval if the agent's template sets on_outside_task: "approval".
  • The envelope only narrows: a connector the agent is not connected to stays unusable. A run resumed after an approval hold keeps the envelope it was stamped with, and a resume never reads the trigger again: a run that had no envelope when it was held stays without one, so deleting the trigger or adding an envelope to it during the hold changes nothing for that run.
  • Limits: a JSON object of at most 16 KiB encoded, exactly the keys v (must be 1) and connectors; at most 32 connectors, 64 tools per connector, 16 bound arguments per tool and 64 values per argument; keys up to 128 bytes, values up to 512 bytes, string values only. A rejected envelope says which limit it broke (see Why an envelope is rejected). See Task envelope for the full shape and semantics.
  • Troubleshooting: connector calls on a webhook run refused with task_envelope_missing mean the agent's template is required and this trigger has no envelope. Set one with PATCH.
  • The envelope is part of the tenant data export (webhook_triggers).

Why an envelope is rejected

A rejected task_envelope (create or PATCH) answers 400 with code: "invalid_task_envelope" and a reason (plus, where it applies, a path), so a caller can fix the request without guessing:

{ "error": "task_envelope invalid", "code": "invalid_task_envelope",
  "reason": "too_many_values", "path": { "connector": "crm", "tool": "*", "arg": "customer" } }

reason is always one of this closed list:

reason Meaning
too_large the encoded envelope is over 16 KiB
too_many_connectors more than 32 connectors
too_many_tools more than 64 tools under one connector
too_many_args more than 16 bound arguments under one tool
too_many_values an argument has no values, or more than 64
value_too_long a value is longer than 512 bytes
key_too_long a connector, tool or argument name is longer than 128 bytes
bad_shape anything else: not an object, a wrong v, an unknown or missing key, an empty name, a value that is not a non-empty string

path is optional and says where in the envelope the reported problem is. It holds up to three fields, connector, tool and arg, each a name from your own request. It never contains a value, and it leaves out a name that is itself too long, so for key_too_long it points at the parent only. A request with several problems reports one of them; fix it and resend to see the next.

Delete

DELETE /admin/v1/gateways/{gateway}/agents/{agent}/webhook-triggers/{id}

Cancels the trigger's still-pending runs and removes it — again one transaction with its audit record (all or nothing). Answers 200 {"ok": true}. Create/enable/disable/delete are recorded in the gateway audit log (never with the token or secret hash).

Both {id} routes answer 404 { "error": "trigger not found", "code": "trigger_not_found" } when the trigger does not exist on this gateway or belongs to an agent you cannot manage (another member's agent, or the agent is gone) — one answer for both, so the response never reveals whether another member's trigger exists (also when the trigger is deleted between the lookup and the change). A failed read on these routes (the trigger or its parent-agent lookup) answers 503 { "error": "temporarily unavailable; retry later" } (nothing written; retry); a failed write answers an opaque 500 { "error": "internal error", "request_id": "<id>" } unless nothing was written (the retryable 503 below) — never a 404, never driver text. When the change kept colliding with concurrent database activity, waited out a lock held by another change (a lock wait is never repeated), or found no database connection, the answer is 503 { "error": "temporarily unavailable; retry later" }: nothing changed, retry. A 500 normally means nothing changed either; only a connection lost while the change was being committed can leave it stored, so after a 500 list the triggers (GET …/webhook-triggers) to see the current enabled state before retrying.


Workflow triggers (event-driven Baukasten runs)

A webhook can also fire a visual Workflow (Baukasten) run instead of an agent run — the "event trigger" for a workflow. The same POST /hooks/{token} receiver is reused (identical method / rate-limit / secret / body-cap / UTF-8 rules above); the only difference is what the fire enqueues and how the body is interpreted.

A workflow trigger is created on the workflow, not an agent, and is limited to one per workflow (MVP):

GET    /admin/v1/gateways/{gateway}/workflows/{id}/webhook   → the trigger, or {"webhook": false}
POST   /admin/v1/gateways/{gateway}/workflows/{id}/webhook   → create (reveals the secret ONCE); 409 if one exists
DELETE /admin/v1/gateways/{gateway}/workflows/{id}/webhook   → delete + cancel the workflow's pending webhook runs

GET returns 200 { "webhook": { "id", "enabled", "last_fired_at", "url_path", "secret_header" } } (never the secret). POST takes an optional name (a non-string or empty value becomes "Webhook"; longer than 255 bytes is cut to 255) and answers 201 { "id", "enabled": 1, "url_path", "secret", "secret_header": "X-AIG-Webhook-Secret" } — the secret only here. A second POST is 409 { "error": "webhook already exists", "code": "webhook_exists" }. Every refusal on this route carries a typed code. POST is refused 403 { "error": "impersonation_forbidden", "code": "impersonation_forbidden" } while an administrator impersonates a user. An unknown workflow is 404 { "error": "not found" }.

The DELETE is one transaction: the workflow's still-pending webhook runs are cancelled (error_code webhook_trigger_deleted, payload cleared) and the trigger row is removed together, or not at all — a fire that races the delete is ordered by the trigger row's lock and refused once the delete commits. It is idempotent: with no trigger, any webhook run still pending is cancelled and the answer is 200 {"ok": true}. A workflow deleted in the meantime → 404 {"error": "not found"}; a delete that kept colliding with concurrent database activity, waited out a lock held by another change, or found no database connection → 503 { "error": "temporarily unavailable; retry later" } (nothing changed); any other database fault → 500 { "error": "internal error", "request_id": "<id>" } (normally nothing changed; only after a connection lost while the change was being committed is the outcome unknown — check the trigger before retrying).

These require the WORKFLOWS_AUTHOR permission (the built-in member, ki_manager, tenant_admin, or admin roles, or a custom role granting it; viewer/demouser are refused 403), gateway access, and the workspace workflow feature flag — the same gate as the workflow build routes. The trigger stores the workflow's own tenant/gateway, so the fire path derives the run's identity (owner, tenant, gateway, version) entirely from the workflow — a caller can never target another tenant's workflow.

Firing a workflow trigger

POST https://ai-api.myra.eu/hooks/{token}
X-AIG-Webhook-Secret: {secret}
X-AIG-Idempotency-Key: {optional-key}
Content-Type: application/json

{ "betreff": "…", "prioritaet": "hoch" }

The body must be a JSON object. Its top-level fields become the trigger node's output, addressable in the builder as {{trigger.output.<field>}}.

Part Accepted Rejected → status
Tenant suspension (needs AIG_TENANCY_ENABLED) the trigger's tenant is not suspended; checked after the per-trigger and per-tenant limits and before the body is read suspended → 403 {"error":"forbidden","code":"forbidden"}, byte-identical to a disabled trigger, nothing enqueued, no failed-authentication charge; state unreadable → 503 temporarily_unavailable (retry)
Body a JSON object ({…}); empty body = {} a JSON array/scalar, or invalid JSON → 400; a key repeated in one object at any depth (also when one spelling uses an escape such as "\u0061") → 400 code duplicate_key (the message names the key when it is short printable ASCII; nothing is queued); more than 16,384 structural elements (each {, [ and , outside strings, plus each string) → 413 code body_too_complex (a body of 32 KiB or less that is mostly empty arrays can reach this; ordinary payloads such as a GitHub pull-request event stay far below it); a body containing a NUL byte (raw or after the JSON value) → 400 payload is not valid JSON; a number that cannot be kept exactly → 400 code number_not_exact; an integer with too many digits → 400 error number_too_long, code number_not_exact; a number that is not valid JSON → 400 code number_invalid (see JSON numbers); over cap → 413 (see the agent-trigger table for the edge limit); non-UTF-8 → 400
Workflow state published + workspace feature on; the trigger's tenant equals the workflow's tenant (independent of AIG_TENANCY_ENABLED, checked after the body checks above and before the workspace-feature gate) a trigger whose tenant differs from its workflow's tenant → 403 {"error":"forbidden","code":"forbidden"} with nothing enqueued; unpublished, feature off, or no published version → 403; the feature flag unreadable: a retryable fault → 503 {"error":"temporarily unavailable; retry later","code":"temporarily_unavailable"} with Retry-After: 1 and nothing enqueued, a permanent fault → 500 {"error":"internal error","code":"internal_error"}
Trigger state (re-checked at enqueue) the trigger is still enabled, the workflow still published with a current version disabled / deleted / unpublished after the request was checked → the same 403 (nothing enqueued); a lock held past a short bound, repeated conflicts, or no database connection → 503 (nothing enqueued, retry)
Backpressure ≤ 50 in-flight (pending + running + suspended) webhook runs exceeded → 429; count unreadable (transient DB error) → 503 (retry)
X-AIG-Idempotency-Key optional; a string ≤ 64 chars of A-Z a-z 0-9 - _ . :; collapses a retry to one run absent → each fire is its own run; longer than 64 bytes → 400 invalid idempotency key with code idempotency_key_too_long; illegal characters → 400 invalid idempotency key with code invalid_idempotency_key; sent more than once → 400 X-AIG-Idempotency-Key must be sent once with code invalid_idempotency_key

When a body has several defects the answer is, in order: over the byte cap 413 payload_too_large; non-UTF-8 400 bad_utf8; not a JSON object 400 invalid_payload; a raw NUL byte 400 invalid_payload; more than 16,384 structural elements 413 body_too_complex; invalid JSON 400 invalid_payload, or a non-finite number (NaN, Infinity, an overflow such as 1e400) 400 number_invalid / number_not_exact; a repeated key 400 duplicate_key; then the other number checks (inexact finite, too long, hex or other invalid spelling) 400. A non-finite value that a later repeat of its own key hides ({"a":NaN,"a":1}) answers duplicate_key. Only workflow triggers parse the body; an agent trigger passes any text through unchanged, so a repeated key is not an error there.

Success returns 202 { "status": "queued", "run_id": "…" }. The run is picked up by the dedicated workflow runner within ~2 s (not a full scheduler tick).

The enqueue is one transaction (the same shape as an agent trigger's fire): the workflow row and the trigger row are re-checked under their locks, the run is bound to the workflow's current version — the version whose number is the workflow's version (the last one published or rolled back to; two publishes in the same second can no longer bind the older one) — and is stored together with the trigger's last_fired_at, or nothing is stored. The run's owner, tenant and gateway come from the locked workflow row. A repeated fire with the same X-AIG-Idempotency-Key returns the existing run's id (and updates last_fired_at); once the trigger is disabled or deleted, or the workflow unpublished, it is refused with 403 like any other fire.

The payload is untrusted data — single-pass, never re-interpreted

The payload is treated as opaque data. Template resolution is single-pass: a graph template {{trigger.output.x}} is resolved exactly once, and the substituted value is never re-scanned — so a payload value that itself contains {{…}} (e.g. {"x": "{{secret.leak}}"}) is delivered/used literally, never expanded into another step's output. A missing field a template references is a fail-closed run error (template_unresolved), and a null on the path fails with template_null_path — the run never silently drops a slot. As with agent triggers, a payload value still becomes model input on an agent step, so design the workflow's steps to treat trigger fields as data; workflow delivery additionally passes the fail-closed PII gate (blocked_pii) before any egress.

Deletion / export

Deleting the trigger cancels the workflow's still-pending webhook runs (clearing their stored payload) and removes the config row; deleting the workflow cascades its trigger away. A fired run's payload is stored on workflow_run.trigger_input (bounded), which is exported with the run (Art. 15) and erased on tenant purge (Art. 17).


Data export

Webhook triggers appear in the tenant exit export (webhook_triggers section / webhook_triggers.csv) with the token (the URL path) but never the secret hash — the secret is unrecoverable and does not leave the gateway.

Numbers in webhook-trigger responses are written exactly. If a response cannot be encoded, the endpoint answers 500 with { "error": "internal error", "code": "response_encode_failed" }; see Error codes.