Inspecting Text for Sensitive Data

The DLP API can detect and classify sensitive data. Given text input, the API returns JSON output that includes details about any InfoTypes found in the text, a likelihood value, and offset information.

Inspecting a String

You can use the DLP API's CLI tool to easily check a string for sensitive data. To set up the CLI, refer to the quickstart. You can also feed information to the API using cURL and JSON. For more information, see the JSON quickstart.

CLI

Sample Input:

node inspect string "My phone number is (123) 456-7890"
Sample Output:
[
  {
    "quote": "(123) 456-7890",
    "infoType": {
      "name": "PHONE_NUMBER"
    },
    "likelihood": "POSSIBLE",
    "location": {
      "byteRange": {
        "start": "19",
        "end": "33"
      },
       "codepointRange": {
         "start": "19",
         "end": "33"
       }
    },
    "createTime": "1970-01-18T05:28:03.541776Z"
  }
]
    

JSON

Sample Input:

{
  "items":
  [
    {
      "type": "text/plain",
      "value": "My phone number is (123) 456-7890"
    }
  ],
  "inspectConfig":
  {
    "includeQuote": false,
    "minLikelihood": "POSSIBLE"
  }
}
URL:
  POST https://dlp.googleapis.com/v2beta1/content:inspect
Sample Output:
[
  {
    "quote": "(123) 456-7890",
    "infoType": {
      "name": "PHONE_NUMBER"
    },
    "likelihood": "POSSIBLE",
    "location": {
      "byteRange": {
        "start": "19",
        "end": "33"
      },
      "codepointRange": {
      "start": "19",
      "end": "33"
      }
    },
    "createTime": "1970-01-18T05:28:03.541776Z"
  }
]
    

Inspecting a Text File

CLI

Sample Input:

node inspect file my-file.txt
Sample Output, if my-file.text contained only the string "My phone number is (123) 456-7890":
[
  {
    "quote": "(123) 456-7890",
    "infoType": {
      "name": "PHONE_NUMBER"
    },
    "likelihood": "POSSIBLE",
    "location": {
      "byteRange": {
        "start": "19",
        "end": "33"
      },
       "codepointRange": {
       "start": "19",
       "end": "33"
        }
    },
    "createTime": "1970-01-18T05:28:03.541776Z"
  }
]

Send feedback about...

Data Loss Prevention API