This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

GenAI Security Endpoints (Preview)

Automatic detection & protection of sensitive data

GenAI Security endpoints focus on automated sensitive data discovery and protection. You can detect sensitive data and choose to automatically protect the findings. Protegrity’s context-aware models are leveraged to identify sensitive data within provided input. Currently the classification can only be generated for texts in English.

This collection includes pre-release functionality and is subject to change in the future releases of the platform. We are actively iterating over this offering and welcome industry insight to help shape up the platform.

UPCOMING ENHANCEMENTS:

  • Improved PII detection in sentences without punctuation
  • Improved detection of emails and zipcodes provided without context
  • Improved detection of account numbers in large payloads

1 - Classify (Preview)

Detect and classify sensitive data

METHOD: POST

ENDPOINT: https://api.playground.protegrity.com/v1/ai

DESCRIPTION:

Detect and classify sensitive data in a given input. The endpoint will return a classification and confidence score for every sensitive attribute found, alongside its location – a column name or a start and end index. Confidence score returns values from 0.1 to 1. The higher the confidence score, the more the product is sure of the PII classification it produced. We recommend using the confidence score to prioritize inspection of found sensitive data.

ATTRIBUTES:

data (required) Input data to transform.

operation (required) Type of operation to perform. Choose classify to only detect and classify data. Option protect deidentifies data. Option unprotect restores de-identified data to its original values. Accepts: [ classify | protect | unprotect ]

OPTIONS:

format (required) Specify the format of the input data. Currently the API only supports the option text for unstructured text. Accepts: [ text ].

SAMPLE REQUEST

curl --location 'https://api.playground.protegrity.com/v1/ai' \
--header 'x-api-key: <API_Key>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <JWT_TOKEN>' \
--data '{
    "operation": "classify",
    "options": {
        "format": "text"
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
}'
  
import requests
import json

JWT_Token = "<JWT_TOKEN>"
API_Key = "<API_Key>"
url = 'https://api.playground.protegrity.com/v1/ai' 
headers = { 'x-api-key': API_Key, 'Content-Type': 'application/json', 'Authorization': JWT_Token } 
data = { 
      "options": {
        "format": "text",
        "raw": "false"
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]

} 

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.text)

  
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL; 
import java.io.OutputStream; 
import java.io.InputStreamReader; 
import java.io.BufferedReader;

public class APIRequest { public static void main(String[] args) { 
  try { 
    String JWT_Token = "<JWT_TOKEN>"
    String API_Key = "<API_Key>"
    URI uri = new URI("https://api.playground.protegrity.com/v1/ai");
    URL url = uri.toURL(); 
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
    conn.setRequestMethod("POST"); 
    conn.setRequestProperty("x-api-key", API_Key); 
    conn.setRequestProperty("Content-Type", "application/json"); 
    conn.setRequestProperty("Authorization", JWT_Token); conn.setDoOutput(true);

    String jsonInputString = "{ \"options\": {\n" + //
                "        \"format\": \"text\",\n" + //
                "        \"raw\": false\n" + //
                "    },\n" + //
                "    \"data\": [\"Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!\"]\n" + //
                " }";
    
    try (OutputStream os = conn.getOutputStream()) {
        byte[] input = jsonInputString.getBytes("utf-8");
        os.write(input, 0, input.length);
    }

    try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
        StringBuilder response = new StringBuilder();
        String responseLine = null;
        while ((responseLine = br.readLine()) != null) {
            response.append(responseLine.trim());
        }
        System.out.println(response.toString());
    }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}

  
fetch('https://api.playground.protegrity.com/v1/ai', 
    { method: 'POST', 
      headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' }, 
      body: JSON.stringify({ 
        "options": {
          "format": "text",
          "raw": false
      },
      "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
  
        }) 
    })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error)); 

  
package main

import ( 
	"io" 
	"fmt"
	"strings" 
	"net/http" 
  )
  
func main() { 
	JWT_Token := "<JWT_TOKEN>"
	API_Key := "<API_Key>"
	url := "https://api.playground.protegrity.com/v1/ai" 
	data := strings.NewReader(`{ 
		 "options": {
        "format": "text",
        "raw": false
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
}`) 
  
	req, err := http.NewRequest("POST", url, data)
	if err != nil {
		fmt.Println(err)
		return
	}
  
	req.Header.Set("x-api-key", API_Key)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", JWT_Token)
  
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer resp.Body.Close()
  

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}

  

SAMPLE RESPONSE


[
    {
        "score": 0.85,
        "classification": "PHONE_NUMBER",
        "start_index": 101,
        "end_index": 113
    },
    {
        "score": 0.99,
        "classification": "PERSON",
        "start_index": 15,
        "end_index": 29
    }
]

2 - Protect (Preview)

Detect, classify, and protect sensitive data

METHOD: POST

ENDPOINT: https://api.playground.protegrity.com/v1/ai

DESCRIPTION:

Detect, classify, and protect sensitive data in a given input. The endpoint will protect the attributes classified as sensitive with a confidence score of 0.68 or more.

ATTRIBUTES:

data (required) Input data to transform.

operation (required) Type of operation to perform. Choose classify to only detect and classify data. Option protect deidentifies data. Option unprotect restores de-identified data to its original values. Accepts: [ classify | protect | unprotect ]

user (optional) Choose a user to impersonate from the list of pre-configured roles.

OPTIONS:

format (required) Specify the format of the input data. Currently the API only supports the option text for unstructured text. Accepts: [ text ].

type (optional) Specify the protection mechanism. Option mask replaces all attributes with ‘*****’. Option tokenize applies a tokenization method that matches the classification of the found attribute. Accepts: [ mask | tokenize ]. Defaults to mask.

tags (optional) Specify if to include tags to mark protected attributes with their assigned classification label. Tags are required for reversing the protection. Accepts: [ true | false ]. Defaults to true.

threshold (optional) Set to the preferred confidence score threshold. Protection will be applied to attributes identified as matching or over the set threshold. Set a to numeric value. If not specified, the threshold is configured to 0.68.

eiv (optional) Provide your custom initialization vector to introduce additional variance in the output. The input may be a number, letter, special character, or a combination of those. Learn more about the IVs in the Key Concepts section. Note that to unprotect the data back to its original value, the eiv has to be provided in the payload.

SAMPLE REQUEST

curl --location 'https://api.playground.protegrity.com/v1/ai' \
--header 'x-api-key: <API_Key>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <JWT_TOKEN>' \
--data '{
    "operation": "protect",
    "options": {
        "format": "text",
        "type": "mask",
        "tags": false,
        "threshold": 0.7
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
}'
  
import requests
import json

JWT_Token = "<JWT_TOKEN>"
API_Key = "<API_Key>"
url = 'https://api.playground.protegrity.com/v1/ai' 
headers = { 'x-api-key': API_Key, 'Content-Type': 'application/json', 'Authorization': JWT_Token } 
data = {
    "operation": "protect",
    "options": {
        "format": "text",
        "type": "mask",
        "tags": False,
        "threshold": 0.7
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.text)
  
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL; 
import java.io.OutputStream; 
import java.io.InputStreamReader; 
import java.io.BufferedReader;

public class APIRequest { public static void main(String[] args) { 
  try { 
    String JWT_Token = "<JWT_TOKEN>";
    String API_Key = "<API_Key>";
    URI uri = new URI("https://api.playground.protegrity.com/v1/ai");
    URL url = uri.toURL(); 
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
    conn.setRequestMethod("POST"); 
    conn.setRequestProperty("x-api-key", API_Key); 
    conn.setRequestProperty("Content-Type", "application/json"); 
    conn.setRequestProperty("Authorization", JWT_Token); conn.setDoOutput(true);

    String jsonInputString = "{ \"operation\": \"protect\",\n" + //
                "       \"options\": {\n" + //
                "        \"format\": \"text\",\n" + //
                "        \"type\": \"mask\",\n" + //
                "        \"tags\": \"false\",\n" + //
                "        \"threshold\": \"0.7\",\n" + //
                "    },\n" + //
                "    \"data\": [\"Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!\"]\n" + //
                " }";
    
    try (OutputStream os = conn.getOutputStream()) {
        byte[] input = jsonInputString.getBytes("utf-8");
        os.write(input, 0, input.length);
    }

    try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
        StringBuilder response = new StringBuilder();
        String responseLine = null;
        while ((responseLine = br.readLine()) != null) {
            response.append(responseLine.trim());
        }
        System.out.println(response.toString());
    }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}  
  
fetch('https://api.playground.protegrity.com/v1/ai', 
    { method: 'POST', 
      headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' }, 
      body: JSON.stringify({
        "operation": "protect",
        "options": {
            "format": "text",
            "type": "mask",
            "tags": false,
            "threshold": 0.7
        },
        "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
    }) 
    })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error)); 
  
package main

import ( 
	"io" 
	"fmt"
	"strings" 
	"net/http" 
  )
  
func main() { 
	JWT_Token := "<JWT_TOKEN>"
	API_Key := "<API_Key>"
	url := "https://api.playground.protegrity.com/v1/ai" 
	data := strings.NewReader(`{
    "operation": "protect",
    "options": {
        "format": "text",
        "type": "mask",
        "tags": false,
        "threshold": 0.7
    },
    "data": ["Hello, this is Peregrine Grey from Air Industries, could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"]
}`) 
  
	req, err := http.NewRequest("POST", url, data)
	if err != nil {
		fmt.Println(err)
		return
	}
  
	req.Header.Set("x-api-key", API_Key)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", JWT_Token)
  
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer resp.Body.Close()
  

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}
  

SAMPLE RESPONSE


{
    "results": "Hello, this is ############## from Air Industries. Could you give me a call back to my mobile number ############. Have a lovely day!"
}

3 - Unprotect (Preview)

Re-identify protected data

METHOD: POST

ENDPOINT: https://api.playground.protegrity.com/v1/ai

DESCRIPTION:

Unprotect sensitive data in a given input, i.e. revert previously tokenized values to their original contents. Provided text must include tags to enable this transformation.

ATTRIBUTES:

data (required) Input data to transform.

operation (required) Type of operation to perform. Choose classify to only detect and classify data. Option protect deidentifies data. Option unprotect restores de-identified data to its original values. Accepts: [ classify | protect | unprotect ]

user (optional) Choose a user to impersonate from the list of pre-configured roles.

OPTIONS: format (required) Specify the format of the input data. Currently the API only supports the option text for unstructured text. Accepts: [ text ].

SAMPLE REQUEST

curl --location 'https://api.playground.protegrity.com/v1/ai' \
--header 'x-api-key: <API_Key>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <JWT_TOKEN>' \
--data '{
  "operation": "unprotect",
  "format": "text",
  "user": "paloma.torres",
  "data": ["Hello, this is [PERSON]SQnnLOQMw TEwP[/PERSON] from Air Industries. Could you give me a call back to my mobile number [PHONE_NUMBER]025-016-8606[/PHONE_NUMBER]. Have a lovely day!"]
}'
  
import requests
import json

JWT_Token = "<JWT_TOKEN>"
API_Key = "<API_Key>"
url = 'https://api.playground.protegrity.com/v1/ai' 
headers = { 'x-api-key': API_Key, 'Content-Type': 'application/json', 'Authorization': JWT_Token } 
data = {
  "operation": "unprotect",
  "format": "text",
  "user": "paloma.torres",
  "data": ["Hello, this is [PERSON]SQnnLOQMw TEwP[/PERSON] from Air Industries. Could you give me a call back to my mobile number [PHONE_NUMBER]025-016-8606[/PHONE_NUMBER]. Have a lovely day!"]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

print(response.text)
  
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL; 
import java.io.OutputStream; 
import java.io.InputStreamReader; 
import java.io.BufferedReader;

public class APIRequest { public static void main(String[] args) { 
  try { 
    String JWT_Token = "<JWT_TOKEN>";
    String API_Key = "<API_Key>";
    URI uri = new URI("https://api.playground.protegrity.com/v1/ai");
    URL url = uri.toURL(); 
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
    conn.setRequestMethod("POST"); 
    conn.setRequestProperty("x-api-key", API_Key); 
    conn.setRequestProperty("Content-Type", "application/json"); 
    conn.setRequestProperty("Authorization", JWT_Token); conn.setDoOutput(true);

    String jsonInputString = "{ \"operation\": \"unprotect\",\n" + //
                "       \"options\": {\n" + //
                "        \"format\": \"text\",\n" + //
                "        \"user\": \"paloma.torres\",\n" + //
                "    },\n" + //
                "    \"data\": [\"Hello, this is [PERSON]SQnnLOQMw TEwP[/PERSON] from Air Industries. Could you give me a call back to my mobile number [PHONE_NUMBER]025-016-8606[/PHONE_NUMBER]. Have a lovely day!\"]\n" + //
                " }";
    
    try (OutputStream os = conn.getOutputStream()) {
        byte[] input = jsonInputString.getBytes("utf-8");
        os.write(input, 0, input.length);
    }

    try (BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"))) {
        StringBuilder response = new StringBuilder();
        String responseLine = null;
        while ((responseLine = br.readLine()) != null) {
            response.append(responseLine.trim());
        }
        System.out.println(response.toString());
    }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
  
fetch('https://api.playground.protegrity.com/v1/ai', 
    { method: 'POST', 
      headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' }, 
      body: JSON.stringify({
        "operation": "unprotect",
        "format": "text",
        "user": "paloma.torres",
        "data": ["Hello, this is [PERSON]SQnnLOQMw TEwP[/PERSON] from Air Industries. Could you give me a call back to my mobile number [PHONE_NUMBER]025-016-8606[/PHONE_NUMBER]. Have a lovely day!"]
      }) 
    })
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  
package main

import ( 
	"io" 
	"fmt"
	"strings" 
	"net/http" 
  )
  
func main() { 
	JWT_Token := "<JWT_TOKEN>"
	API_Key := "<API_Key>"
	url := "https://api.playground.protegrity.com/v1/ai" 
	data := strings.NewReader(`{
  "operation": "unprotect",
  "format": "text",
  "user": "paloma.torres",
  "data": ["Hello, this is [PERSON]SQnnLOQMw TEwP[/PERSON] from Air Industries. Could you give me a call back to my mobile number [PHONE_NUMBER]025-016-8606[/PHONE_NUMBER]. Have a lovely day!"]
}`) 
  
	req, err := http.NewRequest("POST", url, data)
	if err != nil {
		fmt.Println(err)
		return
	}
  
	req.Header.Set("x-api-key", API_Key)
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Authorization", JWT_Token)
  
	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer resp.Body.Close()
  

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}
  

SAMPLE RESPONSE


{
  "results": "Hello, this is Peregrine Grey from Air Industries. Could you give me a call back to my mobile number 212-456-7890. Have a lovely day!"
}