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.
When Claude writes error messages, button labels, validation text, or onboarding flows, it defaults to generic developer-speak. Add a "Users" section to your CLAUDE.md describing who your actual users are — their technical level, industry jargon, and what they care about — so Claude writes copy that makes sense to THEM, not to developers.
Use the --agent flag with custom markdown files in .claude/agents/ to launch purpose-built Claude sessions with restricted tools and scoped system prompts.
Every project has traps — the billing module that silently fails if you forget to queue the job, the legacy table with column names that don't match the model, the config value that must be set before tests run. Document these gotchas in your CLAUDE.md so Claude avoids the same mistakes your team spent days debugging.