AI DLP Guard Policy
General Information
Policy Type
ai-dlp-guard
Endpoints
List Policies
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Add Policy
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Update Policy
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Delete Policy
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Guard Definitions
policyAiDlpGuardDefList carries the embedded secret/credential-detection rules.
Fields
| Field | Type | Required | Description |
|---|---|---|---|
| id | integer | No | Set by the platform once the rule is saved; ignored on write. |
| presetId | string | No | Back-reference to the catalog rule this definition was copied from. A provenance marker only, not an APIops name-based reference — import clears it and the copy stays fully functional, just localized. |
| name | string | Yes | Rule name. Used as the anonymous label reported in logs and traffic data instead of the raw regex. |
| ruleValue | string | Yes | Regex pattern matched against the resolved scan text. |
| action | string | No | BLOCK (default), FLAG or MASK. MASK redacts the matched region in place and lets the (redacted) traffic through. |
| category | string | No | Category label (e.g. aws, openai, github, pem, jwt, generic). |
| enabled | boolean | No | Whether this definition is active. Default true. |
| description | string | No | Free-text description for UI display. |
| literalAnchors | array of strings | No | Literal substrings that must appear verbatim in every possible match of ruleValue. Used as a fast pre-filter before the regex runs. An anchor that isn't a true substring of every match is rejected at save time (400) — a loose anchor would silently defeat the gate and let a real match through unscanned. Leave empty/null if you're not sure; the rule is simply always regex-scanned, just without the pre-filter speedup. |
File Signature Detection
fileSignatureDetectionEnabled adds a second, independent check: a magic-byte scan for binary document/archive/executable content smuggled into a prompt or echoed back in a response — something a text regex cannot catch reliably.
| Field | Type | Required | Description |
|---|---|---|---|
| fileSignatureDetectionEnabled | boolean | No | Turns the magic-byte scan on. Default false. |
| fileSignatureAction | string | No | BLOCK (default) or FLAG only. MASK is rejected at save time (400) — a magic-byte match has no well-defined redaction span. |
| fileSignatureTypes | array of strings | No | Allow-list narrowing which signatures count as a match: PDF, ZIP_OOXML, PNG, JPEG, GIF, GZIP, RAR, SEVEN_ZIP, ELF, PE_EXE, OLE2, RTF, JAVA_CLASS. Null/empty means all of them. |
External Guardrail
engine decides which decision sources feed the policy's verdict.
| Value | Behaviour |
|---|---|
BUILTIN (default) | Only policyAiDlpGuardDefList (and, if enabled, the file-signature scan) is evaluated. |
BUILTIN_PLUS_EXTERNAL | The regex/file-signature checks and the external adapter both run. Either one can trigger a block. |
EXTERNAL_ONLY | policyAiDlpGuardDefList is ignored entirely — no BLOCK/MASK/FLAG rule runs. Only the external adapter's verdict applies. The file-signature scan is unaffected by engine — it runs whenever fileSignatureDetectionEnabled is true, regardless of engine. |
failMode governs what happens when the external adapter call itself errors or times out. It also governs the case where the external adapter or its provider cannot be resolved (for example, the adapter is missing or the connection was deleted). In that case, FAIL_OPEN continues with the BUILTIN evaluation only:
| Value | Behaviour |
|---|---|
FAIL_CLOSED (default) | The request is blocked. |
FAIL_OPEN | The request continues; a FAIL_OPEN signal is recorded so the bypass is visible. |
externalGuardrail Fields
Either llm-judge or http-dlp is accepted on this policy.
| Field | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | llm-judge or http-dlp. |
| llmProviderName | string | Conditional | Required when type is llm-judge. Name of the LLM provider connection config. Apinizer looks for the name in the project of the API proxy first, then in the admin project (shared providers). A provider in the own project wins when both have the same name. |
| webhookConnectionName | string | Conditional | Required when type is http-dlp. Name of the webhook connection config the adapter calls. |
| modelId | string | No | Judge model identifier. llm-judge only. |
| promptTemplate | string | No | Judge prompt template. llm-judge only. |
| jsonMode | boolean | No | Whether the judge is asked to respond in JSON mode. llm-judge only. |
| maxOutputTokens | integer | No | Judge max output tokens. llm-judge only. |
| timeoutMs | integer | No | HTTP call timeout in milliseconds. Must be positive if set. Shared by both adapter types. |
| maxInputChars | integer | No | Max input characters sent to the adapter. Must be positive if set. Shared by both adapter types. |
| decisionMode | string | No | STANDARD or REASONING. Unset is STANDARD. llm-judge only, chat judge. STANDARD: temperature 0, small output limit, default timeoutMs 2000, default maxOutputTokens 64. REASONING: for thinking models; no temperature is sent, maxOutputTokens is the budget for thinking and verdict together, default timeoutMs 15000 (up to 60000), default maxOutputTokens 1024. A value that you set always wins over the default |
| decisionThreshold | number | No | Verdict threshold for TypeSafe Jev and TEI judges. Range 0.05 to 0.99. Default 0.5. A value outside the range is set to the nearest limit. Jev: unsafe when the probability is at or above the value. TEI: unsafe when a selected label scores at or above the value |
| unsafeLabels | array[string] | Conditional | TEI judge only. Labels that mean unsafe, for example INJECTION and JAILBREAK. Matching is not case-sensitive. At least one label is required for a TEI judge. |
| decisionQuestion | string | Conditional | TypeSafe Jev judge only. The yes/no question that Jev answers about the text. yes means unsafe. Required for a TypeSafe Jev judge (400 decisionquestionrequired when blank). The Manager UI pre-fills: Does this text contain confidential data that must not leave the organisation, such as passwords, API keys, private keys, internal documents or customer records? |
Judge providers. For llm-judge, llmProviderName can name an OpenAI-compatible chat provider, an Anthropic provider, a TypeSafe Jev provider (decision model), or a TEI provider (guard classifier). AWS Bedrock, Google Vertex AI, Cohere, the native Gemini wire format, embedding-only providers, and custom providers without an adapter family cannot judge. The provider must use credentials held by the AI gateway (Provided by AI gateway). TypeSafe Jev and TEI make decisions only: they do not use promptTemplate, jsonMode, or maxOutputTokens, and they cannot be a routing target, a pool member, a failover target, or an embedding provider.
If the judge provider refuses to answer for safety reasons, the verdict is UNSAFE with the category provider-refusal. FAIL_OPEN does not let this request through. maxWaitMs still limits the whole check, so a slow reasoning judge is cut off by it and failMode decides.
Other Fields
| Field | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | No | Whether the guard runs at all. Default true. |
| carryBufferSize | integer | No | Streaming carry buffer size in characters, for a chunk-boundary MASK. |
| decodeEncodedContent | boolean | No | Decodes base64/hex/URL/unicode segments before scanning. Default false. |
List Policies
Endpoint
GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"resultList": [
{
"apiProxy": {
"name": "MyAiProxy",
"requestPolicyList": [
{
"type": "ai-dlp-guard",
"name": "secret-leak-guard",
"description": "Blocks AWS keys and PEM private keys",
"active": true,
"enabled": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws",
"literalAnchors": ["AKIA"],
"enabled": true
}
],
"fileSignatureDetectionEnabled": true,
"fileSignatureAction": "BLOCK",
"fileSignatureTypes": ["PDF", "ZIP_OOXML"],
"engine": "BUILTIN",
"failMode": "FAIL_CLOSED"
}
],
"responsePolicyList": [],
"errorPolicyList": []
}
}
],
"resultCount": 1
}
cURL Example
curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAiProxy/policies/" \
-H "Authorization: Bearer YOUR_TOKEN"
Add Policy
Endpoint
POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Request Body
Full JSON Body Example — Regex Rules Plus File-Signature Scan
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "ai-dlp-guard",
"description": "Blocks AWS keys and PEM private keys, redacts generic tokens",
"active": true,
"enabled": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws",
"literalAnchors": ["AKIA"]
},
{
"name": "pem-private-key",
"ruleValue": "-----BEGIN [A-Z ]*PRIVATE KEY-----",
"action": "BLOCK",
"category": "pem",
"literalAnchors": ["PRIVATE KEY-----"]
},
{
"name": "generic-bearer-token",
"ruleValue": "(?i)bearer [a-z0-9._-]{20,}",
"action": "MASK",
"category": "generic"
}
],
"carryBufferSize": 64,
"decodeEncodedContent": true,
"fileSignatureDetectionEnabled": true,
"fileSignatureAction": "BLOCK",
"fileSignatureTypes": ["PDF", "ZIP_OOXML", "PE_EXE"]
}
}
Full JSON Body Example — With an External LLM-Judge
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 2
},
"policy": {
"type": "ai-dlp-guard",
"description": "Regex rules plus a judge model as a second opinion",
"active": true,
"enabled": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws"
}
],
"engine": "BUILTIN_PLUS_EXTERNAL",
"failMode": "FAIL_CLOSED",
"externalGuardrail": {
"type": "llm-judge",
"llmProviderName": "internal-guard-model",
"timeoutMs": 2000
}
}
}
Example — TypeSafe Jev Judge
"externalGuardrail": {
"type": "llm-judge",
"llmProviderName": "typesafe-jev",
"modelId": "jev-latest",
"decisionQuestion": "Does this text contain confidential data that must not leave the organisation, such as passwords, API keys, private keys, internal documents or customer records?",
"decisionThreshold": 0.5
}
Request Body Fields
See Guard Definitions, File Signature Detection, External Guardrail and Other Fields above. type (ai-dlp-guard), description and active follow the common policy contract; name comes from the path parameter.
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
Error Responses
| Code | Reason |
|---|---|
| 400 | Blank name; fileSignatureAction is MASK; a literalAnchors entry that isn't a verbatim substring of every match of its rule's ruleValue; engine is not BUILTIN but externalGuardrail is missing; externalGuardrail.type blank or unsupported; llmProviderName blank for llm-judge; webhookConnectionName blank for http-dlp; timeoutMs/maxInputChars not positive; proxy not found; a TypeSafe Jev judge without decisionQuestion (decisionquestionrequired) or a TEI judge without unsafeLabels (unsafelabelsrequired). |
| 401 | Missing or invalid token. |
| 403 | The token's account lacks permission on the project. |
cURL Example
curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAiProxy/policies/secret-leak-guard/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "ai-dlp-guard",
"description": "Blocks AWS keys",
"active": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws"
}
]
}
}'
Update Policy
Endpoint
PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
The body is the same shape as Add Policy. The update replaces the policy, so send the fields you want to keep — including every rule in policyAiDlpGuardDefList.
Full JSON Body Example — Turning On File-Signature Detection
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "ai-dlp-guard",
"description": "Blocks AWS keys, now also blocks smuggled PDFs and archives",
"active": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws"
}
],
"fileSignatureDetectionEnabled": true,
"fileSignatureAction": "BLOCK",
"fileSignatureTypes": ["PDF", "ZIP_OOXML"]
}
}
Response
Success Response (200 OK)
{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}
cURL Example
curl -X PUT \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAiProxy/policies/secret-leak-guard/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"]
},
"policy": {
"type": "ai-dlp-guard",
"active": true,
"policyAiDlpGuardDefList": [
{
"name": "aws-access-key",
"ruleValue": "AKIA[0-9A-Z]{16}",
"action": "BLOCK",
"category": "aws"
}
],
"fileSignatureDetectionEnabled": true
}
}'
Delete Policy
Endpoint
DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Response
Success Response (200 OK)
{
"status": "SUCCESS"
}
cURL Example
curl -X DELETE \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAiProxy/policies/secret-leak-guard/" \
-H "Authorization: Bearer YOUR_TOKEN"
Notes and Warnings
EXTERNAL_ONLYturns off every embedded rule, but not file-signature detection.fileSignatureDetectionEnabledruns independently ofengine— set it explicitly if you want the magic-byte scan underEXTERNAL_ONLY.fileSignatureActionnever acceptsMASK. A magic-byte match has no well-defined redaction span, so onlyBLOCK/FLAGare valid; sendingMASKis rejected at save time.- A
literalAnchorsentry must be a true substring of every possible match, not just a likely one. A loose anchor would silently defeat the pre-filter and let a real match through unscanned — the platform rejects the save rather than accept a rule that looks safe but isn't. MASKon a guard def redacts and lets the (redacted) traffic through — unlikeBLOCK, the request or response is not rejected, only the matched span is replaced.decodeEncodedContentwidens what is scanned, it never narrows it — when nothing decodes, or the flag is off, the guard sees the byte-identical original text.