Skip to content

Webhook Triggers

Availability: Test environment In production the route answers 404 and the management operations FORBIDDEN. Since 2026-11 /status

Where the platform switch FEATURE_WEBHOOK_TRIGGER_ENABLED is off, the public route answers 404 to every request and the management operations are refused with FORBIDDEN.

A webhook trigger is a public URL that starts the published workflow of one of your AI employees when an outside system (a billing system, Zapier, n8n, your own backend) sends it a signed JSON request. Each accepted delivery runs the agent’s workflow as a headless task, with the spend caps and per-workspace limits that already apply to runWorkflowTask.

Only the workspace owner can create and manage triggers.

Triggers are managed with GraphQL, using the signed-in owner’s login (a dashboard JWT). In the workspace app the same screens live under Developers, Webhook triggers: list, create, switch on and off, rotate the secret, delete.

mutation CreateWorkflowTrigger($input: CreateWorkflowTriggerInput!) {
createWorkflowTrigger(input: $input) {
secret
warning
trigger {
id
publicId
path
authMode
secretPrefix
enabled
}
}
}
{
"input": {
"agentId": 7,
"name": "Billing system",
"variableMapping": [
{ "from": "invoice.id", "to": "invoiceId", "type": "STRING" },
{ "from": "invoice.total", "to": "total", "type": "NUMBER" }
]
}
}
Input fieldNotes
agentIdAn agent of your workspace. Each delivery runs that agent’s published workflow, so the agent must be active and have a workflow when deliveries arrive.
nameA label for the integration that will call it, at most 120 characters.
authModeHMAC (default, signed deliveries, recommended) or BEARER (the secret itself travels in every request; use it only when the caller cannot sign).
variableMappingWhich body fields become workflow variables, at most 32. Leave it empty to start the workflow with no variables. Fields you do not map are always dropped.

A mapping entry has from (a dotted path into the JSON body such as invoice.id, at most 6 names, no array indexes), to (the variable name: starts with a letter, letters, digits and _, at most 64 characters; runner names such as userMessage are refused) and type (STRING, NUMBER or BOOLEAN).

The result contains the signing secret (it starts with whsec_). It is returned once, when the trigger is created or its secret is rotated, and cannot be read again. Store it immediately. The trigger record keeps only the first 12 characters (secretPrefix) so you can tell secrets apart; that is not enough to sign anything. The secret is never put in a URL.

POST /hooks/v1/<publicId>
Content-Type: application/json
X-Wetel-Signature: t=1731240000,v1=<hex HMAC-SHA256>
Idempotency-Key: invoice-1042 (optional)
  • Host and path. POST to the path returned as trigger.path (/hooks/v1/<publicId>) on the Wetel API host.
  • Body. JSON only (application/json), at most 256 KB. A compressed body is refused.
  • Signature. X-Wetel-Signature: t=<unix seconds>,v1=<hex>, where v1 is the lower-case hex HMAC-SHA256 of the string <t>.<raw body> (the timestamp, a dot, the exact bytes you send) keyed with the secret. A delivery whose t is more than 300 seconds from the server’s clock is refused.
  • Bearer mode. Send Authorization: Bearer <secret> instead.
  • Idempotency. An optional Idempotency-Key header (at most 128 characters of letters, digits, ., _, : or -) makes a retry start the run only once. Without it, a signed delivery is still de-duplicated by its own signature, so an exact replay of a captured request never runs twice.
import { createHmac } from "node:crypto";
const body = JSON.stringify({ invoice: { id: "INV-1042", total: 129.5 } });
const t = Math.floor(Date.now() / 1000);
const v1 = createHmac("sha256", process.env.WETEL_TRIGGER_SECRET)
.update(`${t}.${body}`)
.digest("hex");
await fetch(`${process.env.WETEL_API_HOST}/hooks/v1/${publicId}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Wetel-Signature": `t=${t},v1=${v1}`,
"Idempotency-Key": "invoice-1042",
},
body,
});
StatusBodyMeaning
202{ "status": "queued", "sessionId": 123 }Accepted and queued. A repeat of the same idempotency key answers 202 with the same sessionId.
404the same body every timeAny pre-authentication failure (see below).
400invalid_body or invalid_idempotency_keyThe body is not valid JSON, or the key has a bad shape.
413payload_too_largeOver 256 KB.
415unsupported_media_typeNot application/json, or encoded.
409in_progress or not_runnableThe first delivery with this key has not finished queueing (retry in a few seconds), or the agent cannot run now.
429rate_limited or busyA limit was hit; wait the retryAfterSeconds in the body.
503unavailableA supporting service is down. The route fails closed; retry later.

Every failure before authentication is the same 404: the feature is off, the id is malformed or unknown, the trigger is deleted or switched off, the signature is missing, malformed, stale or wrong. A caller, or an attacker, cannot tell these apart. This is on purpose. The reason for a refused delivery to a trigger that exists is shown to you, the owner, in lastRejectReason (below).

The delivery’s outcome is read with workflowTaskOutcome(sessionId) with workflowTaskOutcome, which uses an API key rather than the trigger secret.

All of these are workspace owner only and use a dashboard JWT.

OperationWhat it does
workflowTriggers(first, after)Lists your triggers, newest first, with a Relay cursor (first default 20, max 100). Shows lastUsedAt, lastRejectedAt and lastRejectReason. Never returns a secret.
createWorkflowTrigger(input)Creates one and returns the secret once. FORBIDDEN while the platform flag is off.
rotateWorkflowTriggerSecret(id)Issues a new secret, shown once. The old one stops working at once on the process that handles the call and within about 30 seconds on every other process, so update the caller first. The URL does not change.
setWorkflowTriggerEnabled(id, enabled)Switches a trigger on or off. While off, every delivery gets the same 404 as an unknown trigger. Switching on is refused while the platform flag is off; switching off always works.
deleteWorkflowTrigger(id)Deletes it. Its URL answers 404 from then on and its secret is discarded. It cannot be undone; create a new trigger instead.

lastRejectReason is one of signature_missing, signature_malformed, signature_stale, signature_mismatch or disabled. It is updated at most once a minute, and the delivery’s body, headers and secret are never logged or returned.

  • 256 KB per body.
  • A per-trigger rate limit (60 a minute by default) applied after the signature check, so a forger cannot use up the real caller’s allowance, and a per-address limit applied before any lookup.
  • Each accepted delivery counts like any workflow task against the workspace’s spend and concurrency caps and appears in the task invocation record, with the trigger as its origin.