Inspecting Text for Sensitive Data

The Data Loss Prevention API can detect and classify sensitive data within text content. Given text input, the API returns details about any InfoTypes found in the text, a likelihood value, and offset information.

Inspecting a Text String

You can use the code samples below to easily check a string for sensitive data. You can also feed information to the API using JSON over HTTP.

See the JSON quickstart for more information on using JSON.

Sample Input:

{
  "item":  {
      "type":"text/plain",
      "value":"My phone number is (415) 555-0890"
  },
  "inspectConfig":{
    "includeQuote":true,
    "minLikelihood":"POSSIBLE",
    "infoTypes": {
      "name": "PHONE_NUMBER"
    }
  }
}
URL:
  POST https://dlp.googleapis.com/v2beta2/projects/project-id/content:inspect
Sample Output:
[
  {
    "quote":"(415) 555-0890",
    "infoType":{
      "name":"PHONE_NUMBER"
    },
    "likelihood":"VERY_LIKELY",
    "location":{
      "byteRange":{
        "start":"19",
        "end":"33"
      },
      "codepointRange":{
        "start":"19",
        "end":"33"
      }
    },
    "createTime":"1970-01-18T05:28:03.541776Z"
  }
]

Inspecting a Text File

Send feedback about...

Data Loss Prevention API