Use HTTP Hooks to Send Webhooks on Tool Execution
HTTP hooks send POST requests to a URL whenever a hook event fires, letting you integrate Claude Code with external services like Slack, PagerDuty, or a custom audit dashboard without writing shell scripts.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "http",
"url": "http://localhost:8080/hooks/tool-executed",
"timeout": 30,
"headers": {
"Authorization": "Bearer $WEBHOOK_TOKEN",
"Content-Type": "application/json"
},
"allowedEnvVars": ["WEBHOOK_TOKEN"]
}
]
}
]
}
}
The hook sends the full event payload as the POST body, including session ID, tool name, arguments, and output. Your endpoint can log it, send a Slack notification, or enforce custom policies.
Headers support environment variable interpolation with the $VAR_NAME syntax, but you must explicitly list allowed variables in allowedEnvVars for security. This prevents accidental leakage of sensitive environment variables.
HTTP hooks can also return decisions. A 2xx response with JSON containing "decision": "block" will block the action, just like a command hook returning exit code 2:
{
"decision": "block",
"reason": "This operation requires manager approval"
}
A 2xx response with plain text adds that text as context to Claude. Non-2xx responses and timeouts are treated as non-blocking errors, so your webhook endpoint going down will not break Claude's workflow.
Connect Claude Code to any HTTP service with zero scripting.
Log in to leave a comment.
The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.
The language setting makes Claude respond in your preferred language by default, across every session and project.
The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.