Detokenize data
Detokenization involves using tokens to fetch sensitive data stored in a vault. Detokenization lets authorized users and processes access the original information whenever necessary. You can call the Detokenize API or use an SDK to detokenize your data and ensure data accessibility while abiding by security protocols.
Prerequisites
Section titled “Prerequisites”-
A vault for which you have the Vault Owner role.
-
Skyflow account, vault, and workspace details:
- In Studio, click vault menu icon > View vault details.
- Note your Account ID, Vault ID, and Vault URL values.
-
A bearer token to authenticate API calls. For a short-lived token, use the following process. To generate tokens from service accounts, see Authenticate.
-
In Studio, click your account icon and choose Generate API Bearer Token.
-
Click Generate Token.
-
-
Set environment variables for your account and vault details:
export VAULT_URL=$VAULT_URLexport VAULT_ID=$VAULT_IDexport ACCOUNT_ID=$ACCOUNT_IDexport BEARER_TOKEN=$BEARER_TOKENexport TOKEN_1=$TOKEN_VALUE_1export TOKEN_2=$TOKEN_VALUE_2export TOKEN_3=$TOKEN_VALUE_3export REDACTION_1=$REDACTION_TYPE_1export REDACTION_2=$REDACTION_TYPE_2export REDACTION_3=$REDACTION_TYPE_3Detokenize your data
Section titled “Detokenize your data”When you need to view sensitive, tokenized data, call the Detokenize API to retrieve the corresponding values.
curl -s -X POST "$VAULT_URL/v1/vaults/$VAULT_ID/detokenize" \-H "Authorization: Bearer $BEARER_TOKEN" \-H "content-type: application/json" \-d '{ "detokenizationParameters": [ { "token": "'"$TOKEN_VALUE_1"'", "redaction": "$REDACTION_TYPE_1" }, { "token": "'"$TOKEN_VALUE_2"'", "redaction": "$REDACTION_TYPE_2" }, { "token": "'"$TOKEN_VALUE_3"'", "redaction": "$REDACTION_TYPE_3" } ], "downloadURL": false}'The response returns the detokenized values.
{ "records": [ { "token": "TOKEN_VALUE_1", "valueType": "VALUE_TYPE", "value": "DATA_VALUE" }, { "token": "TOKEN_VALUE_2", "valueType": "VALUE_TYPE", "value": "DATA_VALUE" }, { "token": "TOKEN_VALUE_3", "valueType": "VALUE_TYPE", "value": "DATA_VALUE" } ]}Handle errors in batch operations
Section titled “Handle errors in batch operations”The continueOnError setting lets you manage the behavior of detokenization calls in the event of an error. When continueOnError is true, detokenization continues for all specified tokens even if the vault fails to find a value for a particular token. If false and any token in the request encounters an error, the request stops and returns an error message.
curl -s -X POST "$MANAGEMENT_URL/v1/vaults/$VAULT_ID/detokenize" \-H "Authorization: Bearer $BEARER_TOKEN" \-H "content-type: application/json" \-d '{ "detokenizationParameters": [ { "token": "'"$TOKEN_VALUE_1"'", "redaction": "$REDACTION_TYPE_1" }, { "token": "'"$TOKEN_VALUE_2"'", "redaction": "$REDACTION_TYPE_2" }, { "token": "'"$TOKEN_VALUE_3"'", "redaction": "$REDACTION_TYPE_3" } ], "downloadURL": false "continueOnError": true}'If the request is successful, the error field returns null. If it’s unsuccessful, valueType is NONE, and error displays a specific error message.
{ "records": [ { "token": "TOKEN_VALUE_1", "valueType": "VALUE_TYPE", "value": "DATA_VALUE", "error": null }, { "token": "TOKEN_VALUE_2", "valueType": "NONE", "value": "", "error": "Token not found" }, { "token": "TOKEN_VALUE_3", "valueType": "VALUE_TYPE", "value": "", "error": "Token not found" } ]}When continueOnError is false and token values are missing, the response returns an error message specifying the missing tokens.
{ "error": { "grpc_code": 5, "http_code": 404, "message": "Token not found for token_2, token_3", "http_status": "Not Found", "details": [] }}Next steps
Section titled “Next steps”Learn more about tokenization, review tokenization and compliance, or explore data governance.