Contact Us

Tell us about your stack and the privacy problems you're trying to solve. We typically respond within one business day.

Prefer email? support@philterd.ai

Please do not enter PII or PHI in this form. If you need to share an example, use a sanitized one.

Knowledge base How-to

Move Policies Between the Redaction Policy Editor and Philter

Load a policy from the Redaction Policy Editor into Philter 4, bring a stored policy back to edit, and use PhiSQL alongside the editor, with the workarounds the released editor needs.

For Redaction Policy Editor, Philter and PhiSQL

A redaction policy usually lives in more than one place. You build and try it in the Redaction Policy Editor, Philter stores it by name and redacts with it, and later someone needs to change it. Some teams would rather keep policies as PhiSQL files in version control. This guide moves one policy along each of those paths and back.

A policy built in the Redaction Policy Editor is downloaded as JSON and saved to Philter with POST /api/policies, then used with /api/filter. A policy written in PhiSQL is compiled by Philter's POST /api/policies/compile and saved the same way. To edit a stored policy, GET /api/policies/{name} returns its JSON, which Upload Policy loads back into the editor after removing the anonymizationCandidates fields that editor 1.0.0 cannot read.

Everything below was run with the released editor, 1.0.0, and Philter 4.0.1. The commands assume Philter at https://localhost:8080 and your API key in PHILTER_API_KEY. The quick start sets up both. Building the policy itself is covered in Build and test a redaction policy without writing JSON.

Load an editor policy into Philter

The example policy redacts email addresses and phone numbers and masks SSNs. In the editor, set Policy Name to claims-intake, add the three filters, click Generate Policy, then Download Policy. The file is claims-intake.json.

The download is longer than a hand-written policy. Version 1.0.0 writes out every field its Phileas engine knows, including internal ones, and no policy name. One filter looks like this:

"ssn": {
  "ssnFilterStrategies": [
    {
      "filterType": "SSN",
      "id": "59947d35-ccce-45f0-a10f-2ff463ec8edc",
      "strategy": "MASK",
      "redactionFormat": "{{{REDACTED-%t}}}",
      "replacementScope": "CONTEXT",
      "staticReplacement": "",
      "maskCharacter": "*",
      "maskLength": "SAME",
      "truncateCharacter": "*",
      "truncateDirection": "LEADING",
      "condition": "",
      "salt": false,
      "anonymizationCandidates": []
    }
  ],
  "enabled": true,
  "ignored": [],
  "ignoredFiles": [],
  "ignoredPatterns": [],
  "windowSize": 5,
  "priority": 0
}

Philter 4.0.1 accepts the file as it is. The name comes from the request:

curl -sk -X POST "https://localhost:8080/api/policies?name=claims-intake" \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @claims-intake.json \
  -w "HTTP %{http_code}\n"
HTTP 201

Redact with it:

curl -sk "https://localhost:8080/api/filter?p=claims-intake" \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: text/plain" \
  --data-binary "Claimant reached us at (217) 555-0142 and alex.morgan@example.com. SSN on file: 123-45-6789."
Claimant reached us at {{{REDACTED-phone-number}}} and {{{REDACTED-email-address}}}. SSN on file: ***********.

MASK replaces every character of the match, hyphens included.

Compare with Test Policy

Test Policy in the editor gave the same result for this text:

The Test Policy section of the Redaction Policy Editor 1.0.0. The input text, Claimant reached us at (217) 555-0142 and alex.morgan@example.com. SSN on file: 123-45-6789., is redacted to Claimant reached us at {{{REDACTED-phone-number}}} and {{{REDACTED-email-address}}}. SSN on file: ***********.

The two will not always agree. Editor 1.0.0 tests with Phileas 3.3.0, while Philter 4.0.1 runs Phileas 4.5.0. Treat the editor’s result as a quick check and Philter’s as the one that counts, and measure on your own documents with Philter Scope before relying on a policy.

Bring a stored policy back into the editor

Philter returns a stored policy as JSON:

curl -sk "https://localhost:8080/api/policies/claims-intake" \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -o claims-intake.json

For this policy, the file is identical to the one the editor downloaded. Upload Policy in editor 1.0.0 cannot load it, though. It stops with “Failed to parse policy JSON.” and leaves only the first filter in the form. The same happens with any policy the editor itself downloaded: the anonymizationCandidates field it writes into every strategy is one its own upload code cannot place in the form.

Remove that field before uploading (walk needs jq 1.6 or later):

jq 'walk(if type == "object" then del(.anonymizationCandidates) else . end)' \
  claims-intake.json > claims-intake-edit.json

Upload claims-intake-edit.json and all three filters load, with their strategies. The policy name is not part of the JSON, so the form shows default. Type the name again before you download, and save the result back to Philter under the same name with PUT /api/policies/claims-intake.

Upload restores only what the form can show. Check the form against the file, and compare the regenerated JSON with the original before you replace a stored policy.

Write the policy in PhiSQL

Editor 1.0.0 has no PhiSQL support, but Philter 4.0.1 compiles PhiSQL itself. Save this as claims_intake.phisql:

POLICY claims_intake;

REDACT EMAIL_ADDRESS, PHONE_NUMBER WITH REDACT;
REDACT SSN WITH MASK;

Compile it:

curl -sk -X POST https://localhost:8080/api/policies/compile \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: text/plain" \
  --data-binary @claims_intake.phisql
{"name":"claims_intake","policy":{"identifiers":{"emailAddress":{"emailAddressFilterStrategies":[{"strategy":"REDACT"}]},"phoneNumber":{"phoneNumberFilterStrategies":[{"strategy":"REDACT"}]},"ssn":{"ssnFilterStrategies":[{"strategy":"MASK"}]}}}}

Compiling saves nothing. Take the policy object and save it:

curl -sk -X POST https://localhost:8080/api/policies/compile \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: text/plain" \
  --data-binary @claims_intake.phisql | jq '.policy' > claims_intake.json

curl -sk -X POST "https://localhost:8080/api/policies?name=claims_intake" \
  -H "Authorization: Bearer $PHILTER_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @claims_intake.json \
  -w "HTTP %{http_code}\n"
HTTP 201

Redacting the same text with p=claims_intake gives the same output as the editor’s policy above. The compiled JSON has none of the editor’s internal fields, so Upload Policy loads it into editor 1.0.0 directly, all three filters included, if you want to try it in Test Policy or adjust it in the form.

Known issues in editor 1.0.0

  • Zip Code filters cannot be generated from the form. Adding a Zip Code filter makes Generate Policy fail, because the form sends a truncation setting of 0 that the server rejects. The Healthcare preset includes a Zip Code filter, so it fails the same way. Write ZIP code handling in PhiSQL or in the JSON after downloading.
  • Upload Policy fails on the editor’s own downloads, as described above. Remove anonymizationCandidates first.

In the next release

The editor’s main branch, which is not yet released, adds an Author with PhiSQL panel that compiles PhiSQL into the form, and Copy PhiSQL and Download PhiSQL actions that write the current policy out as PhiSQL after checking that it compiles back to the same policy. It also targets redaction policy schema 1.3.0, the version Philter 4.0.1 runs, and its Healthcare preset generates. Until it is published, use Philter’s compile endpoint as shown above.