Claude Code HTTP hooks: headers and failure policy
Inspect allowedEnvVars and onFailure; a failed request is not automatically a block.
Configure URL, event and headers · Separate continuation from explicit blocking · Inspect the variable allowlist locally
At a glance
This page explains one configuration contract from official documentation and records the local synthetic checks. It changes no actual settings, runs no hook, creates no subagent and calls no external service. Documented capabilities are separate from execution results.
Runtime and applicability
- Article type
- Spec file
- Verified
- Applies to
- Claude Code Applies to the documented Claude Code configuration; version and event support appear in the body.
- Tools
File locations
| Path | Scope | How it is read |
|---|---|---|
settings: type=http Hook | The event or subagent configuration described in this page. | Read by Claude Code during relevant configuration loading and event execution; not enabled in this run. |
When to use
- Use when inspecting this configuration, loading location and result contract.
When not to use
- Stop integration and consult specific documentation when the event, version or permission boundary is unclear.
Configure URL, event and headers
An HTTP hook sends event JSON as the POST body with Content-Type: application/json. Configure type=http and url, then add headers. Header values support $VAR_NAME or ${VAR_NAME}, but only names in allowedEnvVars are expanded; unlisted references become empty strings. Keep actual tokens in the execution environment.
Separate continuation from explicit blocking
onFailure defaults to continue. The block value can block the action on request failure or a non-2xx status and requires Claude Code v2.1.295 or later. A normal 2xx response carrying valid decision JSON uses the event decision fields. Establish event support and the receiver response contract first; HTTP status codes are not command-hook exit codes.
Inspect the variable allowlist locally
The synthetic configuration contains only the name DEMO_TOKEN and no token value. A local check confirms that the variable referenced by Authorization appears in allowedEnvVars; removing it breaks the intended authentication contract. This checks configuration intent only, with no HTTP hook request. Stop integration when the destination is uncontrolled, the variable is missing or the version is insufficient.
Sources
All links are official pages; verification dates are listed per source, and links point to the version checked.