Detokenize
The detokenize
endpoint enables you to detokenize tokens in order to retrieve their original values.
The maximum number of tokens that can be detokenized within a single request is defined by your Tenant's "Detokenize Limit" Quota.
POST
https://api.basistheory.com/detokenizePermissions
token:read
The token:read
permission must be granted on the container of each token included in the request.
Detokenize a single token
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/detokenize" \
-H "BT-API-KEY: <API_KEY>" \
-H "Content-Type: application/json" \
-X "POST" \
-d '{
"card_number": "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}"
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<API_KEY>");
const token = await bt.detokenize({
card_number: "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}",
});
using BasisTheory.net.Detokenize;
var client = new DetokenizeClient("<API_KEY>");
var token = await client.DetokenizeAsync(new {
card_number = "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}"
});
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<API_KEY>");
DetokenizeApi apiInstance = new DetokenizeApi(defaultClient);
Object result = apiInstance.detokenize(Map.of(
"card_number", "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}"));
}
}
import basistheory
from basistheory.api import tokenize_api
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<API_KEY>")) as api_client:
tokenize_client = tokenize_api.TokenizeApi(api_client)
token = tokenize_client.tokenize(body={
"card_number": "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}"
})
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<API_KEY>"},
})
tokens, httpResponse, err := apiClient.TokenizeApi.Tokenize(contextWithAPIKey).Body(map[string]interface{}{
"card_number": "{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb | json: '$.number' }}"
}).Execute()
}
Response
{
"card_number": "4242"
}
Detokenize a list of tokens
Request
- cURL
- JavaScript
- C#
- Java
- Python
- Go
curl "https://api.basistheory.com/detokenize" \
-H "BT-API-KEY: <API_KEY>" \
-H "Content-Type: application/json" \
-X "POST" \
-d '{
"tokens": [
"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}",
"{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"
],
}'
import { BasisTheory } from "@basis-theory/basis-theory-js";
const bt = await new BasisTheory().init("<API_KEY>");
const token = await bt.detokenize({
tokens: [
"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}",
"{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"
],
});
using BasisTheory.net.Detokenize;
var client = new DetokenizeClient("<API_KEY>");
var token = await client.DetokenizeAsync(new {
tokens = new object [] {
"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}",
"{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"
},
});
import com.basistheory.*;
import com.basistheory.auth.*;
import java.util.Map;
public class Example {
public static void main(String[] args) throws Exception {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.basistheory.com");
ApiKeyAuth ApiKey = (ApiKeyAuth) defaultClient.getAuthentication("ApiKey");
ApiKey.setApiKey("<API_KEY>");
DetokenizeApi apiInstance = new DetokenizeApi(defaultClient);
Object result = apiInstance.detokenize(Map.of(
"tokens", new String[]{"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}", "{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"}));
}
}
import basistheory
from basistheory.api import tokenize_api
with basistheory.ApiClient(configuration=basistheory.Configuration(api_key="<API_KEY>")) as api_client:
tokenize_client = tokenize_api.TokenizeApi(api_client)
token = tokenize_client.tokenize(body={
"tokens": [
"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}",
"{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"
],
})
package main
import (
"context"
"github.com/Basis-Theory/basistheory-go/v3"
)
func main() {
configuration := basistheory.NewConfiguration()
apiClient := basistheory.NewAPIClient(configuration)
contextWithAPIKey := context.WithValue(context.Background(), basistheory.ContextAPIKeys, map[string]basistheory.APIKey{
"ApiKey": {Key: "<API_KEY>"},
})
tokens, httpResponse, err := apiClient.TokenizeApi.Tokenize(contextWithAPIKey).Body(map[string]interface{}{
"tokens": [2]string{"{{ 7993dbd8-19d5-44bf-b6dc-078e8b44c6cb }}", "{{ a1883f97-2e4c-439a-bf73-dffb681de929 }}"}
}).Execute()
}
Response
{
"tokens": [
{
"id": "7993dbd8-19d5-44bf-b6dc-078e8b44c6cb",
"type": "token",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"data": "secret data",
"containers": ["/general/high/"],
"metadata": {
"nonSensitiveField": "Non-Sensitive Value"
},
"created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"created_at": "2021-03-01T08:23:14+00:00"
},
{
"id": "a1883f97-2e4c-439a-bf73-dffb681de929",
"type": "token",
"tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
"data": "secret data 2",
"containers": ["/general/high/"],
"metadata": {
"nonSensitiveField": "Non-Sensitive Value 2"
},
"created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
"created_at": "2021-03-01T08:23:14+00:00"
}
]
}