Webhooks
A webhook trigger is an authenticated endpoint that starts one Task Agent’s runs from outside Lunen — CI pipelines, alerting systems, form backends, anything that can POST. The run it creates is a normal run: same plan, same policy, same approvals, same audit trail.
Webhooks are inbound only. Lunen does not deliver outbound webhooks — there is no subscription for run or approval events.
Create a trigger
Triggers live in the Webhook Triggers section of a Task Agent’s side panel, once the agent has been saved. The agent’s owner creates them: give each a label, choose its authentication, and it gets its own URL and secret:
POST https://<your-lunen-host>/hooks/agents/task/{triggerId}
Choose the authentication mode at creation — it can’t be changed later:
| Mode | How callers authenticate | Use when |
|---|---|---|
| Bearer (no body) | Authorization: Bearer <secret> header; no body verification. | The caller can hold a secret header but not sign payloads. |
| HMAC (with body) | X-Lunen-Signature: sha256=<hex> — lowercase hex HMAC-SHA256 of the raw request body with the trigger’s key. | You send a payload and want it tamper-evident. |
The secret or signing key is shown once, at creation — copy it then; the
trigger card shows only its last few characters afterwards, plus a ready
curl example for HMAC triggers. A Task Agent can have up to 10 active
triggers.
Triggers can be disabled without being deleted, and secrets rotate from the
same panel — the previous secret keeps working for 24 hours so callers
migrate without a hard cut. An administrator can disable, rotate, or delete
any agent’s triggers, but only the agent’s owner can create or re-enable
one. Deleting a trigger is final: its URL answers 404 from then on.
Creation, enabling, disabling, rotation, and deletion are all
audit events.
Send a payload
An HMAC trigger’s request body, when there is one, must be a JSON object, up to 1 MiB. It becomes the run’s run input, delivered to the plan steps marked as consuming it — how an alert’s details or a form submission become the material the run works on. An empty body fires the run with no input. Bearer triggers take no body; they just fire the run.
BODY='{"incident":"sev2-4123","service":"checkout"}'
SIG=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_KEY" -r | cut -d' ' -f1)
curl -X POST "https://<your-lunen-host>/hooks/agents/task/$TRIGGER_ID" \
-H "Content-Type: application/json" \
-H "X-Lunen-Signature: sha256=$SIG" \
-d "$BODY"
Responses
Success is 202 Accepted — the run is created and queued, not awaited:
{ "runId": "…", "runUrl": "https://…/app/agents/task/…/…" }
Errors return { "error": "<message>" }, and the message says what to fix.
| Status | Meaning |
|---|---|
202 | Run created. |
400 | Body isn’t valid JSON, or isn’t a JSON object. |
401 | Authentication failed — missing or wrong secret, or a bad signature. |
403 | The agent’s owner isn’t allowed to run it. |
404 | Unknown or deleted trigger, or the agent was archived. |
409 | The trigger is disabled (checked before authentication), or the agent can’t run: it is disabled, has no plan steps, or hasn’t been accepted by its owner yet. |
413 | Body over 1 MiB. |
Semantics worth designing around
A 202 means the run exists, not that it will succeed. runUrl opens the
run in the dashboard for someone signed in; it is not a status API to poll.
Run-level guarantees apply as usual: if a run for the agent is already
active — including one waiting on an approval — the new run is
skipped and still answers 202, so a webhook
storm becomes a series of skips rather than a pile-up; and a triggered run
that hits an Approve-mode tool pauses for its owner like any other. Callers
wanting delivery certainty should treat non-202 responses as theirs to
retry — Lunen does not queue failed deliveries.
The HMAC signature covers the body only — there is no timestamp or nonce — so a captured request can be replayed. Keep the secret private, and design the agent so a repeated payload does no harm.