POST /v1/messages
Web search is a tool entry in the tools array. allowed_domains and blocked_domains live at the top level of the tool definition (not nested under filters).
Request
With allow and block lists (Anthropic native shape)
Fields
All optional fields on the tool entry:| Field | Type | Purpose |
|---|---|---|
max_uses | integer | Cap on how many searches the model may run per request |
allowed_domains | string[] | Only include results from these domains |
blocked_domains | string[] | Never include results from these domains |
user_location | object | Localize search results. Fields: type (always "approximate"), city, region, country, timezone |
Response shape
The model’s reply containsserver_tool_use and web_search_tool_result blocks alongside the usual text blocks — search-result URLs are returned structurally:
Project-level enforcement
Project-level allow/block lists configured via Policy Gateway cap the request:- Allow: request
allowed_domains⊆ projectallowed_domains. A request asking for a domain outside the project list returns400. - Block: project
blocked_domains∪ requestblocked_domains(union — both apply).
Multi-turn caveat
Replaying assistant messages that containserver_tool_use or web_search_tool_result blocks back into a new request can return 422. Strip those blocks before replaying.