Plugins
The router can run a request through extra plugins. You turn a plugin on for a single request with the plugins field in the body. One plugin is available today: DLP (data loss prevention).
DLP looks for sensitive data in a request (secrets and PII) and reacts according to the mode you choose. It checks user messages, tool results (tool), tool call arguments, and readable reasoning sent back in the history. Ordinary model answers in the history are checked too: in mask and block modes a finding there is masked, and the request goes through. The new answer the model writes is not checked. The system prompt is checked only when the key has a policy.
{ "model": "anthropic/claude-sonnet-4.6", "plugins": { "dlp": { "mode": "mask" } }}The plugins field is optional, but leaving it out does not turn the check off: an API key can have its own DLP policy set by the group administrator. See API key policy.
Every plugins.dlp field (stop words, custom patterns, exceptions, report_scope) and its format is described in the API Reference.
On /v1/chat/completions, DLP does not work with n greater than one: such a request is rejected with 400 and the code dlp_multi_choice_unsupported.
Without mode, alert applies.
mode | Behavior |
|---|---|
alert | Findings come back in the response (plugins.dlp). Nothing is masked, withheld, or refused for the person |
mask | Matches are replaced with masks before the request reaches the model and restored in response text and tool call arguments. Reasoning keeps masks |
block | A blocking finding can reject the request with 403 and the code dlp_violation; extra.dlp lists the findings. Model history, reasoning sent back, and keep_masks have the exceptions described here |
Reasoning sent back
Section titled “Reasoning sent back”DLP scans readable text in reasoning, reasoning_details, thinking blocks on /v1/messages, and reasoning items on /v1/responses, regardless of role. In mask mode, response reasoning keeps masks as the provider sent them, including during streaming. Send retained signed blocks back unchanged to preserve their signatures.
- Unsigned reasoning text with a
maskfinding is masked again. Ablockfinding replaces the whole text field with a withholding note. - A signed block with a direct
maskorblockfinding is removed whole after its tool loop has closed. This includes Responses reasoning items carryingencrypted_content. If tool results follow the block with no later user message, a direct finding instead rejects the request before the model call with403dlp_violation. On/v1/messages, text beside atool_resultdoes not close this tool loop. - When a finding in a signed block comes only from a value found elsewhere in the request, an open tool loop continued with the same provider keeps that block and the previously seen prefix byte for byte unchanged. Newly added tool results are protected. After the loop closes, the block is removed; switching providers also removes foreign signed blocks.
When a Responses reasoning item is removed, subsequent model items are adjusted too; see Responses API.
Data types (entity_types)
Section titled “Data types (entity_types)”Secrets and credentials: ACCESS_TOKEN, API_KEY, BEARER_TOKEN, CERTIFICATE, JWT, PASSWORD, PRIVATE_KEY, PUBLIC_KEY, UNKNOWN_SECRET.
PII and identifiers: BANK_ACCOUNT, CREDIT_CARD, DOB, EMAIL, ID_NUMBER, IP_ADDRESS, MAC_ADDRESS, MEDICAL_ID, PHONE_NUMBER, POSTAL_CODE, SSN, SWIFT_BIC, TAX_ID, VEHICLE_VIN, and the Russian KPP, OGRN, OGRNIP, and OMS. The detectors work on English and Russian text.
The field is optional. Without it, every type is checked except UNKNOWN_SECRET. That one is found by entropy analysis rather than a pattern, so it gives false positives on long random strings and is checked only when you list it.
In mask mode the model sees a mask instead of the value. Here is one email address on its way through a conversation:
- You send
my email is [email protected]with"mode": "mask". The model receivesmy email is <EMAIL:k1:30r4oiSXFHYQ8rlW6cl62yMraAAOD-i01pw7VR7c-ck>. - The model repeats the mask in its answer. You get
[email protected]back. - You ask the model to summarize the conversation and send
"keep_masks": true. The summary you get keeps the mask instead of the address. - Later you send that summary and ask “what is my email?” with DLP on. The original message is no longer in the request, but the model repeats the mask from the summary, and you get the address back.
A mask has the form <TYPE:KEY_ID:VALUE>: the data type, the id of the encryption key, and the encrypted value in base64url. The same value sent with the same API key always gives the same mask, so the provider’s prompt cache keeps working. An email address is encrypted in lower case.
A mask belongs to the API key that produced it. The router turns it back into the value only in a request made with the same key and with DLP on: plugins.dlp in the request or a policy on the key. This also works for a mask from an earlier request. Another API key, including one of the same group, gets the mask as plain text. So does the same key after it is reissued.
When the answer revealed at least one mask, the response carries plugins.dlp_masked: true: beside the findings in a regular response, on the last event of a stream. A client can use it to mark an answer that shows a protected value.
A value found directly under mask or block is protected when it appears elsewhere in the same request, including in model replies, tool results, system text, tool descriptions, and router web search traces sent back on the next turn. Repeated values add no findings to the report. A value found only by an alert rule does not protect its repetitions; the request stays unchanged.
In mask and block, a repeated value in an image or an old tool call can hide that containing part. If there is no containing part to hide, the router returns 403 dlp_violation naming the place without the value. This covers free request parameters (stop, metadata, tool_choice, user, safety_identifier, prompt_cache_key, web_search_options), a declared tool name, and a key or number in SystemOne questions.
Keeping masks: keep_masks
Section titled “Keeping masks: keep_masks”plugins.dlp.keep_masks (default false): with true, the response keeps masks in text, reasoning, and tool call arguments, the same in a stream and without one. Send it when you store the answer and send it back later, as with a summary in step 3: the stored text then holds masks, not values.
This includes a numeric tool parameter: it reaches you as the mask string, not the original number.
With keep_masks: true under block, a finding in message text is masked instead of rejecting the request. A finding in a place that cannot be replaced, such as an image URL, still rejects it.
"dlp": {"keep_masks": true} on its own does not turn DLP on. If the key has no policy, nothing is checked and nothing is revealed.
When a mask is not revealed
Section titled “When a mask is not revealed”The response then carries the mask as plain text, with no error. This happens when:
- the request had no DLP: no
plugins.dlpand no policy on the key; keep_masksistrue;- the mask was made by another API key, or by this key before it was reissued;
- the mask was changed, or its key id is unknown;
- in a stream, a mask from an earlier request longer than 4096 characters arrived split between chunks. The same mask in a response without streaming is revealed.
Show such a mask to the person as a value hidden by DLP rules, and do not pass it to a tool or write it to a file.
This also applies to a damaged or cut fragment starting with <TYPE:KEYID: (TYPE matches [A-Z][A-Z_]{0,63}, KEYID matches [A-Za-z0-9_-]{1,64}). At the end of text, <TYPE: or <TYPE:KEYID counts too. Code such as fn first<T:Clone> does not count as a mask.
Long history
Section titled “Long history”If the conversation history exceeds a DLP resource limit, the router replaces its oldest parts with findings until the rest fits. System and developer text stays in the request. The response carries plugins.dlp_withheld with the number of replaced parts (leaves) and their message indexes (message_indexes). If nothing can be removed, the whole request goes through. Only new content over the value or byte limit gets 413 scan_limit_exceeded before the model call. In alert, the request stays unchanged and only an alert is recorded.
Files in DLP requests
Section titled “Files in DLP requests”The router does not decode inline text files. A text file in a data: URL or base64 source, or a file with no type, gets 400 feature_not_supported. An untyped file passes as binary when its first bytes match %PDF, PNG (\x89PNG), JPEG (\xff\xd8\xff), GIF8, OggS, ID3, fLaC, ZIP (PK\x03\x04), RIFF with WEBP or WAVE, or ftyp at bytes 5-8. A file with a declared binary type also passes without its bytes being scanned. Send text files as text when DLP applies.
API key policy
Section titled “API key policy”An API key can have a DLP policy set by the group administrator. It acts as a floor on strictness: whether or not you send plugins.dlp, the request is checked at least against the policy. Clients written to the OpenAI and Anthropic standards have no field for a DLP config at all, and the policy applies to them too.
Your config still applies, but it can only make the check stricter:
| Field | How the merge treats it |
|---|---|
mode | Applies to the rules you declared. If the policy has the same rule, the stricter mode wins: alert is weaker than mask, and mask is weaker than block |
entity_types | The categories are combined. If you do not send the field, the policy’s categories apply |
stop_words | The lists of forbidden literals are combined |
regexes | The lists of custom patterns are combined |
allowlist | Applies only to findings from your rules. An exception does not cancel a finding from a policy rule. A value you declare both as a stop word and as an exception stays forbidden |
report_scope | Stays yours: it chooses only which findings come back, not whether the request is blocked |
Under a policy, two more fields are reset: injected_context_names and acknowledged. The first takes a marked message out of the check, which under a policy would be a way around it; the second has no effect even without a policy.
The reaction to a finding is set by whoever declared the rule that fired. If you listed entity_types, your mode applies to those categories, your stop words, and your patterns, and the administrator’s mode covers the rest of the policy’s categories. If you did not send entity_types, your mode applies to all of the policy’s categories.
You cannot see the contents of the administrator’s policy, and no separate error tells you that your settings were weakened: the stricter setting applies. A change to the administrator’s settings reaches the check in about a minute.
When the policy is unavailable
Section titled “When the policy is unavailable”If the key’s policy cannot be fetched, the request is rejected with 503 and the code dlp_policy_unavailable, and the Retry-After header gives the interval before a retry. The check does not turn itself off: a request whose policy is unknown does not reach the model.
Block error
Section titled “Block error”{ "error": { "code": "dlp_violation", "message": "Request blocked: sensitive data detected", "extra": { "dlp": [ { "category": "pii", "entity_type": "EMAIL", "message_index": 0, "location": "messages[0].content", "start": 12, "end": 28, "confidence": 0.99 } ], "findings_count": 1, "block_scope": "in_report_scope" } }}On /v1/messages, the body is in Anthropic format: the error type is permission_error, the machine-readable code sits next to it in the code field, and the findings are in details.
{ "type": "error", "error": { "type": "permission_error", "code": "dlp_violation", "message": "Request blocked: sensitive data detected", "details": { "dlp": [ { "category": "pii", "entity_type": "EMAIL", "message_index": 0, "location": "messages[0].content", "start": 12, "end": 28, "confidence": 0.99 } ], "findings_count": 1, "block_scope": "in_report_scope" } }}A finding describes where the match is and what kind it is: the category (secret, pii, custom), the entity type, and the position in the text. It does not contain the values themselves, and they cannot be recovered from the response. A stop word finding has the entity type STOP_WORD, and a finding from your pattern has CUSTOM_REGEX; both have the category custom.
The block_scope field tells you where the reason for the block is: in_report_scope if it is among the listed findings, and outside_report_scope if it is in a part of the request we do not return.
A block always comes as a regular HTTP response, including with stream: true. The decision is made before the stream opens, so a block never arrives as an event inside the stream.
Embeddings and decisions
Section titled “Embeddings and decisions”/v1/embeddings and /v1/systemone use the same modes, data types, and key policy. They have no messages: each element of input and each string in state, instructions, and criteria is checked the same way as a user message. On /v1/systemone, keys are checked too: the question keys and any object key inside state, instructions, and criteria. Numbers are checked; booleans are not; see Decisions.
- A finding’s
locationis the path to the element (input[1],state.customer.email), andmessage_indexis-1. report_scopenarrows nothing, andblockrejects the whole request.- On
/v1/systemone, a directmaskorblockfinding in a key or number rejects the request. A repeated protected value in astatekey or number hides its containing object; in aquestionskey or number it returns403 dlp_violationbecause there is no containing part to hide. - Findings in
maskandalertmodes come back in the response’splugins.dlp.
For details, see Embeddings and Decisions.