Webhooks
Gateway can expose a small HTTP webhook endpoint for external triggers.Enable
hooks.tokenis required whenhooks.enabled=true.hooks.pathdefaults to/hooks.
Auth
Every request must include the hook token:Authorization: Bearer <token>- or
x-clawdbot-token: <token> - or
?token=<token>
Endpoints
POST /hooks/wake
Payload:
textrequired (string): The description of the event (e.g., “New email received”).modeoptional (now|next-heartbeat): Whether to trigger an immediate heartbeat (defaultnow) or wait for the next periodic check.
- Enqueues a system event for the main session
- If
mode=now, triggers an immediate heartbeat
POST /hooks/agent
Payload:
messagerequired (string): The prompt or message for the agent to process.nameoptional (string): Human-readable name for the hook (e.g., “GitHub”), used as a prefix in session summaries.sessionKeyoptional (string): The key used to identify the agent’s session. Defaults to a randomhook:<uuid>. Using a consistent key allows for a multi-turn conversation within the hook context.wakeModeoptional (now|next-heartbeat): Whether to trigger an immediate heartbeat (defaultnow) or wait for the next periodic check.deliveroptional (boolean): Iftrue, the agent’s response will be sent to the messaging provider. Defaults tofalse. Responses that are only heartbeat acknowledgments are automatically skipped.provideroptional (string): The messaging service for delivery. One of:last,whatsapp,telegram,discord,slack,signal,imessage. Defaults tolast.tooptional (string): The recipient identifier for the provider (e.g., phone number for WhatsApp/Signal, chat ID for Telegram, channel ID for Discord/Slack). Defaults to the last recipient in the main session.modeloptional (string): Model override (e.g.,anthropic/claude-3-5-sonnetor an alias). Must be in the allowed model list if restricted.thinkingoptional (string): Thinking level override (e.g.,low,medium,high).timeoutSecondsoptional (number): Maximum duration for the agent run in seconds.
- Runs an isolated agent turn (own session key)
- Always posts a summary into the main session
- If
wakeMode=now, triggers an immediate heartbeat
POST /hooks/<name> (mapped)
Custom hook names are resolved via hooks.mappings (see configuration). A mapping can
turn arbitrary payloads into wake or agent actions, with optional templates or
code transforms.
Mapping options (summary):
hooks.presets: ["gmail"]enables the built-in Gmail mapping.hooks.mappingslets you definematch,action, and templates in config.hooks.transformsDir+transform.moduleloads a JS/TS module for custom logic.- Use
match.sourceto keep a generic ingest endpoint (payload-driven routing). - TS transforms require a TS loader (e.g.
bunortsx) or precompiled.jsat runtime. - Set
deliver: true+provider/toon mappings to route replies to a chat surface (providerdefaults tolastand falls back to WhatsApp). clawdbot hooks gmail setupwriteshooks.gmailconfig forclawdbot hooks gmail run. Seedocs/gmail-pubsub.mdfor the full Gmail watch flow.
Responses
200for/hooks/wake202for/hooks/agent(async run started)401on auth failure400on invalid payload413on oversized payloads
Examples
Use a different model
Addmodel to the agent payload (or mapping) to override the model for that run:
agent.models, make sure the override model is included there.
Security
- Keep hook endpoints behind loopback, tailnet, or trusted reverse proxy.
- Use a dedicated hook token; do not reuse gateway auth tokens.
- Avoid including sensitive raw payloads in webhook logs.