Skip to content
Back to catalog

Redact sensitive data with Pangea

Remove emails, phone numbers, and other sensitive data from text with Pangea Redact

Pangea offers security features as API services that developers call from their own apps. Its Redact service detects sensitive information in text, such as email addresses, phone numbers, and credit card numbers, and replaces it based on rules you configure.

How does the integration work?

The Censor with Redact function template puts Pangea Redact behind an Appwrite Function. Send it text, and it returns the same text with the sensitive parts replaced, so you can clean messages, comments, or support tickets before you store or display them.

RoutePurpose
GET /Serves a demo form for trying the function
POST /Redacts the text field of the JSON body and returns {"ok": true, "redacted": "..."}

The template is available for Node.js, Python, and Dart.

How to implement

To implement the Pangea Redact integration, there are several steps you must complete:

Step 1: Set up Pangea Redact

Sign up for Pangea and enable the Redact service in your project. Note the domain on the service's Overview page, then open API Credentials and copy the default service token from the Service Tokens tab. Tokens start with pts_.

Keep a single Redact configuration in the project. The template doesn't send a configuration ID, and Pangea rejects requests without one when a project has several configurations.

Step 2: Create the Appwrite Function

For this step, you must create an account on Appwrite Cloud or self-host Appwrite if you haven't already. If you self-host Appwrite, enable a runtime the template supports in _APP_FUNCTIONS_RUNTIMES and follow the Functions configuration guide so function domains work.

In the Appwrite Console, go to Functions, open the Templates tab, search for Censor with Redact, and click Create from template. Under Template variables, set PANGEA_REDACT_TOKEN to your Pangea token.

If your Pangea domain is aws.eu.pangea.cloud, you can choose Connect later to deploy right away. Otherwise, choose Connect your repository so you can update the endpoint in the cloned code, as described above. Then click Create and deploy.

Step 3: Test the function

Copy the function's domain from the Domains tab and open it in your browser to try the demo form, or send a request:

Bash
curl -X POST https://<FUNCTION_DOMAIN> \
-H "Content-Type: application/json" \
-d '{"text": "My email address is myname2000@gmail.com"}'

The response contains the redacted text, for example:

JSON
{
"ok": true,
"redacted": "My email address is <EMAIL_ADDRESS>"
}

What Redact replaces, and how, depends on the rules in your Redact configuration in the Pangea console.

The template allows anyone to execute the function, so anyone who finds its domain can send text to Redact with your Pangea token. Before you use it in a public app, replace Any in the function's execute access with narrower roles, such as Users, and call the function with an Appwrite SDK instead of its domain.

Read more about Pangea and Appwrite Functions

If you would like to learn more about Pangea and Appwrite Functions, we have some resources that you should visit:

Technology Partner Program

Building on Appwrite?

Teams and developers who ship integrations, tools, or services on Appwrite can join our partner program for verified catalog placement, co-marketing, training, and engineering support.