Sensitive Data Protection can redact or obfuscate sensitive data from a string of text. You can feed textual information to the API using JSON over HTTP, or use one of the client libraries to do so using several popular programming languages.
The projects.content.deidentify
API takes the following as arguments:
- A string of text.
- Placeholder text that will replace any sensitive data detected. In this example, the data is replaced with its corresponding infoType.
- A list of one or more infoTypes that you want to redact.
Sensitive Data Protection returns the string with any sensitive data replaced by your chosen placeholder.
Example text redaction
For more information about using JSON with the DLP API, see the JSON quickstart.
C#
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
REST
JSON input:
{
"item": {
"value":"My email is test@example.com",
},
"deidentifyConfig": {
"infoTypeTransformations":{
"transformations": [
{
"primitiveTransformation": {
"replaceWithInfoTypeConfig": {}
}
}
]
}
},
"inspectConfig": {
"infoTypes": {
"name": "EMAIL_ADDRESS"
}
}
}
URL:
https://dlp.googleapis.com/v2/projects/[PROJECT_ID]/content:deidentify
Sensitive Data Protection returns the following after receiving the request:
JSON output:
{
"item":{
"value":"My email is [EMAIL_ADDRESS]"
},
"overview":{
"transformedBytes":"16",
"transformationSummaries":[
{
"infoType":{
"name":"EMAIL_ADDRESS"
},
"transformation":{
"replaceWithInfoTypeConfig":{
}
},
"results":[
{
"count":"1",
"code":"SUCCESS"
}
],
"transformedBytes":"16"
}
]
}
}
You can try this out yourself using the API Explorer embedded here.
Next steps
Redaction is one form of de-identification. To learn more about how to de-identify content, see De-identifying sensitive data in text content.