Skip to main content

Redact

Stop leaking PII, financial, healthcare, and other forms of personal and private data. Use the redact service with custom rules to identify and remove sensitive data.

Protecting PII

ChatGPT example

Additional Resources

About

Pangea’s Redact service helps developers control sensitive information by performing redaction using defined rules. Redact comes equipped with out-of-the-box rules to address personally identifiable information (PII), geographic locations, payment card industry (PCI) data, and many other types of sensitive information, while also providing rule customization to fit the needs of your application.

Quickstart

These steps are a basic outline of how to configure Redact in order to begin integrating the service with your application. For more in-depth information and a complete set of step-by-step instructions, refer to our configuration guide.

  1. Navigate to the Pangea User Console .
  2. Sign up to Pangea. As part of the sign up process, an Organization and initial token will be created.
  3. Accept the default configuration to get started with the quickstart steps below, and for more info on configuring your Redact token and rulesets you can visit Get Started with Redact.
  4. Set any desired settings in the Rulesets page under the Redact page in your console.

Add Redact to your app

The steps below will walk you through the basics of integrating Redact with a Python application, including a code sample for redacting sensitive information. For a more in-depth explanation and other examples you can visit our Python SDK.

Set your environment variables

Before starting to code, it is necessary to export your token and domain variables to your project if you have not already added them to your environment.

  1. Open up a bash terminal window.
  2. Type the following commands, replacing yourServiceDomain and yourAccessToken with your Domain and Default Token copied from the Redact page in the Pangea User Console.
export PANGEA_DOMAIN="yourServiceDomain"
export PANGEA_REDACT_TOKEN="yourAccessToken"

Writing the Redact code

  1. In order to be ready to code, you must first install the Pangea SDK. To add the Pangea Python SDK to your project, you will need to run one of the following commands in your project root directory based on your preferred installation method.

Install SDK via Pip:

pip3 install pangea-sdk

or

Install SDK via Poetry:

poetry add pangea-sdk
  1. Next, import the Pangea libraries into your code.
import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Redact
  1. Load the client configuration, adding the token and domain from your environment variables so you can authenticate with Pangea. You can read more about how Pangea uses tokens on our Tokens page.
token = os.getenv("PANGEA_REDACT_TOKEN")
assert token
domain = os.getenv("PANGEA_DOMAIN")
assert domain
config = PangeaConfig(domain=domain)
redact = Redact(token, config=config)
  1. Create the text request and send it to the Redact service.
text = "Hello, my phone number is 123-456-7890"
print(f"Redacting PII from: {text}")
  1. Print the redacted text if successful, including exception handling.
try:
    redact_response = redact.redact(text=text)
    print(f"Redacted text: {redact_response.result.redacted_text}")
except pe.PangeaAPIException as e:
    print(f"Embargo Request Error: {e.response.summary}")
    for err in e.errors:
        print(f"\t{err.detail} \n")

Completed code

The code sample below is a usable, copy & paste resource for this application that will work on its own. For best results, be sure to edit placeholder data in the request with your desired values, such as the text field message, and experiment with rules in the Rulesets page under Redact in your Pangea User Console .

import os

import pangea.exceptions as pe
from pangea.config import PangeaConfig
from pangea.services import Redact

token = os.getenv("PANGEA_REDACT_TOKEN")
assert token
domain = os.getenv("PANGEA_DOMAIN")
assert domain
config = PangeaConfig(domain=domain)
redact = Redact(token, config=config)


def main():
    text = "Hello, my phone number is 123-456-7890"
    print(f"Redacting PII from: {text}")

    try:
        redact_response = redact.redact(text=text)
        print(f"Redacted text: {redact_response.result.redacted_text}")
    except pe.PangeaAPIException as e:
        print(f"Embargo Request Error: {e.response.summary}")
        for err in e.errors:
            print(f"\t{err.detail} \n")


if __name__ == "__main__":
    main()

Improving your app

The purpose of this guide is to provide the minimum steps required to start coding with our Redact service, however there are additional features that can be added to this process, such as integration with other Pangea services that have data storage requirements. Read more about the capabilities on our Redact Overview page.

Pangea has based Redact on years of experience building compliant enterprise applications. This service helps to ensure that builders have the necessary tools to meet the privacy needs of their application’s users.

Next steps

  • Check out our Admin Guide if you have a specific task you would like to complete
  • If you are feeling confident, you can browse our APIs or explore our Github repo, which has libraries for supported languages, SDKs, sample apps, etc.
  • For any questions, you can connect with our Pangea Discourse for Builders or continue exploring our Redact documentation

Was this article helpful?

Contact us