Develop an Inference hooks integration
Build the AI security server that receives signed Inference hooks requests, verifies them, and returns allow or deny verdicts.
An Inference hooks integration is an AI security server: an HTTPS service that Anthropic calls. For each governed request, your server receives a signed POST carrying the conversation transcript and responds with an allow or deny verdict. With file checks on, it receives a file frame in the same way. This page documents the protocol for building that server: the request and verdict schemas, signature verification, and the operational contract.
To turn Inference hooks on and point them at your endpoint, see Configure Inference hooks. To learn what Inference hooks are and when to use them, see the Inference hooks overview.
Get a first verdict round trip
The smallest working integration is a server that reads each request and allows it. Run one of the following servers and expose it at a public https:// URL. For example, put it behind a TLS-terminating reverse proxy on a host you control, not a reverse-tunnel service (see Receive a request). Then have your administrator set it as the endpoint and test the connection. The Test connection result reports the allow verdict your server returned.
# Run with: python server.py
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
class VerdictHandler(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1" # keep the connection open between verdicts
def do_POST(self):
# Drain the body; transcripts can be megabytes.
self.rfile.read(int(self.headers.get("Content-Length", 0)))
verdict = b'{"action": "allow"}'
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(verdict)))
self.end_headers()
self.wfile.write(verdict)
ThreadingHTTPServer(("", 8000), VerdictHandler).serve_forever()Receive a request
Anthropic sends an HTTPS POST to the URL your administrator configures. The whole configured URL is the endpoint: there is no fixed path suffix, so choose any path that suits your server.
Host your AI security server where Anthropic can reach it: an https:// URL on port 443, on a publicly routable host. Private, loopback, and carrier-grade NAT ranges are refused at connect time. The server must have a certificate that validates against the public CA trust store, and it must respond without redirects. The host must have an IPv4 address, which Anthropic uses even when the host also has IPv6 addresses; a URL whose host is localhost or an IPv6 address is refused. The configured URL must be the final destination. Reverse-tunnel hosts (ngrok and similar tunnel services) are not supported: Anthropic’s network policy blocks them. Host your server on a domain you control. Configure Inference hooks covers how your administrator sets and tests the URL.
Every request carries these fixed headers, along with any custom request headers your administrator configured and, once your organization has a signing secret, the webhook-* signature headers described in Verify the signature:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | anthropic-dlp/1 |
Accept-Encoding | identity |
There are three hook events, told apart by the top-level type field. The prompt frame is sent once for each governed inference request, before inference starts. The tool call frame is sent when a model response contains tool calls, before any of them runs, in organizations that have Validate tool calls on. The file frame is sent for a file that a file check covers, before the file is stored, in organizations that have Check files on. In each case, Anthropic waits until your AI security server responds or the verdict timeout elapses. An organization can receive some frames and not others, so don’t assume that you get every kind.
The prompt frame
The request body is a JSON object with these fields:
| Field | Type | Description |
|---|---|---|
type | string | The hook event: "prompt", "tool_call" (see The tool call frame), or "file" (see The file frame). Handle an unrecognized value gracefully (see Forward compatibility). |
request_id | string | Opaque per-frame identifier for correlation. Equals the webhook-id header. |
tenant_id | string or null | Opaque identifier for the organization the request belongs to. |
actor | object | The principal the request is attributed to, discriminated on type ("user" is the only value sent today): id (a tagged identifier, stable across requests for the same account) and email_address (when available). Both id and email_address can be null. |
source | object | The originating application: application (see Source values). |
messages | array | The conversation transcript up to the point of inference. See Content blocks. |
session_id | string or null | Opaque conversation identifier, when one exists. Don’t parse it. For Claude Code it is a best-effort, client-asserted session identifier. |
model | string or null | Public model identifier for this request, when available. |
metadata | object | Reserved extension map of string keys to string values, sent empty today. Require nothing from it, and tolerate its absence, its presence, and any keys that appear. |
An example request body:
{
"type": "prompt",
"request_id": "req_abc123",
"tenant_id": "11111111-1111-1111-1111-111111111111",
"actor": {
"type": "user",
"id": "user_01AbCdEfGhIjKlMnOpQrStUv",
"email_address": "alice@example.com"
},
"source": {
"application": "claude-ai"
},
"session_id": "22222222-2222-2222-2222-222222222222",
"model": "claude-sonnet-4-5",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the attached report."
},
{
"type": "attachment",
"file_name": "q2-report.pdf",
"media_type": "application/pdf",
"size_bytes": 48213,
"text": "Q2 revenue grew 14% quarter over quarter..."
}
]
}
],
"metadata": {}
}Content blocks
Each entry in messages has a role of user or assistant (tool results appear under the user role, matching the public Messages API content model) and a content array of blocks discriminated by type:
Block type | Fields |
|---|---|
text | text: the text content. |
tool_use | id: the identifier the matching tool result references. tool_name: the tool’s name. input: the arguments the model passed to the tool. tool_info: on a tool call frame only (left out elsewhere, never null), an object that says who runs or provides the tool; see The tool call frame. |
tool_result | content: the tool’s output as text, with parts joined by newlines; binary parts such as images are replaced by placeholder markers, and raw bytes are never sent. is_error: whether the tool call failed. tool_name: the tool’s name, so a policy can condition on tool identity without cross-referencing an earlier block. tool_use_id: the id of the matching tool_use block. |
attachment | file_name: the original file name or path. media_type: the attachment’s media type. size_bytes: the size of the original file. text: the text content of the attachment when available, such as extracted document text, an audio transcript, or link metadata. A prompt frame never holds raw attachment bytes. |
Apart from type, a text block’s text, and a tool_result block’s content and is_error, any of these fields can be null when the value isn’t known; for example, an image arrives as an attachment block with file_name and text set to null.
A block whose type you don’t recognize is a forward-compatible addition. The only field it guarantees is type; your policy may inspect whatever other fields are present, but must not reject the request because of an unrecognized type.
What the transcript contains
The transcript is the conversation as the end user sees it, up to the point of inference: transcript text, tool calls and their results, extracted attachment text, and prior turns. It never includes system prompts, tool definitions, Anthropic-internal context, Claude’s hidden reasoning, or raw file bytes. Only a file frame can hold a file’s bytes. If Claude gets only an attachment’s file path, the transcript holds only the text that tools return from the file.
A turn whose every block is excluded is omitted entirely, so don’t assume strict user and assistant alternation.
Transcripts are sent untruncated, so a long conversation with large attachments produces a large request body. In practice the model’s context window keeps bodies under about 10 MB, but the protocol allows up to 64 MiB. Several common defaults are much smaller, including nginx client_max_body_size at 1 MB and Express express.json() at 100 kB, and a rejected body counts as a webhook failure, so under Allow the request failure handling an oversized prompt would reach the model uninspected.
Source values
source.application is an open string, not a closed enum. Common values are claude-ai, claude-code, and cowork; connection tests and automatic circuit-breaker recovery checks use config-test. New values may appear, and your server must not reject a request because of one it doesn’t recognize.
Treat source.application as advisory routing metadata, not a trust boundary: don’t rest a security-critical policy decision on it alone.
The tool call frame
When Claude produces tool calls, Anthropic sends one tool call frame that lists them. One verdict covers the whole frame: you can’t allow some tool calls and deny others. The frame goes to the same endpoint as the prompt frame, with the same headers, signature, and top-level fields. Code that Claude runs in the code execution tool can make tool calls too. Anthropic sends those in separate tool call frames before they run.
Some tool calls might be left out, and a response with only such calls produces no tool call frame. See Availability in the Inference hooks overview.
The frame differs from the prompt frame in three ways:
typeis"tool_call".messagesholds only the latest message, theassistantmessage Claude just produced: anytextblocks and onetool_useblock for each tool call the frame lists, in the order the model produced them. Earlier conversation is left out, because the prompt frame sent before that model call carried it. Read the last entry ofmessages, because the protocol may later add earlier messages before it.- Each
tool_useblock carries atool_infoobject that says who runs or provides the tool.
Where session_id is set, it is the same on both frames. The tool call frame has its own request_id, which is opaque like the prompt frame’s.
The frame holds each call’s arguments, not its result. A result reaches your server only when it is sent back to Claude in a later prompt frame, normally in a tool_result block. In Claude Code and Cowork, a result that arrives while Claude works on something else can come in a text block of a user message instead. Some results are replaced by a placeholder or left out.
What tool_info tells you
tool_info says who runs or provides the tool, not what the tool can reach. Only type is on every tool. A field that doesn’t apply or isn’t known is left out, never null, so a tool_info can be just {"type": "client"}.
| Field | Present on | Description |
|---|---|---|
type | Every tool | One of the values in the next table. New values might appear. Return a verdict, not an error, for one you don’t recognize. Don’t expect any other field with it. |
tool_type | Every platform tool and some client tools | The versioned type of a tool that Anthropic defines, such as web_search_20250305. Match it exactly; don’t parse a name or a date out of it. |
toolset_name | Some tools | A name for the server or group of tools that the tool belongs to. It isn’t a stable identifier. |
origin | Some third-party tools | The scheme, host, and non-default port of the server’s URL. It can be a private or local address, localhost included. An absent origin means unknown, not safe. |
verified_origin | Every tool that has origin | true only when Anthropic connects to the server itself. false means only that Anthropic hasn’t confirmed the origin. |
type has one of these values:
| Value | Meaning |
|---|---|
"platform" | The Claude API runs the tool while it serves the request. |
"application" | Anthropic runs the tool as part of the application that made the request. |
"third_party" | The tool is on a server that Anthropic knows of, such as a connector or an MCP server. This doesn’t mean Anthropic has vetted the server. |
"client" | Any other tool, usually one that the application calling Claude runs. |
An example tool_use block for a tool on an MCP server:
{
"type": "tool_use",
"id": "toolu_01GhIjKlMnOpQrStUvWxYzAb",
"tool_name": "crm_search",
"input": {
"query": "accounts renewing in Q4"
},
"tool_info": {
"type": "third_party",
"toolset_name": "crm",
"origin": "https://mcp.crm.example.com",
"verified_origin": true
}
}Write rules that keep working
The protocol defines the fields on this page. It doesn’t define which values a given tool arrives with. A tool’s tool_name, input fields, and tool_info values can differ between Claude products and between conversations, and they can change over time. These practices keep your rules working:
- Scan all of
inputfor sensitive content. This works however the tool is labeled. - Deny when any one value matches. A rule that needs several values to match lets the call through when one of them differs or is missing.
- Don’t allow on a name or
tool_info.typealone. Another tool can have the same values. Only anoriginwithverified_originset totrueconfirms the server’s address. - Choose a verdict for calls that match no rule. Expect names you haven’t seen.
- Check your rules against your own traffic. Log the
tool_nameandtool_infovalues you receive and review them regularly.
The file frame
When a member uploads a file that a file check covers, Anthropic sends a file frame before the file is stored or reaches Claude. The frame goes to the same endpoint as the other frames, with the same headers and signature, and one verdict decides that upload. File checks are in beta, and only organizations with Check files on receive file frames. Test connection doesn’t send one.
It differs from the prompt frame in these ways:
typeis"file".- It has a
fileobject, and nomessagesormodel. session_idis the conversation identifier that the app sent ornullwhere there is no session. It isn’t proof that the conversation exists or belongs to that member, so don’t base a rule on it.
The file object has these fields:
| Field | Type | Description |
|---|---|---|
file_name | string | The name that the caller gave, or one that the upload route set in its place. A long name can be cut, usually keeping the extension, so don’t rely on the last characters before the extension. |
media_type | string | Best effort: read from the file’s bytes where possible, otherwise the type that the caller claimed. application/octet-stream when neither gives a type. |
size_bytes | integer or null | The file’s size. It can be a value that the caller reported, and it’s null when Anthropic doesn’t know the size as it sends the frame. |
sensitivity_labels | object | What Anthropic found when it looked for labels. Always present. See Sensitivity labels. |
content | object | The file itself, or why it isn’t sent. Always present. See File content. |
An example request body, with Send file content off:
{
"type": "file",
"request_id": "req_def456",
"tenant_id": "11111111-1111-1111-1111-111111111111",
"session_id": "22222222-2222-2222-2222-222222222222",
"actor": {
"type": "user",
"id": "user_01AbCdEfGhIjKlMnOpQrStUv",
"email_address": "alice@example.com"
},
"source": {
"application": "claude-ai"
},
"metadata": {},
"file": {
"file_name": "q2-report.docx",
"media_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"size_bytes": 48213,
"sensitivity_labels": {
"type": "found",
"labels": [
{
"type": "mip",
"label_id": "33333333-3333-3333-3333-333333333333",
"entra_tenant_id": "44444444-4444-4444-4444-444444444444"
}
]
},
"content": {
"type": "not_sent",
"reason": "not_enabled"
}
}
}Microsoft Purview sensitivity labels (MIP labels)
sensitivity_labels has a type of found, unreadable, not_applicable, or not_checked. found adds labels, a list of 0 to 16 labels. unreadable and not_checked add reason.
type | What it means | reason values |
|---|---|---|
found | labels lists up to 16 labels, in no set order. An empty list means that Anthropic found no label. | No reason field |
unreadable | The file can hold a label, but Anthropic couldn’t read one, for a reason that lies in the file. | encrypted, legacy_binary, damaged, too_large, or null |
not_applicable | Anthropic doesn’t read labels from this kind of file, such as an image or a text file. | No reason field |
not_checked | Anthropic didn’t read the labels, or the read didn’t finish. | time_limit, failed, not_supported, or null |
Each reason means the following:
| Reason | What it means |
|---|---|
encrypted | The file is encrypted or rights-protected. Not every such file gives this reason. |
legacy_binary | The file is in an older binary Office format and no label could be read. An old file with a readable label gives found. |
damaged | The file is damaged. |
too_large | The file’s label data, or the structure that holds it, takes more than the read allows. This has nothing to do with your file size limit. |
time_limit | The read ran out of time. Anthropic waits 1 second for labels. |
failed | The read failed, Anthropic skipped it, or Anthropic couldn’t rely on the answer. |
not_supported | The upload route doesn’t read labels. |
null | No other reason fits. |
Check Microsoft Purview sensitivity labels (MIP labels) without file content says what to consider in a rule.
A label of type mip has these fields:
| Field | Type | Description |
|---|---|---|
type | string | "mip", a Microsoft Purview Information Protection label. |
label_id | string | The label’s GUID, in lowercase, without braces. |
entra_tenant_id | string or null | The GUID of the tenant that the label names, in the same form. null when it doesn’t name exactly one as a GUID. |
File content
content is one of these:
type | Fields |
|---|---|
base64 | data: the whole file as the upload route received it, in base64 (RFC 4648 section 4, padded). |
not_sent | reason: not_supported if the upload route doesn’t send content, not_enabled if your organization hasn’t turned content on, or null if neither fits. |
sensitivity_labels doesn’t depend on whether content holds the file. With not_sent, decide from the rest of the frame, by your own policy. To decide from labels alone, see Check Microsoft Purview sensitivity labels (MIP labels) without file content.
Request size
A frame of any kind never exceeds 64 MiB. Before an Owner turns on Send file content, your server must accept request bodies up to that limit. Otherwise, an Owner must lower Largest file size (MB) so that file frames stay under what your server accepts. A frame with content is about a third larger than the file, so with the default size limit of 30 MiB it can reach about 40 MiB. Lowering the limit doesn’t make prompt frames smaller. Requests aren’t compressed. A file frame without content is small.
Many servers’ default limits are far lower, as What the transcript contains describes. A rejected file frame is a webhook failure, so under Allow the request that file proceeds uninspected, and an HTTP 413 from your server is a failure like any other. Outside shadow mode, these failures count toward the circuit breaker, and a trip stops prompt checks too.
Treat a file frame as untrusted
- The caller can choose
file_nameand can influencemedia_typeandsize_bytes. None of them need match the file. Anthropic can also clean or shortenfile_name. - The file in
datais what the caller sent, unchecked. It can be malformed or built to harm a parser. sensitivity_labelsreports what the file says. A label is only text in the file, so anyone who can edit the file can change or remove one.actor,file_name, andcontentcan hold personal data. Keep them out of general-purpose logs.
Frames and files
Don’t count frames as files. One file can reach your server more than once, in separate frames, each with its own request_id and its own verdict. For example, a document that a member attaches in a chat or a project can produce two frames, and nothing links them. A new upload of the same file is a new frame too. Base each verdict only on what the frame holds, so that the same file gets the same answer.
When an upload replaces a stored file, file_name is the stored file’s name, and the rest of file describes the new file. Nothing in the frame tells a replacement from a new upload.
Not every file reaches your server. Anthropic can refuse a file without sending a frame, for example a file over your size limit, and it can let a file proceed with no frame, for example a file that a file check doesn’t cover. If Anthropic has to send content and can’t read the file, it sends no frame, and your Failure handling setting decides the file.
Return a verdict
Respond with HTTP 200 and a JSON verdict body for both outcomes; the action field discriminates. To allow the request:
{
"action": "allow"
}To deny it:
{
"action": "deny",
"deny_reason": "This prompt appears to contain customer payment card data, which your organization's policy does not allow.",
"reference_id": "scan_01HXPT4R9V"
}| Field | Constraints | Semantics |
|---|---|---|
action | "allow" or "deny"; required | allow lets inference or the file proceed; deny rejects inference or the file. |
deny_reason | string or null; at most 500 characters, longer values truncated | Shown to the end user when action is deny, though on a file frame it might not reach them; ignored on allow. |
reference_id | string or null; at most 50 characters from [A-Za-z0-9._:/-] | Your own identifier for this evaluation. It’s recorded on the denial’s inference_hooks_request_denied compliance activity and never shown to the end user. Keep it opaque: no request content and no personal data. |
A deny is never discarded over a formatting problem: an oversize deny_reason is truncated, a malformed reference_id is silently dropped, and the action is still honored.
The reverse doesn’t hold. Anything other than HTTP 200 with a parseable verdict is a webhook failure, and your organization’s failure handling applies instead of a verdict. In particular:
- Don’t signal a deny with an error status. A non-200 response is a failure, not a deny.
- Any
actionvalue other thanallowordenyis treated as a webhook failure.
Anthropic reads at most 64 KiB of the response body, and the body must be uncompressed. Redirects are not followed, and cookies are ignored. Unknown fields in the verdict body are ignored, so you can return a richer object alongside the fields documented here.
A tool call frame takes the same verdict body, and every rule in this section applies to it unchanged. allow lets the tool calls run and the response continues; deny stops all of them and ends the response with the same error as a denied prompt, including your deny_reason. Text delivered before the first tool call is not taken back.
A file frame takes the same verdict body too. allow lets the file proceed. deny refuses that upload: Anthropic doesn’t store the file or pass that copy to Claude. A deny might not stop text that the app reads itself and sends with the message; see What a file check doesn’t cover. Unlike on other frames, deny_reason might not reach the member; see How a file check works.
Verify the signature
Requests are signed according to the Standard Webhooks specification, using three headers. Anthropic sends the header names in lowercase, and proxies are free to re-case them, so look them up case-insensitively.
| Header | Contents |
|---|---|
webhook-id | Unique identifier for this delivery. Equals the body’s request_id. Use it as an idempotency key and as the first component of the signed payload. |
webhook-timestamp | Unix time in seconds, as a decimal string, when the request was signed. Reject a timestamp more than 5 minutes from your server’s clock, in either direction. |
webhook-signature | One or more space-separated v1,<base64> values, each an HMAC-SHA256 over {webhook-id}.{webhook-timestamp}.{raw body bytes}. Accept the request if any value matches yours, using a constant-time comparison. |
Two details cause most verification bugs:
- Verify raw bytes. Compute the HMAC over the body exactly as received, before any JSON parsing or re-encoding.
- Decode the secret with a standard base64 decoder. The signing secret is the value after the
whsec_prefix, encoded with the standard base64 alphabet (+and/), as is the signature in the header. A URL-safe decoder derives the wrong key bytes whenever the secret contains+or/, which is most of the time.
Once your organization has a signing secret, every request Anthropic sends is signed, including the connection test, because the setup flow generates the secret before the first test. Enabling Inference hooks requires a secret, so reject any request that arrives unsigned. One exception: an organization that enabled Inference hooks before the secret was required keeps sending unsigned requests until its administrator generates one. Accept unsigned requests only until your administrator confirms the secret exists, then reject them.
Rotating the secret is an immediate cutover, but requests signed with the previous secret can still arrive for about a minute afterward, plus anything already in flight. Have your AI security server accept signatures from both secrets during the switchover so those stragglers aren’t rejected.
The following samples are server implementations, so there is no shell tab: an AI security server is a long-running HTTPS service rather than a one-shot request. Each sample uses only the language’s standard library; the Standard Webhooks project also publishes verification libraries for most languages.
import base64
import hashlib
import hmac
import time
TOLERANCE_SECONDS = 300
def verify(secret: str, headers: dict[str, str], body: bytes) -> bool:
"""Return True if the body was signed by Anthropic for this organization.
Anthropic sends header names in lowercase, but proxies are free to
re-case them, so normalize the lookup to lowercase.
"""
lowercased = {name.lower(): value for name, value in headers.items()}
try:
message_id = lowercased["webhook-id"]
timestamp = lowercased["webhook-timestamp"]
signatures = lowercased["webhook-signature"]
except KeyError:
return False # unsigned request: not from Anthropic
try:
signed_at = int(timestamp)
except ValueError:
return False
if abs(time.time() - signed_at) > TOLERANCE_SECONDS:
return False # replayed, or the clocks disagree
try:
key = base64.b64decode(secret.removeprefix("whsec_"), validate=True)
except ValueError:
return False # misconfigured secret: reject rather than crash
payload = f"{message_id}.{timestamp}.".encode() + body
expected = b"v1," + base64.b64encode(
hmac.new(key, payload, hashlib.sha256).digest()
)
# Compare bytes: compare_digest on str raises on non-ASCII input.
return any(
hmac.compare_digest(expected, candidate.encode())
for candidate in signatures.split()
)Operational semantics
Timeout and retry
Your administrator sets a verdict timeout between 1 and 10,000ms (5,000ms by default). The budget covers the entire exchange: connection, TLS handshake, request, and response. The same timeout applies to tool call frames. File frames have a timeout of their own, File verdict timeout (ms): also 1 to 10,000ms, with a default of 10,000ms. It covers sending the frame too, so a large frame on a slow link can time out.
Anthropic retries exactly once, after a 100ms delay, and only when the connection attempt fails. The retry shares the same timeout budget and carries the same webhook-id and the same signature. Once your AI security server has responded, the exchange is never retried.
Webhook failures
Timeouts, non-200 statuses (redirects included), unparseable or oversized response bodies, and unreachable endpoints are all webhook failures. A webhook failure never becomes a deny; instead, your organization’s failure handling setting determines whether the affected request or file is blocked or proceeds without inspection.
Circuit breaker
Sustained webhook failures attributable to your AI security server trip a circuit breaker that stops enforcement: Anthropic stops contacting your server, and failure handling applies to every request.
Starting 3 minutes after the trip, Anthropic checks whether your server has recovered. At most about once per minute, it sends your server the same synthetic test prompt that Test connection sends (source.application is config-test). The prompt is signed like any other request and carries no user content. Respond to it normally. A valid verdict, allow or deny, resets the breaker and enforcement resumes; a webhook failure leaves the breaker tripped, and the checks continue. Answer that prompt even if your server handles only files. An Owner can turn Enforce verdicts back on at any time. Configuration changes by an Owner stop the automatic checks; see Circuit breaker in Configure Inference hooks.
Prompt, tool call, and file frames share one circuit breaker, and failures on any of them count toward it. So, failed file frames can stop all checks, including the checks on prompts and tool calls. The test prompt from Test connection doesn’t count.
Each trip is recorded as an inference_hooks_circuit_breaker_tripped activity in the Activity Feed, one activity for each trip. While the breaker is tripped, no per-request Inference hooks activities are recorded, so the trip activity is the feed’s only record of the tripped window.
Latency
Enforcement adds your AI security server’s round trip to the latency of every governed request in your organization. With Validate tool calls on, a response that produces a tool call frame also waits for its verdict, in shadow mode as well. With file checks on, each checked upload waits for its verdict too, in shadow mode as well. Keep the verdict fast, and load-test your server before rolling it out to a large organization.
Source IP addresses
Requests to your AI security server originate from 160.79.106.0/24, part of Anthropic’s published outbound IP ranges. Allowlist that block, not the inbound ranges on the same page, which don’t cover it. Allowlisting narrows your server’s exposure, but it is not a substitute for signature verification: the block carries Anthropic egress traffic beyond Inference hooks.
Forward compatibility
The protocol grows without breaking correctly written servers. Your server must ignore:
- Unknown fields anywhere in a frame.
- Unknown keys in
metadata. - New
source.applicationvalues. - New
actor.typevalues.actoris a union discriminated ontype, and"user"is the only kind sent today; a future kind guarantees only thattypeis present. - Content blocks with an unrecognized
type. - A
sensitivity_labelsorcontentobject with an unrecognizedtype. Treat the first asnot_checkedand the second asnot_sent. - A label with an unrecognized
type. Onlytypeis sure to be there. - A
reasonvalue that you don’t recognize. Treat it asnull. - Messages with a
roleother thanuserorassistant, which a later revision may add.
Never reject a request because of an unrecognized block type or field; read the fields you know and skip the rest.
A frame of a new event type is an addition your server can’t handle by skipping a field: the request still needs a verdict. When the top-level type is a value you don’t recognize, return an allow verdict rather than an error status; an error response is a webhook failure, and sustained failures trip the circuit breaker.
A server that allows unknown frames allows every file until you add rules for the file frame, so update it before an Owner turns on Check files.
Design your integration
A production AI security server makes a few design choices beyond the wire protocol.
Deduplicate on webhook-id. The webhook-id header is unique for each delivery and equals the body’s request_id, and a connection-failure retry reuses it, so it works as an idempotency key. If you record verdicts, key the records on it.
Record verdicts and join denials. Store each verdict you return along with its reference_id. Every denial is recorded as an inference_hooks_request_denied compliance activity carrying the reference_id your server returned, so you can join denials in the Activity Feed to the matching records in your own system.
Archive with an always-allow server. To capture transcripts in real time without policing them, return {"action": "allow"} unconditionally and persist the frame after responding. This is a push-based alternative to polling the Compliance API, and answering before you persist keeps your round trip out of the user’s critical path.
Write deny_reason for the end user. The text you return is what the user sees when their request is blocked, truncated at 500 characters. Tell them what to change, such as which kind of content to remove, rather than emitting a scanner code that only your team can interpret.
Next steps
Enable Inference hooks, connect and test your endpoint, and control enforcement, failure handling, and rollout.
What Inference hooks are, how the verdict round trip works, and when to use them.
Was this page helpful?