All guides

Redact Personal Data with Custom Guardrail Rules

Protect personal data with Cloptima's regional templates, and write your own rules for the business terms only you have.

9 min read Updated November 2026Guardrails
On this page
  1. 01What you'll set up
  2. 02Templates and your own rules
  3. 03Start from a regional template
  4. 04Terms, a pattern, or a labeled value
  5. 05Add a rule
  6. 06Examples you can adapt
  7. 07Limits that keep traffic fast
  8. 08Test and tune
  9. 09As code

01

What you'll set up

You will add a regional personal-data template and your own rules to a guardrail profile, test them against sample text, and tune them until they catch what you intend.

  • A regional personal-data template
  • Custom rules of your own: terms, a pattern, or a labeled value
  • A redact-or-block choice for each rule
  • A tuning loop that keeps false matches low

You need a guardrail profile first. If you do not have one, start with the guide on creating your first guardrail profile.

02

Templates and your own rules

Cloptima templates cover credentials and the common personal-data formats of each region. What else counts as sensitive depends on your business, and custom rules cover it.

Cloptima templates

  • Credentials, personal data by region, financial, healthcare, and infrastructure identifiers
  • Maintained by Cloptima

Your rules

  • Customer identifiers, employee IDs, internal codenames
  • Defined by you, tuned to your data

03

Start from a regional template

Open the profile in AI → Guardrails and choose Edit. Under Protect sensitive data, switch on the template for each region you serve, and choose Redact or Block for it. Each template lists its rules, so you can see exactly what it finds.

TemplateWhat it finds
US personal dataEmail addresses, Social Security numbers, US phone numbers, card numbers, and labeled passport, driver's license, and date-of-birth values
European personal dataEmail addresses, IBANs, international phone numbers, and card numbers
UK personal dataEmail addresses, National Insurance numbers, NHS numbers, UK phone numbers, postcodes, sort codes, IBANs, and card numbers
Canadian personal dataEmail addresses, Social Insurance Numbers, phone numbers, postal codes, health card numbers, and card numbers
Indian personal dataEmail addresses, Aadhaar numbers, PAN and GSTIN identifiers, mobile numbers, IFSC codes, and card numbers
Australian personal dataEmail addresses, Tax File Numbers, Medicare numbers, ABNs, BSBs, phone numbers, and card numbers

04

Terms, a pattern, or a labeled value

A custom rule matches a list of terms, one regular expression, or a value next to its label. Choose by what you are looking for.

UseWhenBehaves like
Term listFixed words and names, such as codenamesEach term matches as whole words, in any letter case.
Regular expression (RE2)Formats, such as IDs and host namesCase-sensitive. Add (?i) to match any letter case. No lookaround or backreferences.
Labeled value (RE2)A number that means something only next to its label, such as Employee ID: E123456Finds the value on the label's line, or alone on the next line. Only the value is replaced.

05

Add a rule

In the profile editor, under Protect sensitive data, choose Add custom rule.

  1. 1

    Give the rule an ID

    Use lowercase letters, digits, and underscores, such as project_codenames. Each ID is unique in the profile, and it names the rule's placeholder.

  2. 2

    Choose how it matches

    Pick Term list, Regular expression (RE2), or Labeled value (RE2).

  3. 3

    Choose On match

    Redact replaces the match with a placeholder. Block refuses a request whose new message matches.

  4. 4

    Enter what to find

    Terms go one per line. A pattern goes in the Pattern field. A labeled value takes a Label and a Value.

  5. 5

    Save

    The rule is live as soon as the profile is saved.

AI → Guardrails → Edit guardrail profile → Add custom rule
1Rule ID
project_codenames
2Match
Term list
3On match
Block
4Terms (one per line)
project falcon internal-only

Each term matches as whole words, in any letter case.

Terms for names, patterns for formats.

06

Examples you can adapt

These cover the patterns teams ask for most.

GoalMatchRuleOn match
Keep a project codename out of promptsTerm listProject FalconBlock
Mask internal host namesRegular expression\b[a-z0-9-]+\.corp\.example\.com\bRedact
Mask employee IDs like EMP-123456Regular expression\bEMP-\d{6}\bRedact
Catch customer account numbersRegular expression\bACCT-\d{8}\bRedact
Mask badge numbers that follow a labelLabeled valueLabel (?i:employee id|badge), value E\d{6}Redact
What the model receives
Before: Email [email protected] about account ACCT-20481977.
After:  Email [EMAIL_ADDRESS_K7Q2M4XAB3CD] about account [ACCOUNT_NUMBER_R5T2WQ6ZHJ3N].

The same value gets the same placeholder on every turn, so the model can still reason about it. When the answer repeats a placeholder, your app gets the original value back.

07

Limits that keep traffic fast

Rules run on a linear-time matcher, so no pattern can slow your traffic or stall other requests. To keep that guarantee, rules have bounds.

ItemLimitWhy
Terms per ruleUp to 10Keeps each rule focused
Length of a termUp to 64 charactersKeeps matching predictable
Length of a pattern, label, or valueUp to 128 charactersKeeps matching predictable
Pattern featuresNo look-ahead and no back-referencesThese are what make matching unpredictable
Rules per profileDepends on your planSee pricing

08

Test and tune

Attach the profile to a policy in Monitor only and send sample prompts through a test key. The profile records what it would redact or block, and requests it would have blocked appear in Audit, under Policy violations.

  • Too many matches: tighten the pattern, or use a labeled value so a number matches only next to its label
  • Missed matches: add a second rule for the other format, rather than one complex rule
  • A format that varies by country: add one rule per format, with clear IDs
  • Names and addresses in free text: add a provider safety scan, because pattern rules cannot understand meaning

09

As code

Teams that manage infrastructure in Terraform can keep guardrail profiles there.

main.tf
resource "cloptima_llm_guardrail_profile" "customer_data" {
  name = "Customer data protection"
  definition = {
    protect = [
      { template = "secrets", action = "redact" },
      { template = "us_personal_data", action = "redact" },
      { rule = "employee_id", match = { regex = "\\bEMP-\\d{6}\\b" }, action = "redact" },
      { rule = "codename", match = { terms = ["Project Falcon"] }, action = "block" },
    ]
  }
}

Put This Guide Into Practice

Cloptima automates the strategies described in this guide.

No credit card required
5-minute setup
Free plan