This document describes how to use the Cloud Data Loss Prevention API to detect sensitive text and objects in an image. Sensitive Data Protection returns the location of any sensitive data that it detects.
Given an image as input, Sensitive Data Protection detects sensitive data
in the image. The output of an inspection operation includes the detected
infoTypes, the
likelihood of the match, and pixel
coordinates and length values that indicate the areas within which
Sensitive Data Protection found the sensitive data. The coordinates at the bottom
left corner of an image are (0,0)
.
Inspect an image for all default infoTypes
To inspect an image for sensitive data, you submit a base64-encoded image to the
content.inspect
method. If you don't specify specific information types (infoTypes)
to search for, Sensitive Data Protection
searches for the most common infoTypes.
To inspect an image for all default infoTypes, follow these steps:
- Encode the image as base64.
- Submit a request to the
content.inspect
method of the DLP API. The request requires only the base64-encoded image.
For example, consider this image of a document.

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
To inspect this image for default infoTypes, send the following JSON to
the content.inspect
method:
{ "item": { "byteItem": { "data": "BASE64_ENCODED_IMAGE", "type": "IMAGE_PNG" } } }
The output is similar to the following:
{ "result": { "findings": [ { "infoType": { "name": "PERSON_NAME", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 383, "left": 419, "width": 82, "height": 38 }, { "top": 383, "left": 494, "width": 91, "height": 37 } ] } } ] }, "createTime": "2025-05-22T20:27:03.730Z", "findingId": "2025-05-22T20:27:03.731510Z4997664074931396457" }, { "infoType": { "name": "EMAIL_ADDRESS", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "VERY_LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 445, "left": 390, "width": 357, "height": 48 } ] } } ] }, "createTime": "2025-05-22T20:27:03.728Z", "findingId": "2025-05-22T20:27:03.731538Z284444825812417100" }, { "infoType": { "name": "PHONE_NUMBER", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "VERY_LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 515, "left": 404, "width": 223, "height": 34 } ] } } ] }, "createTime": "2025-05-22T20:27:03.729Z", "findingId": "2025-05-22T20:27:03.731544Z7910624062018243126" }, { "infoType": { "name": "PERSON_NAME", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "UNLIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 798, "left": 473, "width": 81, "height": 45 } ] } } ] }, "createTime": "2025-05-22T20:27:03.730Z", "findingId": "2025-05-22T20:27:03.731551Z2345136870450870227" }, { "infoType": { "name": "PERSON_NAME", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "UNLIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 837, "left": 1166, "width": 46, "height": 45 } ] } } ] }, "createTime": "2025-05-22T20:27:03.730Z", "findingId": "2025-05-22T20:27:03.731557Z6725780456697828166" }, { "infoType": { "name": "PERSON_NAME", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "UNLIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 915, "left": 453, "width": 141, "height": 43 } ] } } ] }, "createTime": "2025-05-22T20:27:03.730Z", "findingId": "2025-05-22T20:27:03.731562Z7328853308213386463" }, { "infoType": { "name": "PERSON_NAME", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "UNLIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 915, "left": 1180, "width": 105, "height": 43 } ] } } ] }, "createTime": "2025-05-22T20:27:03.730Z", "findingId": "2025-05-22T20:27:03.731569Z5618332947461439057" } ] } }
In this example, Sensitive Data Protection found the following infoTypes, though its match confidence for each one varies:
PERSON_NAME
EMAIL_ADDRESS
PHONE_NUMBER
See the JSON quickstart for more information about using the DLP API with JSON.
Be aware that Sensitive Data Protection often uses multiple boxes to indicate where a single instance of sensitive data is in the image.
Inspect an image for specific infoTypes
To inspect an image for only certain sensitive data types, specify their corresponding built-in infoTypes.
To inspect an image for specific infoTypes, follow these steps:
- Encode the image as base64.
- Submit a request to the
content.inspect
method of the DLP API. The request must include the following:- The base64-encoded image.
- One or more infoType detectors.
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
Consider the original image from the previous section. To inspect for only email
addresses and telephone numbers, send the following JSON to the
content.inspect
method.
{ "item": { "byteItem": { "data": "BASE64_ENCODED_IMAGE", "type": "IMAGE_PNG" } }, "inspectConfig": { "infoTypes": [ { "name": "PHONE_NUMBER" }, { "name": "EMAIL_ADDRESS" } ] } }
The output is similar to the following:
{ "result": { "findings": [ { "infoType": { "name": "EMAIL_ADDRESS", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "VERY_LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 445, "left": 390, "width": 357, "height": 48 } ] } } ] }, "createTime": "2025-05-22T20:59:48.653Z", "findingId": "2025-05-22T20:59:48.654873Z3907900286477341146" }, { "infoType": { "name": "PHONE_NUMBER", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "VERY_LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 515, "left": 404, "width": 223, "height": 34 } ] } } ] }, "createTime": "2025-05-22T20:59:48.653Z", "findingId": "2025-05-22T20:59:48.654914Z7486984971818202511" } ] } }
See the JSON quickstart for more information about using the DLP API with JSON.
Inspect an image for sensitive objects
To inspect an image for sensitive objects, specify the built-in object infoType detectors in the request.
To inspect an image for specific object infoTypes, follow these steps:
- Encode the image as base64.
- Submit a request to the
content.inspect
method of the DLP API. The request must include the following:- The base64-encoded image.
- One or more object infoType detectors.
For example, consider the following image.

To inspect this image for specific object infoTypes, send the following JSON to
the content.inspect
method:
{ "item": { "byteItem": { "data": "BASE64_ENCODED_IMAGE", "type": "IMAGE_PNG" } }, "inspectConfig": { "infoTypes": [ { "name": "OBJECT_TYPE/BARCODE" }, { "name": "OBJECT_TYPE/LICENSE_PLATE" }, { "name": "OBJECT_TYPE/WHITEBOARD" } ] } }
The output is similar to the following:
{ "result": { "findings": [ { "infoType": { "name": "OBJECT_TYPE/WHITEBOARD", "sensitivityScore": { "score": "SENSITIVITY_LOW" } }, "likelihood": "LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "left": 427, "width": 561, "height": 678 } ] } } ] }, "createTime": "2025-05-22T22:25:09.564718Z", "findingId": "2025-05-22T22:25:09.564721Z3400818180961962648" }, { "infoType": { "name": "OBJECT_TYPE/LICENSE_PLATE", "sensitivityScore": { "score": "SENSITIVITY_MODERATE" } }, "likelihood": "LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 554, "left": 137, "width": 187, "height": 70 } ] } } ] }, "createTime": "2025-05-22T22:25:09.564752Z", "findingId": "2025-05-22T22:25:09.564753Z2359274424382836782" }, { "infoType": { "name": "OBJECT_TYPE/BARCODE", "sensitivityScore": { "score": "SENSITIVITY_LOW" } }, "likelihood": "LIKELY", "location": { "contentLocations": [ { "imageLocation": { "boundingBoxes": [ { "top": 569, "left": 666, "width": 306, "height": 274 } ] } } ] }, "createTime": "2025-05-22T22:25:09.564762Z", "findingId": "2025-05-22T22:25:09.564762Z1655085669963455621" } ] } }
See the JSON quickstart for more information about using the DLP API with JSON.
Code examples
Following is sample code in several languages that demonstrates how to use Sensitive Data Protection to inspect an image for sensitive data.
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.
Try it out
You can try each of these examples out yourself—or experiment with your
own images—in the API Explorer on the reference page for
content.inspect
:
What's next
- Learn more about image inspection and redaction.
- Learn how to redact sensitive data from images.