Credit Card Number (PCI DSS)

Data protection endpoint

METHOD: POST

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

DESCRIPTION:

Protect or unprotect a Credit Card Number. The returned CCN is not length-preserving. The endpoint accepts partial CCN protection, i.e. leaving the 8-digit BIN in the clear.

ATTRIBUTES:

data (required) Input data to transform.

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

operation (required) Specify if to protect or unprotect data. Accepts: [ protect | unprotect ].

OPTIONS:

bin (optional) Set to true to leave the 8-digit BIN number in the clear. Must be set to true when unprotecting the string tokenized using this option. Accepts: [ true | false ]. Defaults to false.

eiv (optional) Provide your custom initialization vector to introduce additional variance in the output. The IV 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/ccn'
--header 'x-api-key: <API_Key>'
--header 'Content-Type: application/json'
--header 'Authorization: <JWT_TOKEN>'
--data '{ "operation": "protect", "data": ["4321567898765432", "2376876534560987"], "options": { "bin": false } }' 
import requests import json

url = 'https://api.playground.protegrity.com/v1/ccn' 
headers = { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' } 
data = { 
    "operation": "protect", 
    "data": ["4321567898765432", "2376876534560987"], 
    "options": { 
      "bin": false 
      } 
    } 

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/ccn");
    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\": [\"4321567898765432\", \"2376876534560987\"], \"options\": { \"bin\": false } }";
    
    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/ccn', 
    { method: 'POST', 
      headers: { 'x-api-key': '<API_Key>', 'Content-Type': 'application/json', 'Authorization': '<JWT_TOKEN>' }, 
      body: JSON.stringify({ 
        "operation": "protect", 
        "data": ["4321567898765432", "2376876534560987"], 
        "options": { "bin": false } 
        }) 
    })
    .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/ccn" 
	data := strings.NewReader(`{ 
		"operation": "protect", 
		"data": ["4321567898765432", "2376876534560987"],
		"options": {"bin": false} 
	  }`) 
  
	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


[
  "0449999816792240",
  "6683962881463918"
]



Last modified March 4, 2025