Multitype
METHOD: POST
ENDPOINT: https://api.playground.protegrity.com/v1/multi
DESCRIPTION:
Protect or unprotect various attributes within a payload. Please refer to the specific payload type descriptions to see available options.
ATTRIBUTES:
data
(required) Input data to transform.
type
(required) Type of data provided. It should match one of available Data Protection endpoints, e.g. name, address, ccn.
operation
(required) Specify if to protect or unprotect data. Accepts: [ protect | unprotect ]
.
id
(required) A numeric id for tracking separete elements.
user
(optional) Choose a user to impersonate from the list of pre-configured roles.
OPTIONS:
options
(optional) Options as available for each endpoint type.
SAMPLE REQUEST
curl --location 'https://api.playground.protegrity.com/v1/multi' \
--header 'x-api-key: <API_Key>' \
--header 'Content-Type: application/json' \
--header 'Authorization: <JWT_TOKEN>' \
--data '[
{
"id": 1,
"type": "address",
"operation": "protect",
"data": ["Place 8 Rue Nicolau", "46 avenue de la Grande Armée"],
"options":{
"dictionary": "fr"
}
},
{
"id": 2,
"type": "city",
"operation": "protect",
"data": ["Paris"]
}
]'
import requests
import json
JWT_Token = "<JWT_TOKEN>"
API_Key = "<API_Key>"
url = 'https://api.playground.protegrity.com/v1/multi'
headers = { 'x-api-key': API_Key, 'Content-Type': 'application/json', 'Authorization': JWT_Token }
data = [
{
"id": 1,
"type": "address",
"operation": "protect",
"data": ["Place 8 Rue Nicolau", "46 avenue de la Grande Armée"],
"options":{
"dictionary": "fr"
}
},
{
"id": 2,
"type": "city",
"operation": "protect",
"data": ["Paris"]
}
]
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/mutli");
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\", \"data\": [\n" + //
" {\n" + //
" \"id\": 1,\n" + //
" \"type\": \"address\",\n" + //
" \"operation\": \"protect\",\n" + //
" \"data\": [\"Place 8 Rue Nicolau\", \"46 avenue de la Grande Armée\"],\n" + //
" \"options\":{\n" + //
" \"dictionary\": \"fr\"\n" + //
" }\n" + //
" },\n" + //
" {\n" + //
" \"id\": 2,\n" + //
" \"type\": \"city\",\n" + //
" \"operation\": \"protect\",\n" + //
" \"data\": [\"Paris\"]\n" + //
" }\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/multi',
{ method: 'POST',
headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' },
body: JSON.stringify({
"operation": "protect",
"data": [
{
"id": 1,
"type": "address",
"operation": "protect",
"data": ["Place 8 Rue Nicolau", "46 avenue de la Grande Armée"],
"options":{
"dictionary": "fr"
}
},
{
"id": 2,
"type": "city",
"operation": "protect",
"data": ["Paris"]
}
]
})
})
.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/multi"
data := strings.NewReader(`{
"operation": "protect",
"data": [
{
"id": 1,
"type": "address",
"operation": "protect",
"data": ["Place 8 Rue Nicolau", "46 avenue de la Grande Armée"],
"options":{
"dictionary": "fr"
}
},
{
"id": 2,
"type": "city",
"operation": "protect",
"data": ["Paris"]
}
]
}`)
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
[
{
"id": "1",
"results": [
"è6HmO s 0Cq okÎHWmxÛR",
"sC ÈÂÉÉut éj Âî C1io3V 7xIoZSV"
]
},
{
"id": "2",
"results": [
"ôdnÂefp"
]
}
]
Last modified March 4, 2025