Ana içeriğe geç

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​

FieldTypeRequiredDescription
idintegerNoSet by the platform once the rule is saved; ignored on write.
presetIdstringNoBack-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.
namestringYesRule name. Used as the anonymous label reported in logs and traffic data instead of the raw regex.
ruleValuestringYesRegex pattern matched against the resolved scan text.
actionstringNoBLOCK (default), FLAG or MASK. MASK redacts the matched region in place and lets the (redacted) traffic through.
categorystringNoCategory label (e.g. aws, openai, github, pem, jwt, generic).
enabledbooleanNoWhether this definition is active. Default true.
descriptionstringNoFree-text description for UI display.
literalAnchorsarray of stringsNoLiteral 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.

FieldTypeRequiredDescription
fileSignatureDetectionEnabledbooleanNoTurns the magic-byte scan on. Default false.
fileSignatureActionstringNoBLOCK (default) or FLAG only. MASK is rejected at save time (400) — a magic-byte match has no well-defined redaction span.
fileSignatureTypesarray of stringsNoAllow-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.

ValueBehaviour
BUILTIN (default)Only policyAiDlpGuardDefList (and, if enabled, the file-signature scan) is evaluated.
BUILTIN_PLUS_EXTERNALThe regex/file-signature checks and the external adapter both run. Either one can trigger a block.
EXTERNAL_ONLYpolicyAiDlpGuardDefList 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:

ValueBehaviour
FAIL_CLOSED (default)The request is blocked.
FAIL_OPENThe 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.

FieldTypeRequiredDescription
typestringYesllm-judge or http-dlp.
llmProviderNamestringConditionalRequired 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.
webhookConnectionNamestringConditionalRequired when type is http-dlp. Name of the webhook connection config the adapter calls.
modelIdstringNoJudge model identifier. llm-judge only.
promptTemplatestringNoJudge prompt template. llm-judge only.
jsonModebooleanNoWhether the judge is asked to respond in JSON mode. llm-judge only.
maxOutputTokensintegerNoJudge max output tokens. llm-judge only.
timeoutMsintegerNoHTTP call timeout in milliseconds. Must be positive if set. Shared by both adapter types.
maxInputCharsintegerNoMax input characters sent to the adapter. Must be positive if set. Shared by both adapter types.
decisionModestringNoSTANDARD 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
decisionThresholdnumberNoVerdict 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
unsafeLabelsarray[string]ConditionalTEI 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.
decisionQuestionstringConditionalTypeSafe 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​

FieldTypeRequiredDescription
enabledbooleanNoWhether the guard runs at all. Default true.
carryBufferSizeintegerNoStreaming carry buffer size in characters, for a chunk-boundary MASK.
decodeEncodedContentbooleanNoDecodes base64/hex/URL/unicode segments before scanning. Default false.

List Policies​

Endpoint​

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI 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​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy 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​

CodeReason
400Blank 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).
401Missing or invalid token.
403The 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​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy 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_ONLY turns off every embedded rule, but not file-signature detection. fileSignatureDetectionEnabled runs independently of engine — set it explicitly if you want the magic-byte scan under EXTERNAL_ONLY.
  • fileSignatureAction never accepts MASK. A magic-byte match has no well-defined redaction span, so only BLOCK/FLAG are valid; sending MASK is rejected at save time.
  • A literalAnchors entry 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.
  • MASK on a guard def redacts and lets the (redacted) traffic through — unlike BLOCK, the request or response is not rejected, only the matched span is replaced.
  • decodeEncodedContent widens what is scanned, it never narrows it — when nothing decodes, or the flag is off, the guard sees the byte-identical original text.