Guides

Webhooks

Give a task a web address that GitHub, Stripe, Slack or any service can call. Each call reaches the task's sandboxes, even one that starts after the call: nothing is lost while none is running.

Make one

From your code, an agent over MCP (task_webhook), or the agent inside the sandbox with its own task token:

Terminal
curl -X POST -H "Authorization: Bearer $ANNEX_TASK_TOKEN" \
  -H 'Content-Type: application/json' -d '{"name": "github"}' \
  "$ANNEX_URL/v1/workspaces/$ANNEX_WORKSPACE_ID/tasks/$ANNEX_TASK_ID/webhooks"

The answer has its url, shown only then: give it to the sender. Anyone with it can call it, so treat it like a password. GET …/webhooks lists a task's webhooks with how many calls each took; DELETE …/webhooks/{id} turns one off.

How calls arrive

  • deliver: "sandbox" (the default): Annex writes each call into the task's newest running sandbox as /tmp/annex-inbox/<webhook id>/<message id>.json.
  • Add command and Annex runs it there for each call, with the call on stdin and ANNEX_WEBHOOK_FILE set. If it doesn't exit 0, the call is tried again, 5 times at most.
  • deliver: "queue": calls wait on the task's queue (webhooks, or the queue you name) for your agent to claim, like any job. A sandbox webhook has a queue of its own, named after it, so the two never take each other's calls.

Each call is JSON: method, query, headers (the sender's own, signatures included, so you can check them), body (or body_base64 for bytes), from and received_at.

Limits

  • Bodies up to 128 KiB; 600 calls a minute per webhook; 20 webhooks per task.
  • A sender's retry of the same call (its Idempotency-Key, Webhook-Id or X-GitHub-Delivery) is taken once.
  • Annex answers 202 as soon as the call is safely queued, so senders never wait on your sandbox.
  • Calls wait a week at most, like the task's other queues.