Docs/Core Concepts/Data Loss Prevention

Data Loss Prevention (DLP)

Automatically detect and mask sensitive data — PII, API keys, credentials, and custom patterns — before it reaches your LLM provider or leaves your system in a response.


Overview

AI agents frequently handle sensitive data: customer emails, phone numbers, API tokens, internal documents. Without a safeguard, that data passes through LLM providers and third-party services — outside your control.

Trappr's DLP layer scans every request and response at the gateway. When a sensitive pattern is detected, it's replaced with a placeholder before being forwarded. The real value never leaves your controlled environment.

Your Agent
sends message with PII
DLP Scanner
masks sensitive values
LLM Provider
sees [MASKED] tokens
DLP Scanner
re-injects on response
Your Agent
receives full response

Built-in pattern library

Trappr ships with a curated set of patterns enabled by default. You can enable or disable individual patterns per app.

CategoryDetected typesDefault
CredentialsAPI keys, Bearer tokens, AWS access keys, private keysOn
PIIEmail addresses, phone numbers, SSNs, passport numbersOn
FinancialCredit card numbers, bank account numbers, IBANsOn
NetworkIP addresses, MAC addresses, internal hostnamesOff
CustomYour own regex patternsConfigurable

Enabling DLP

1
Open DLP settings in the dashboard

Go to Dashboard → DLP. You'll see the full list of built-in pattern categories and any custom rules you've created.

2
Enable the categories you need

Toggle the categories relevant to your agent's data. For agents that handle customer records, enable PII. For agents with tool access to cloud APIs, enable Credentials.

3
Optionally add custom patterns

Under DLP → Custom rules, add regex patterns for data specific to your domain — for example, internal employee IDs, project codes, or domain-specific secrets.

Regex
# Example: internal employee ID
^EMP-[0-9]{6}$

# Example: internal project code
\bPROJ-[A-Z]{3}-[0-9]{4}\b
4
Route traffic through the Gateway

DLP is applied automatically to all requests routed through the AI Gateway. No agent code changes are needed beyond the base URL update.

How masking works

When a pattern match is found, the detected value is replaced with a typed placeholder. The placeholder is scoped to the request — so if your agent uses the masked value in a follow-up message, Trappr resolves it back correctly.

Original valueMasked as
john.doe@company.com[EMAIL_1]
sk-proj-abc123...[API_KEY_1]
+1-555-867-5309[PHONE_1]
4111 1111 1111 1111[CREDIT_CARD_1]
Masking is one-way by design. The unmasked value is not sent to the LLM provider at any point. Your agent's response will contain the placeholder — re-injection into a user-facing interface can be configured separately if needed.

DLP in ENFORCE mode

When an app is in ENFORCE mode, DLP violations can be configured to block the request entirely rather than masking and forwarding. The agent receives an error response with a policy violation code.

JSON
{
  "error": {
    "code": "dlp_policy_violation",
    "message": "Request blocked: sensitive data detected.",
    "type": "trappr_enforcement"
  }
}

Viewing DLP events

Every DLP match is logged with the category, pattern, and the request context under Dashboard → DLP → Events. You can filter by category, time range, and app.

Use DLP event logs to tune your patterns. If you see too many false positives on a particular pattern, you can disable that specific sub-rule without turning off the whole category.