NAV
cURL Node.js .NET

Get Started

Reference

Other Docs

More

Introduction

The Basis Theory API is organized around REST. Our API is built with a predictable resource-oriented structure, uses JSON-encoded requests and responses, follows standard HTTP verbs/responses, and uses industry standard authentication.

You are able to create different Tenants within your Basis Theory account to enable you to segment your test environments from your core production data. Tenants serve as a logical grouping for each of your systems to interact with Basis Theory without affecting each other.

What is Basis Theory?

Our software becomes a core part of your infrastructure enabling you to quickly encrypt, tokenize, and store any payload securely. Your token infrastructure can be used to protect data at rest, as it passes between your own internal systems, or how it's permissioned and shared with third parties.

Getting started

Before You Begin

If you don't have an account

To begin taking advantage of the Basis Theory platform, you’ll need to create an account and Tenant through our Portal.

If you have an account

Check out our API Reference documentation below, or go to our Getting Started section if you’re unsure of where to go next.

Try with Postman

Create a fork of our Basis Theory API workspace, this has pre-configured sample API calls enabling you to quickly try out our API.

Run in Postman

Install SDK

Install SDK

npm install --save @basis-theory/basis-theory-js
dotnet add package BasisTheory.net 

Our SDKs enable you to quickly and easily integrate with the API. Select one of the language tabs to see instructions on how to install the SDK and view code examples in that language.

If you don't see your language listed, contact us about getting an official SDK added in your preferred language.

Authentication

Request

curl "https://api.basistheory.com" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

// at instance
const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

// per call
const bt = await new BasisTheory().init();

const applications = await bt.applications.list({}, {
  apiKey: 'key_N88mVGsp3sCXkykyN2EFED'
});
using BasisTheory.net.Tokens;

// At service
var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

// Per call
var client = new TokenClient();

client.GetAsync(requestOptions: new RequestOptions {
  ApiKey = "key_N88mVGsp3sCXkykyN2EFED"
});

Basis Theory uses API keys to allow access to the API.

Basis Theory requires the API key to be included in all API requests to the server in a header that looks like the following:

X-API-KEY: key_N88mVGsp3sCXkykyN2EFED

Request Correlation

Correlation ID Example:

curl "https://api.basistheory.com" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "bt-trace-id: aa5d3379-6385-4ef4-9fdb-ca1341572153"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const applications = await bt.applications.list({}, {
  correlationId: 'aa5d3379-6385-4ef4-9fdb-ca1341572153'
});
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

client.GetAsync(requestOptions: new RequestOptions {
  CorrelationId = "aa5d3379-6385-4ef4-9fdb-ca1341572153"
});

Basis Theory utilizes Correlation IDs to assist with request tracing, logging, and debugging.

All API endpoints accept a client-provided Correlation ID if sent with the bt-trace-id HTTP header within POST, PUT, PATCH, DELETE methods.

If a bt-trace-id Correlation ID is not provided by the client, a new Correlation ID will be generated by the Basis Theory API.

Pagination

Request

curl "https://api.basistheory.com/applications?page=2&size=10" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const applications = await bt.applications.list({
  page: 2,
  size: 10
});
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var applications = client.GetAsync(new ApplicationGetRequest {
  Page = 2,
  PageSize = 10
});

Response

{
  "pagination": {
    "total_items": 924,
    "page_number": 2,
    "page_size": 10,
    "total_pages": 93
  },
  "data": [
    {...},
    {...},
    {...}
  ]
}

All List endpoints support pagination to allow bulk fetching multiple items. Each List endpoint shares a common response structure. Examples of these requests can be seen in List Applications, List Tokens, and List Atomic Cards

Query Parameters

Parameter Required Type Default Description
page false integer 1 Page number of the results to return
size false integer 20 Number of results per page to return. Maximum size of 100 results.

Pagination Object

Attribute Type Description
pagination pagination metadata Pagination metadata for the response
data array Query results of the request. See list endpoint resource for response schema definition

Pagination Metadata Object

Attribute Type Description
total_items integer Total number of items in the Tenant
page_number integer Current page number. Should match page query parameter.
page_size integer The size of each page. Should match size query parameter.
total_pages integer The total number of pages.

Errors

{
  "errors": {
    "additionalProp1": [
      "string"
    ],
    "additionalProp2": [
      "string"
    ],
    "additionalProp3": [
      "string"
    ]
  },
  "type": "string",
  "title": "string",
  "status": 400,
  "detail": "string",
  "instance": "string"
}
import { BasisTheory } from '@basis-theory/basis-theory-js';

try {
  const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');
  const application = await bt.applications.create({ ... });
} catch (e) {
  console.log(e.status); // HTTP status code
  console.log(e.data); // HTTP Response body
  console.log(e.data.errors);
}

Response

Attribute Type Description
title string A short, human-readable summary of the problem
detail string A human-readable explanation specific to this occurrence of the problem
errors.{property} array An array of human readable error messages returned per request {property}
status integer HTTP status code of the response

Error Codes

Error Code Meaning
400 Invalid request body
401 A missing or invalid X-API-KEY was provided
403 The provided X-API-KEY does not have the required permissions
404 Request entity was not found
422 Request does not satisfy requirements for processing
429 Request has been rate limited
500 Something went wrong on Basis Theory's side

Reactor Errors

When calling POST */react endpoints, vendor-specific errors are translated to the same response schema as Basis Theory Errors. Additional response codes may be returned on calls to POST */react mapped from vendor-specific errors.

Reactor Error Codes

Error Code Meaning Common Scenarios
400 Bad Request
  • Missing or invalid request properties when processing the request with the vendor
  • Invalid Reactor Configuration
401 Authentication Error
  • Invalid or unknown credentials
  • Credentials are valid, but lack permission to complete the operation
402 Invalid Payment Method
  • Expired Card
  • A test card or bank account was used in a production environment, or vice-versa
  • The vendor denied the card or bank account
422 Unprocessable Entity
  • Reactor Formula code is not a valid function
429 Rate Limit Error
  • The vendor responded with a 429 HTTP response code
500 Reactor Runtime Error
  • An unhandled exception occurred
  • The vendor responded with a 5XX HTTP response code
  • Vendor connection failure

Limits

The Basis Theory API has rate limits applied to ensure the speed and consistency of our systems.

Error Codes

Error Code Meaning
429 Request has been rate limited

Applications

Your ability to authenticate to the API is granted by creating Applications, each Application type has different usages to create the most fine-grained control over your tokens and infrastructure possible. Below, we describe each Application Type and their usages.

Application Object

Attribute Type Description
id uuid Unique identifier of the Application which can be used to get an Application
tenant_id uuid The Tenant ID which owns the Application
name string The name of the Application
key string The API key which should be used for authenticating against Basis Theory API endpoints
type string Application type of the Application
permissions array List of permissions for the Application
created_at date Created date of the Application in ISO 8601 format
modified_at date Last modified date of the Application in ISO 8601 format

Application Types

Name Type Description
Server-to-Server server_to_server Used for tokenizing, retrieving, and decrypting data within backend services where the API key can be secured
Client-side Application public Used for tokenizing data directly within your mobile or browser application
Elements elements Used for tokenizing data with the Basis Theory Elements module
Management management Used for managing all aspects of your token infrastructure such as creating an Application

Create Application

Request

curl "https://api.basistheory.com/applications" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "name": "My Example App",
    "type": "server_to_server",
    "permissions": [
      "card:create",
      "card:read",
      "token:create",
      "token:read"
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const application = await bt.applications.create({
  name: 'My Example App',
  type: 'server_to_server',
  permissions: [
    'card:create',
    'card:read',
    'token:create',
    'token:read',
  ],
});
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var application = await client.CreateAsync(new Application {
  Name = "My Example App",
  Type = "server_to_server",
  Permissions = new List<string> {
    "card:create",
    "card:read",
    "token:create",
    "token:read"
  }
});

Response

{
  "id": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Example App",
  "key": "key_FZ8RmaxoGc73lbmF2cpmUJ",
  "type": "server_to_server",
  "permissions": [
    "card:create",
    "card:read",
    "token:create",
    "token:read"
  ],
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/applications

Create a new Application for the Tenant.

Permissions

application:create

Request Parameters

Attribute Required Type Default Description
name true string null The name of the Application. Has a maximum length of 200
type true string null Application of the application
permissions false array [] Permissions for the application

Response

Returns an application if the application was created. Returns an error if there were validation errors, or the application failed to create.

List Applications

Request

curl "https://api.basistheory.com/applications" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const applications = await bt.applications.list();
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var applications = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "name": "My Example App",
      "type": "server_to_server",
      "permissions": [
        "card:create",
        "card:read",
        "token:create",
        "token:read"
      ],
      "created_at": "2020-09-15T15:53:00+00:00",
      "modified_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/applications

Get a list of applications for the Tenant.

Permissions

application:read

Query Parameters

Parameter Required Type Default Description
id false array [] An optional list of application ID's to filter the list of applications by

Response

Returns a paginated object with the data property containing an array of applications. Providing any query parameters will filter the results. Returns an error if applications could not be retrieved.

Get an Application

Request

curl "https://api.basistheory.com/applications/fe1f9ba4-474e-44b9-b949-110cdba9d662" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const application = await bt.applications.retrieve('fe1f9ba4-474e-44b9-b949-110cdba9d662');
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var application = await client.GetByIdAsync("fe1f9ba4-474e-44b9-b949-110cdba9d662");

Response

{
  "id": "fe1f9ba4-474e-44b9-b949-110cdba9d662",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Management App",
  "type": "management",
  "permissions": [
    "application:read",
    "application:write"
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/applications/{id}

Get an application by ID in the Tenant.

Permissions

application:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the application

Response

Returns an application with the id provided. Returns an error if the application could not be retrieved.

Get an Application by Key

Request

curl "https://api.basistheory.com/applications/key" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const application = await bt.applications.retrieveByKey();
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var application = await client.GetByKeyAsync();

Response

{
  "id": "fe1f9ba4-474e-44b9-b949-110cdba9d662",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Management App",
  "type": "management",
  "permissions": [
    "application:read",
    "application:write"
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/applications/key

Get an application by key in the Tenant. Will use the X-API-KEY header to lookup the application.

Permissions

application:read

Response

Returns a application for the provided X-API-KEY. Returns an error if the application could not be retrieved.

Update Application

Request

curl "https://api.basistheory.com/applications/fb124bba-f90d-45f0-9a59-5edca27b3b4a" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json"
  -X "PUT" \
  -d '{
    "name": "My Example App",
    "permissions": [
      "application:read",
      "application:write"
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const application = await bt.applications.update('fb124bba-f90d-45f0-9a59-5edca27b3b4a', {
  name: 'My Example App',
  permissions: [
    'card:create',
    'card:read',
    'token:create',
    'token:read',
  ],
});
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var application = await client.UpdateAsync("fb124bba-f90d-45f0-9a59-5edca27b3b4a", 
  new Application {
    Name = "My Example App",
    Permissions = new List<string> {
      "card:create",
      "card:read",
      "token:create",
      "token:read"
    }
  }
);

Response

{
  "id": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Example App",
  "type": "management",
  "permissions": [
    "application:read",
    "application:write"
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

PUT https://api.basistheory.com/applications/{id}

Update an application by ID in the Tenant.

Permissions

application:update

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the application

Request Parameters

Attribute Required Type Default Description
name true string null The name of the application. Has a maximum length of 200
permissions false array [] Permissions for the application

Response

Returns an application if the application was updated. Returns an error if there were validation errors, or the application failed to update.

Regenerate API Key

Request

curl "https://api.basistheory.com/applications/fb124bba-f90d-45f0-9a59-5edca27b3b4a/regenerate" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "POST"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const application = await bt.applications.regenerateKey('fb124bba-f90d-45f0-9a59-5edca27b3b4a');
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

var application = await client.RegenerateKeyAsync("fb124bba-f90d-45f0-9a59-5edca27b3b4a");

Response

{
  "id": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Example App",
  "key": "key_FZ8RmaxoGc73lbmF2cpmUJ",
  "type": "server_to_server",
  "permissions": [
    "card:create",
    "card:read",
    "token:create",
    "token:read"
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

POST https://api.basistheory.com/applications/{id}/regenerate

Regenerate the API key for an application.

Permissions

application:update

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the application

Response

Returns an application with the new key property populated. Returns an error if there were validation errors, or the application key failed to regenerate.

Delete Application

Request

curl "https://api.basistheory.com/applications/fb124bba-f90d-45f0-9a59-5edca27b3b4a" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.applications.delete('fb124bba-f90d-45f0-9a59-5edca27b3b4a');
using BasisTheory.net.Applications;

var client = new ApplicationClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("fb124bba-f90d-45f0-9a59-5edca27b3b4a");

DELETE https://api.basistheory.com/applications/{id}

Delete an application by ID in the Tenant.

Permissions

application:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the application

Response

Returns an error if the application failed to delete.

Atomic Banks

Atomic Bank Object

Attribute Type Description
id uuid Unique identifier of the token which can be used to get an Atomic Bank
tenant_id uuid The Tenant ID which owns the bank
type string Bank token type
bank bank Bank data
metadata map A key-value map of non-sensitive data.
created_by uuid The Application ID which created the Atomic Bank
created_at date Created date of the Atomic Bank in ISO 8601 format

Bank Object

Attribute Type Description
routing_number string Nine-digit ABA routing number
account_number string Account number up to seventeen-digits

Create Atomic Bank

Request

curl "https://api.basistheory.com/atomic/banks" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
      "bank": {
        "routing_number": "021000021",
        "account_number": "1234567890"
      },
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      }
    }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicBank = await bt.atomicBanks.create({
  bank: {
    routingNumber: '021000021',
    accountNumber: '1234567890',
  },
  metadata: {
    nonSensitiveField: 'Non-Sensitive Value'
  },
});
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicBank = await client.CreateAsync(new AtomicBank {
  Bank = new Bank {
    RoutingNumber = "021000021",
    AccountNumber = "1234567890"
  },
  Metadata = new Dictionary<string, string> {
    { "nonSensitiveField", "Non-Sensitive Value" }
  }
});

Response

{
  "id": "1485efb9-6b1f-4248-a5d1-cf9b3907164c",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "bank",
  "bank": {
    "routing_number": "021000021",
    "account_number": "XXXXXX7890"
  },
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/atomic/banks

Create a new Atomic Bank for the Tenant.

Permissions

bank:create

Request Parameters

Attribute Required Type Default Description
bank true bank null Bank data
metadata false map null A key-value map of non-sensitive data.

Response

Returns an Atomic Bank with masked bank data if the Atomic Bank was created. Returns an error if there were validation errors, or the Atomic Bank failed to create.

List Atomic Banks

Request

curl "https://api.basistheory.com/atomic/banks" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicBanks = await bt.atomicBanks.list();
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicBanks = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "1485efb9-6b1f-4248-a5d1-cf9b3907164c",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "type": "bank",
      "bank": {
        "routing_number": "021000021",
        "account_number": "XXXXXX7890"
      },
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      },
      "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "created_at": "2020-09-15T15:53:00+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/atomic/banks

Get a list of Atomic Banks for the Tenant.

Permissions

bank:read

Response

Returns a paginated object with the data property containing an array of Atomic Banks. Providing any query parameters will filter the results. Returns an error if Atomic Banks could not be retrieved.

Get an Atomic Bank

Request

curl "https://api.basistheory.com/atomic/banks/1485efb9-6b1f-4248-a5d1-cf9b3907164c" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicBank = await client.GetByIdAsync("1485efb9-6b1f-4248-a5d1-cf9b3907164c");
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicBank = await bt.atomicBanks.retrieve('1485efb9-6b1f-4248-a5d1-cf9b3907164c');

Response

{
  "id": "1485efb9-6b1f-4248-a5d1-cf9b3907164c",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "bank",
  "bank": {
    "routing_number": "021000021",
    "account_number": "XXXXXX7890"
  },
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

GET https://api.basistheory.com/atomic/banks/{id}

Get an Atomic Bank by ID in the Tenant.

Permissions

bank:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Bank

Response

Returns an Atomic Bank with the id provided. Returns an error if the Atomic Bank could not be retrieved.

Delete Atomic Bank

Request

curl "https://api.basistheory.com/atomic/banks/1485efb9-6b1f-4248-a5d1-cf9b3907164c" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.atomicBanks.delete('1485efb9-6b1f-4248-a5d1-cf9b3907164c');
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("1485efb9-6b1f-4248-a5d1-cf9b3907164c");

DELETE https://api.basistheory.com/atomic/banks/{id}

Delete an Atomic Bank by ID in the Tenant.

Permissions

bank:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Bank

Response

Returns an error if the Atomic Bank failed to delete.

Decrypt Atomic Bank

Request

curl "https://api.basistheory.com/atomic/banks/1485efb9-6b1f-4248-a5d1-cf9b3907164c/decrypt" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicBank = await bt.atomicBanks.retrieveDecrypted('1485efb9-6b1f-4248-a5d1-cf9b3907164c');
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicBank = await client.GetByIdAsync("1485efb9-6b1f-4248-a5d1-cf9b3907164c", 
  new BankGetByIdRequest {
    Decrypt = true
  });

Response

{
  "id": "1485efb9-6b1f-4248-a5d1-cf9b3907164c",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "bank",
  "bank": {
    "routing_number": "021000021",
    "account_number": "1234567890"
  },
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

GET https://api.basistheory.com/atomic/banks/{id}/decrypt

Decrypt an Atomic Bank by ID in the Tenant.

Permissions

bank:decrypt

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Bank

Response

Returns an Atomic Bank with plaintext bank data with the id provided. Returns an error if the Atomic Bank could not be retrieved.

Create an Atomic Bank Reaction

Request

curl "https://api.basistheory.com/atomic/banks/1485efb9-6b1f-4248-a5d1-cf9b3907164c/react" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "POST" \
  -d '{
    "reactor_id": "5b493235-6917-4307-906a-2cd6f1a90b13",
    "request_parameters": {
      "REQUEST_PARAMETER_1": "Some request value"
    },
    "metadata": {
      "nonSensitiveField": "Non-Sensitive Value"
    }
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactionToken = await bt.atomicBanks.react('1485efb9-6b1f-4248-a5d1-cf9b3907164c', {
  reactorId: '5b493235-6917-4307-906a-2cd6f1a90b13',
  requestParameters: {
    REQUEST_PARAMETER_1: 'Some request value',
  },
  metadata: {
    nonSensitiveField: 'Non-Sensitive value',
  },
});
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var reactionToken = await client.ReactAsync("1485efb9-6b1f-4248-a5d1-cf9b3907164c", 
  new ReactRequest {
    ReactorId = "5b493235-6917-4307-906a-2cd6f1a90b13",
    RequestParameters = new Dictionary<string, object> {
      { "REQUEST_PARAMETER_1",  "Some request value" }
    },
    Metadata = new Dictionary<string, string> {
      { "nonSensitiveField",  "Non-Sensitive Value" }
    }
  });

POST https://api.basistheory.com/atomic/banks/{id}/react

Create an Atomic Bank Reaction by ID in the Tenant.

Permissions

reactor:read bank:create bank:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Bank

Request Parameters

Parameter Required Type Default Description
ractor_id true uuid null The ID of the reactor
request_parameters false map null A key-value map of request parameters names and values for the reactor
metadata false map null A key-value map of non-sensitive data. We overwrite the following keys: correlation_id, reactor_id, reactor_name, source_token_id, and source_token_type

Response

Returns a token with type of bank:reaction if the Atomic Bank was reacted. Returns an error if the Atomic Bank failed to react. Errors generated from Reactors will be translated to the common Basis Theory Error format. See Reactor Errors for more details.

Get an Atomic Bank Reaction Token

Request

curl "https://api.basistheory.com/atomic/banks/1485efb9-6b1f-4248-a5d1-cf9b3907164c/reactions/6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "GET"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactionToken = await bt.atomicBanks.retrieveReaction(
  '1485efb9-6b1f-4248-a5d1-cf9b3907164c', '6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0');
using BasisTheory.net.Atomic.Banks;

var client = new AtomicBankClient("key_N88mVGsp3sCXkykyN2EFED");

var reactionToken = await client.GetReactionByIdAsync(
  "1485efb9-6b1f-4248-a5d1-cf9b3907164c", "6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0");

GET https://api.basistheory.com/atomic/banks/{atomicBankId}/reactions/{reactionTokenId}

Get an Atomic Bank reaction token by ID in the Tenant.

Permissions

bank:read

URI Parameters

Parameter Required Type Default Description
atomicBankId true uuid null The ID of the Atomic Bank
reactionTokenId true uuid null The ID of the reaction token

Response

Returns a token with type of bank:reaction. Returns an error if the Atomic Bank failed to react.

Test Bank Account

To enable testing of Atomic Banks, we've implemented a list of acceptable test bank accounts to ensure you are able to test with non-sensitive data.

Test bank accounts

Routing Number Account Number Description
110000000 000123456789 Successfully added bank

Atomic Cards

Atomic Card Object

Attribute Type Description
id uuid Unique identifier of the token which can be used to get an Atomic Card
tenant_id uuid The Tenant ID which owns the card
type string Card token type
card card Card data
billing_details billing details Billing details
metadata map A key-value map of non-sensitive data.
created_by uuid The application ID which created the Atomic Card
created_at date Created date of the Atomic Card in ISO 8601 format

Card Object

Attribute Type Description
number string The card number without any separators
expiration_month integer Two-digit number representing the card's expiration month
expiration_year integer Four-digit number representing the card's expiration year

Billing Details Object

Attribute Type Description
name string The cardholder or customer's full name
email string The cardholder or customer's email address
phone string The cardholder or customer's phone number
address address The cardholder or customer's address

Address Object

Attribute Type Description
line1 string Address line 1 (Street address / PO Box / Company name)
line2 string Address line 2 (Apartment / Suite / Unit / Building)
city string City / District / Suburb / Town / Village
state string State / County / Province / Region
postal_code string Zip or postal code
country string Two-character ISO country code (e.g. US)

Create Atomic Card

Request

curl "https://api.basistheory.com/atomic/cards" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "card": {
      "number": "4242424242424242",
      "expiration_month": 12,
      "expiration_year": 2025,
      "cvc": "123"
    },
    "billing_details": {
      "name": "John Doe",
      "email": "[email protected]",
      "phone": "555-123-4567",
      "address": {
        "line1": "111 Test St.",
        "line2": "Apt 304",
        "city": "San Francisco",
        "state": "CA",
        "postal_code": "94141",
        "country": "US"
      }
    },
    "metadata": {
      "nonSensitiveField": "Non-Sensitive Value"
    }
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicCard = await bt.atomicCards.create({
  card: {
    number: '4242424242424242',
    expirationMonth: 12,
    expirationYear: 2025,
    cvc: '123',
  },
  billingDetails: {
    name: 'John Doe',
    email: '[email protected]',
    phone: '555-123-4567',
    address: {
      line1: '111 Test St.',
      line2: 'Apt 304',
      city: 'San Francisco',
      state: 'CA',
      postalCode: '94141',
      country: 'US'
    },
  },
  metadata: {
    nonSensitiveField: 'Non-Sensitive Value'
  },
});
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicCard = await client.CreateAsync(new AtomicCard {
  Card = new Card {
    CardNumber = "4242424242424242",
    ExpirationMonth = 12,
    ExpirationYear = 2025,
    CardVerificationCode = "123"
  },
  BillingDetails = new BillingDetails {
    Name = "John Doe",
    Email = "[email protected]",
    PhoneNumber = "555-123-4567",
    Address = new Address {
      LineOne = "111 Test St.",
      LineTwo = "Apt 304",
      City = "San Francisco",
      State = "CA",
      PostalCode = "94141",
      Country = "US"
    }
  },
  Metadata = new Dictionary<string, string> {
    { "nonSensitiveField", "Non-Sensitive Value" }
  }
});

Response

{
  "id": "c1e565009-1984-4638-8fca-dce8a82cc2af",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "card",
  "card": {
    "number": "XXXXXXXXXXXX4242",
    "expiration_month": 12,
    "expiration_year": 2025
  },
  "billing_details": {
    "name": "John Doe",
    "email": "[email protected]",
    "phone": "555-123-4567",
    "address": {
      "line1": "111 Test St.",
      "line2": "Apt 304",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94141",
      "country": "US"
    }
  },
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/atomic/cards

Create a new Atomic Card for the Tenant.

Permissions

card:create

Request Parameters

Attribute Required Type Default Description
card true card null Card data
billing_details false billing details null Billing details
metadata false map null A key-value map of non-sensitive data.

Response

Returns an Atomic Card with masked card data if the Atomic Card was created. Returns an error if there were validation errors, or the Atomic Card failed to create.

List Atomic Cards

Request

curl "https://api.basistheory.com/atomic/cards" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicCards = await bt.atomicCards.list();
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicCards = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "c1e565009-1984-4638-8fca-dce8a82cc2af",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "type": "card",
      "card": {
        "number": "XXXXXXXXXXXX4242",
        "expiration_month": 12,
        "expiration_year": 2025
      },
      "billing_details": {
        "name": "John Doe",
        "email": "[email protected]",
        "phone": "555-123-4567",
        "address": {
          "line1": "111 Test St.",
          "line2": "Apt 304",
          "city": "San Francisco",
          "state": "CA",
          "postal_code": "94141",
          "country": "US"
        }
      },
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      },
      "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "created_at": "2020-09-15T15:53:00+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/atomic/cards

Get a list of Atomic Cards for the Tenant.

Permissions

card:read

Response

Returns a paginated object with the data property containing an array of Atomic Cards. Providing any query parameters will filter the results. Returns an error if Atomic Cards could not be retrieved.

Get an Atomic Card

Request

curl "https://api.basistheory.com/atomic/cards/c1e565009-1984-4638-8fca-dce8a82cc2af" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const atomicCard = await bt.atomicCards.retrieve('c1e565009-1984-4638-8fca-dce8a82cc2af');
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

var atomicCard = await client.GetByIdAsync("c1e565009-1984-4638-8fca-dce8a82cc2af");

Response

{
  "id": "c1e565009-1984-4638-8fca-dce8a82cc2af",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "card",
  "card": {
    "number": "XXXXXXXXXXXX4242",
    "expiration_month": 12,
    "expiration_year": 2025
  },
  "billing_details": {
    "name": "John Doe",
    "email": "[email protected]",
    "phone": "555-123-4567",
    "address": {
      "line1": "111 Test St.",
      "line2": "Apt 304",
      "city": "San Francisco",
      "state": "CA",
      "postal_code": "94141",
      "country": "US"
    }
  },
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

GET https://api.basistheory.com/atomic/cards/{id}

Get an Atomic Card by ID in the Tenant.

Permissions

card:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Card

Response

Returns an Atomic Card with the id provided. Returns an error if the Atomic Card could not be retrieved.

Delete Atomic Card

Request

curl "https://api.basistheory.com/atomic/cards/c1e565009-1984-4638-8fca-dce8a82cc2af" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.atomicCards.delete('c1e565009-1984-4638-8fca-dce8a82cc2af');
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("c1e565009-1984-4638-8fca-dce8a82cc2af");

DELETE https://api.basistheory.com/atomic/cards/{id}

Delete an Atomic Card by ID in the Tenant.

Permissions

card:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Card

Response

Returns an error if the Atomic Card failed to delete.

Create an Atomic Card Reaction

Request

curl "https://api.basistheory.com/atomic/cards/c1e565009-1984-4638-8fca-dce8a82cc2af/react" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "POST" \
  -d '{
    "reactor_id": "5b493235-6917-4307-906a-2cd6f1a90b13",
    "request_parameters": {
      "REQUEST_PARAMETER_1": "Some request value"
    },
    "metadata": {
      "nonSensitiveField": "Non-Sensitive Value"
    }
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactionToken = await bt.atomicCards.react('c1e565009-1984-4638-8fca-dce8a82cc2af', {
  reactorId: '5b493235-6917-4307-906a-2cd6f1a90b13',
  requestParameters: {
    REQUEST_PARAMETER_1: 'Some request value',
  },
  metadata: {
    nonSensitiveField: 'Non-Sensitive Value',
  },
});
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

var reactionToken = await client.ReactAsync("c1e565009-1984-4638-8fca-dce8a82cc2af", 
  new ReactRequest {
    ReactorId = "5b493235-6917-4307-906a-2cd6f1a90b13",
    RequestParameters = new Dictionary<string, object> {
      { "REQUEST_PARAMETER_1",  "Some request value" }
    },
    Metadata = new Dictionary<string, string> {
      { "nonSensitiveField",  "Non-Sensitive Value" }
    }
  });

POST https://api.basistheory.com/atomic/cards/{id}/react

Create an Atomic Card Reaction by ID in the Tenant.

Permissions

reactor:read card:create card:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Atomic Card

Request Parameters

Parameter Required Type Default Description
reactor_id true uuid null The ID of the reactor
request_parameters false map null A key-value map of request parameters names and values for the reactor
metadata false map null A key-value map of non-sensitive data. We overwrite the following keys: correlation_id, reactor_id, reactor_name, source_token_id, and source_token_type

Response

Returns a token with type of card:reaction if the Atomic Card was reacted. Returns an error if the Atomic Card failed to react. Errors generated from Reactors will be translated to the common Basis Theory Error format. See Reactor Errors for more details.

Get an Atomic Card Reaction Token

Request

curl "https://api.basistheory.com/atomic/cards/c1e565009-1984-4638-8fca-dce8a82cc2af/reactions/6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "GET"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactionToken = await bt.atomicCards.retrieveReaction(
  'c1e565009-1984-4638-8fca-dce8a82cc2af', '6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0');
using BasisTheory.net.Atomic.Cards;

var client = new AtomicCardClient("key_N88mVGsp3sCXkykyN2EFED");

var reactionToken = await client.GetReactionByIdAsync(
  "c1e565009-1984-4638-8fca-dce8a82cc2af", "6c12a05d-99e3-4454-bdb0-2e6ff88ec5b0");

GET https://api.basistheory.com/atomic/cards/{atomicCardId}/reactions/{reactionTokenId}

Get an Atomic Card reaction token by ID in the Tenant.

Permissions

card:read

URI Parameters

Parameter Required Type Default Description
atomicCardId true uuid null The ID of the Atomic Card
reactionTokenId true uuid null The ID of the reaction token

Response

Returns a token with type of card:reaction. Returns an error if the Atomic Card failed to react.

Test Cards

To enable testing of Atomic Cards, we've implemented a list of acceptable test card numbers to ensure you are able to test with non-sensitive data.

Test card numbers

Card Description
4242424242424242 Test card
4000056655665556 Test card
5555555555554444 Test card
2223003122003222 Test card
5200828282828210 Test card
5105105105105100 Test card
378282246310005 Test card
371449635398431 Test card
6011111111111117 Test card
6011000990139424 Test card
3056930009020004 Test card
36227206271667 Test card
3566002020360505 Test card
620000000000000 Test card

Logs

Log Object

Attribute Type Description
tenant_id uuid The Tenant ID which owns the entity
application_id uuid The Application ID which performed the operation
entity_type string The entity type of the log
entity_id string The unique identifier of the entity_type
operation string The log operation (e.g. create, update, read, delete)
message string The log message
created_at date Created date of the token in ISO 8601 format

List Logs

Request

curl "https://api.basistheory.com/logs" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const logs = await bt.logs.list();
using BasisTheory.net.Logs;

var client = new LogClient("key_N88mVGsp3sCXkykyN2EFED");

var logs = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "application_id": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "entity_type": "token",
      "entity_id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
      "operation": "read",
      "message": "Token retrieved",
      "created_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/logs

Get a list of logs for the Tenant.

Permissions

log:read

Query Parameters

Parameter Required Type Default Description
entity_type false string null An optional entity type to filter the list of logs by. (e.g. card, bank, application, tenant)
entity_id false string null The unique identifier of the entity_type to filter the list of logs by.
start_date false date null An ISO 8601 formatted date to filter logs where created_at is greater than or equal to
end_date false date null An ISO 8601 formatted date to filter logs where created_at is less than

Response

Returns a paginated object with the data property containing an array of logs. Providing any query parameters will filter the results. Returns an error if logs could not be retrieved.

Permissions

Permissions offer fine-grained control over your Application's access to different aspects of your token infrastructure. We suggest limiting the scope of your Application to the least amount possible, and to not share them across your internal services.

Permissions are associated with every Application and can be configured when you create an Application or update an Application.

Every API endpoint will document the required permissions needed to perform the operation against the endpoint.

Permission Object

Attribute Type Description
type string Permission type referenced by Basis Theory API endpoints
description string Description of the permission
application_types array List of application types that can assign the permission

Permission Types

Permission Description Application Types
tenant:read Read Tenants management
tenant:update Update Tenants management
tenant:delete Delete Tenants management
application:read Read Applications management
application:create Create Applications management
application:update Update and regenerate API keys for Applications management
application:create Delete Applications management
reactor:read Read Reactor Formulas and Reactors server_to_server, management
reactor:create Create Reactors Formulas and Reactors management
reactor:update Update Reactors Formulas and Reactors management
reactor:delete Delete Reactors Formulas and Reactors management
log:read Read audit logs management
token:read Read tokens from the vault server_to_server
token:create Create tokens in the vault public, elements, server_to_server
token:delete Delete tokens from the vault server_to_server
token:decrypt Decrypt tokens server_to_server
card:read Read Atomic Card tokens server_to_server
card:create Create Atomic Card tokens public, elements, server_to_server
card:update Update Atomic Card tokens server_to_server
card:delete Delete Atomic Card tokens server_to_server
bank:read Read Atomic Bank tokens server_to_server
bank:create Create Atomic Bank tokens public, elements, server_to_server
bank:update Update Atomic Bank tokens server_to_server
bank:delete Delete Atomic Bank tokens server_to_server
bank:decrypt Decrypt Atomic Bank tokens server_to_server

List Permissions

Request

curl "https://api.basistheory.com/permissions" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const permissions = await bt.permissions.list();
using BasisTheory.net.Permissions;

var client = new PermissionClient("key_N88mVGsp3sCXkykyN2EFED");

var permissions = await client.GetAsync();

Response

[
  {
    "type": "card:read",
    "description": "Read Payment Card tokens",
    "application_types": [
      "server_to_server"
    ]
  }, 
  {...},
  {...}
]

GET https://api.basistheory.com/permissions

Response

Returns an array of permission objects. Returns an error if permissions could not be retrieved.

Reactor Formulas

Reactor formulas give you the ability to pre-configure custom integrations to securely process, enrich, and associate your tokens.

Reactor Formula Object

Attribute Type Description
id uuid Unique identifier of the Reactor Formula which can be used to get a Reactor Formula
name string The name of the Reactor Formula. Has a maximum length of 200
description string The description of the Reactor Formula
type string Type of the Reactor Formula
source_token_type string Source token type of the Reactor Formula
icon string Base64 data URL of the image
code string Reactor Formula code which will be executed when the Reactor Formula is processed
configuration array Array of configuration options for configuring a reactor
request_parameters array Array of request parameters which will be passed when executing the reactor
created_at date Created date of the Reactor Formula in ISO 8601 format
modified_at date Modified date of the Reactor Formula in ISO 8601 format

Reactor Formula Configuration Object

Attribute Required Type Default Description
name true string null Name of the configuration setting
description false string null Description of the configuration setting
type true string null Data type of the configuration setting. Valid values are string, boolean, and number

Reactor Formula Request Parameter Object

Attribute Required Type Default Description
name true string null Name of the request parameter
description false string null Description of the request parameter
type true string null Data type of the request parameter. Valid values are string, boolean, and number
optional false boolean false If the request parameter is optional when executing the reactor

Reactor Formula Code

All Reactor Formula code snippets must export a function which takes in a context object and returns a token object.

Reactor Formula Code Context Object

Attribute Type Description
sourceToken object The source token that matches the source_token_type of the reactor-formula
configuration array The configuration defined for the Reactor object

Reactor Formula Types

Type Description
official Official formulas that are built and supported by Basis Theory and its authorized partners
private Private formulas which are only available to your Tenant

Create Reactor Formula

Request

curl "https://api.basistheory.com/reactor-formulas" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "name": "My Private Reactor",
    "description": "Securely react a token for another token",
    "type": "private",
    "source_token_type": "card",
    "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
    "code": "
      module.exports = async function (context) {
        // Do something with `context.configuration.SERVICE_API_KEY`

        return {
          foo: 'bar',
        };
      };
    ",
    "configuration": [
      {
        "name": "SERVICE_API_KEY",
        "description": "Configuration description",
        "type": "string"
      }
    ],
    "request_parameters": [
      {
        "name": "REQUEST_PARAMETER_1",
        "description": "Request parameter description",
        "type": "string"
      },
      {
        "name": "REQUEST_PARAMETER_2",
        "description": "Request parameter description",
        "type": "boolean",
        "optional": true
      }
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactorFormula = await bt.reactorFormulas.create({
  name: 'My Private Reactor',
  description: 'Securely exchange token for another token',
  type: 'private',
  sourceTokenType: 'card',
  icon: 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
  code: '
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        foo: 'bar',
      };
    };
  ',
  configuration: [
    {
      name: 'SERVICE_API_KEY',
      description: 'Configuration description',
      type: 'string',
    },
  ],
  requestParameters: [
    {
      name: 'REQUEST_PARAMETER_1',
      description: 'Request parameter description',
      type: 'string',
    },
    {
      name: 'REQUEST_PARAMETER_2',
      description: 'Request parameter description',
      type: 'boolean',
      optional: true
    }
  ],
});
using BasisTheory.net.ReactorFormulas;

var client = new ReactorFormulaClient("key_N88mVGsp3sCXkykyN2EFED");

var reactorFormula = await client.CreateAsync(new ReactorFormula {
  Name = "My Private Reactor",
  Description = "Securely exchange token for another token",
  Type = "private",
  SourceTokenType = "card",
  Icon = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
  Code = @"
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        foo: 'bar',
      };
    };
  ",
  Configuration = new List<ReactorFormulaConfiguration> {
    new ReactorFormulaConfiguration {
      Name = "SERVICE_API_KEY",
      Description = "Configuration description",
      Type = "string"
    }
  },
  RequestParameters = new List<ReactorFormulaRequestParameter> {
    new ReactorFormulaRequestParameter {
      Name = "REQUEST_PARAMETER_1",
      Description = "Request parameter description",
      Type = "string"
    },
    new ReactorFormulaRequestParameter {
      Name = "REQUEST_PARAMETER_2",
      Description = "Request parameter description",
      Type = "boolean",
      IsOptional = true
    }
  }
});

Response

{
  "id": "17069df1-80f4-439e-86a7-4121863e4678",
  "name": "My Private Reactor",
  "description": "Securely exchange token for another token",
  "type": "private",
  "source_token_type": "card",
  "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
  "code": "
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        data: {
          foo: 'bar',
        },
        metadata: {
          nonSensitiveField: 'Non-Sensitive Value'
        }
      };
    };
  ",
  "configuration": [
    {
      "name": "SERVICE_API_KEY",
      "description": "Configuration description",
      "type": "string"
    }
  ],
  "request_parameters": [
    {
      "name": "REQUEST_PARAMETER_1",
      "description": "Request parameter description",
      "type": "string"
    },
    {
      "name": "REQUEST_PARAMETER_2",
      "description": "Request parameter description",
      "type": "boolean",
      "optional": true
    }
  ],
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/reactor-formulas

Create a new Reactor Formula for the Tenant.

Permissions

reactor:create

Request Parameters

Attribute Required Type Default Description
name true string null The name of the Reactor Formula. Has a maximum length of 200
description false string null The description of the Reactor Formula
type true string null Type of the Reactor Formula
source_token_type true string null Source token type of the Reactor Formula
icon false string null Base64 data URL of the image. Supported image types are: image/png, image/jpg, and image/jpeg
code true string null Reactor code which will be executed when the Reactor Formula is processed
configuration true array [] Array of configuration options for configuring a Reactor
request_parameters true array [] Array of request parameters which will be passed when executing the Reactor

Response

Returns an Reactor Formula if the Reactor Formula was created. Returns an error if there were validation errors, or the Reactor Formula failed to create.

List Reactor Formulas

Request

curl "https://api.basistheory.com/reactor-formulas" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactorFormulas = await bt.reactorFormulas.list();
using BasisTheory.net.ReactorFormulas;

var client = new ReactorFormulaClient("key_N88mVGsp3sCXkykyN2EFED");

var reactorFormulas = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "17069df1-80f4-439e-86a7-4121863e4678",
      "name": "My Private Reactor",
      "description": "Securely exchange token for another token",
      "type": "private",
      "source_token_type": "card",
      "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
      "code": "
        module.exports = async function (context) {
          // Do something with `context.configuration.SERVICE_API_KEY`

          return {
            data: {
              foo: 'bar',
            },
            metadata: {
              nonSensitiveField: 'Non-Sensitive Value'
            }
          };
        };
      ",
      "configuration": [
        {
          "name": "SERVICE_API_KEY",
          "description": "Configuration description",
          "type": "string"
        }
      ],
      "request_parameters": [
        {
          "name": "REQUEST_PARAMETER_1",
          "description": "Request parameter description",
          "type": "string"
        },
        {
          "name": "REQUEST_PARAMETER_2",
          "description": "Request parameter description",
          "type": "boolean",
          "optional": true
        }
      ],
      "created_at": "2020-09-15T15:53:00+00:00",
      "modified_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/reactor-formulas

Get a list of official Reactor Formula and private, Tenant-specific Reactor Formulas.

Permissions

reactor:read

Query Parameters

Parameter Required Type Default Description
name false string null Wildcard search of Reactor Formulas by name
source_token_type false string null Filter Reactor Formulas by source token type

Response

Returns a paginated object with the data property containing an array of Reactor Formulas. Providing any query parameters will filter the results. Returns an error if Reactor Formulas could not be retrieved.

Get a Reactor Formula

Request

curl "https://api.basistheory.com/reactor-formulas/17069df1-80f4-439e-86a7-4121863e4678" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactorFormula = await bt.reactorFormulas.retrieve('17069df1-80f4-439e-86a7-4121863e4678');
using BasisTheory.net.ReactorFormulas;

var client = new ReactorFormulaClient("key_N88mVGsp3sCXkykyN2EFED");

var reactorFormula = await client.GetByIdAsync("17069df1-80f4-439e-86a7-4121863e4678");

Response

{
  "id": "17069df1-80f4-439e-86a7-4121863e4678",
  "name": "My Private Reactor",
  "description": "Securely exchange token for another token",
  "type": "private",
  "source_token_type": "card",
  "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
  "code": "
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        data: {
          foo: 'bar',
        },
        metadata: {
          nonSensitiveField: 'Non-Sensitive Value'
        }
      };
    };
  ",
  "configuration": [
    {
      "name": "SERVICE_API_KEY",
      "description": "Configuration description",
      "type": "string"
    }
  ],
  "request_parameters": [
    {
      "name": "REQUEST_PARAMETER_1",
      "description": "Request parameter description",
      "type": "string"
    },
    {
      "name": "REQUEST_PARAMETER_2",
      "description": "Request parameter description",
      "type": "boolean",
      "optional": true
    }
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/reactor-formulas/{id}

Get a Reactor Formula by ID in the Tenant.

Permissions

reactor:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Reactor Formula

Response

Returns an Reactor Formula with the id provided. Returns an error if the Reactor Formula could not be retrieved.

Update Reactor Formula

Request

curl "https://api.basistheory.com/reator-formula/17069df1-80f4-439e-86a7-4121863e4678" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "PUT" \
  -d '{
    "name": "My Private Reactor",
    "description": "Securely exchange token for another token",
    "type": "private",
    "source_token_type": "card",
    "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
    "code": "
      module.exports = async function (context) {
        // Do something with `context.configuration.SERVICE_API_KEY`

        return {
          foo: 'bar',
        };
      };
    ",
    "configuration": [
      {
        "name": "SERVICE_API_KEY",
        "description": "Configuration description",
        "type": "string"
      }
    ],
    "request_parameters": [
      {
        "name": "REQUEST_PARAMETER_1",
        "description": "Request parameter description",
        "type": "string"
      },
      {
        "name": "REQUEST_PARAMETER_2",
        "description": "Request parameter description",
        "type": "boolean",
        "optional": true
      }
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactorFormula = await bt.reactorFormulas.update('17069df1-80f4-439e-86a7-4121863e4678', {
  name: 'My Private Reactor',
  description: 'Securely exchange token for another token',
  type: 'private',
  sourceTokenType: 'card',
  icon: 'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==',
  code: '
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        foo: 'bar',
      };
    };
  ',
  configuration: [
    {
      name: 'SERVICE_API_KEY',
      description: 'Configuration description',
      type: 'string',
    },
  ],
  requestParameters: [
    {
      name: 'REQUEST_PARAMETER_1',
      description: 'Request parameter description',
      type: 'string',
    },
    {
      name: 'REQUEST_PARAMETER_2',
      description: 'Request parameter description',
      type: 'boolean',
      optional: true
    }
  ],
});
using BasisTheory.net.ReactorFormulas;

var client = new ReactorFormulaClient("key_N88mVGsp3sCXkykyN2EFED");

var reactorFormula = await client.UpdateAsync("17069df1-80f4-439e-86a7-4121863e4678", 
  new ReactorFormula {
    Name = "My Private Reactor",
    Description = "Securely exchange token for another token",
    Type = "private",
    SourceTokenType = "card",
    Icon = "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
    Code = @"
      module.exports = async function (context) {
        // Do something with `context.configuration.SERVICE_API_KEY`

        return {
          foo: 'bar',
        };
      };
    ",
    Configuration = new List<ReactorFormulaConfiguration> {
      new ReactorFormulaConfiguration {
        Name = "SERVICE_API_KEY",
        Description = "Configuration description",
        Type = "string"
      }
    },
    RequestParameters = new List<ReactorFormulaRequestParameter> {
      new ReactorFormulaRequestParameter {
        Name = "REQUEST_PARAMETER_1",
        Description = "Request parameter description",
        Type = "string"
      },
      new ReactorFormulaRequestParameter {
        Name = "REQUEST_PARAMETER_2",
        Description = "Request parameter description",
        Type = "boolean",
        IsOptional = true
      }
    }
  }
);

Response

{
  "id": "17069df1-80f4-439e-86a7-4121863e4678",
  "name": "My Private Reactor",
  "description": "Securely exchange token for another token",
  "type": "private",
  "source_token_type": "card",
  "icon": "data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
  "code": "
    module.exports = async function (context) {
      // Do something with `context.configuration.SERVICE_API_KEY`

      return {
        data: {
          foo: 'bar',
        },
        metadata: {
          nonSensitiveField: 'Non-Sensitive Value'
        }
      };
    };
  ",
  "configuration": [
    {
      "name": "SERVICE_API_KEY",
      "description": "Configuration description",
      "type": "string"
    }
  ],
  "request_parameters": [
    {
      "name": "REQUEST_PARAMETER_1",
      "description": "Request parameter description",
      "type": "string"
    },
    {
      "name": "REQUEST_PARAMETER_2",
      "description": "Request parameter description",
      "type": "boolean",
      "optional": true
    }
  ],
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

PUT https://api.basistheory.com/reactor-formulas/{id}

Update a Reactor Formula by ID in the Tenant.

Permissions

reactor:update

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Reactor Formula

Request Parameters

Attribute Required Type Default Description
name true string null The name of the Reactor Formula. Has a maximum length of 200
description false string null The description of the Reactor Formula
type true string null Type of the Reactor Formula
source_token_type true string null Source token type of the Reactor Formula
icon false string null Base64 data URL of the image. Supported image types are: image/png, image/jpg, and image/jpeg
code true string null Reactor code which will be executed when the Reactor Formula is processed
configuration true array [] Array of configuration options for configuring a Reactor
request_parameters true array [] Array of request parameters which will be passed when executing the Reactor

Response

Returns an Reactor Formula if the Reactor Formula was updated. Returns an error if there were validation errors, or the Reactor Formula failed to update.

Delete Reactor Formula

Request

curl "https://api.basistheory.com/reactor-formulas/17069df1-80f4-439e-86a7-4121863e4678" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.reactorFormulas.delete('17069df1-80f4-439e-86a7-4121863e4678');
using BasisTheory.net.ReactorFormulas;

var client = new ReactorFormulaClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("17069df1-80f4-439e-86a7-4121863e4678");

DELETE https://api.basistheory.com/reactor-formulas/{id}

Delete a Reactor Formula by ID in the Tenant.

Permissions

reactor:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the Reactor Formula

Response

Returns an error if the Reactor Formula failed to delete.

Reactors

Reactor Object

Attribute Type Description
id uuid Unique identifier of the Reactor which can be used to get a Reactor
tenant_id uuid The Tenant ID which owns the reactor
name string The name of the reactor
formula Reactor Formula Reactor Formula this Reactor is configured for
configuration map A key-value map of all configuration name and values for an Reactor Formula configuration
created_at string Created date of the Reactor in ISO 8601 format
modified_at string Last modified date of the Reactor in ISO 8601 format

Create Reactor

Request

curl "https://api.basistheory.com/reactors" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "name": "My Reactor",
    "configuration": {
      "SERVICE_API_KEY": "key_abcd1234"
    },
    "formula": {
      "id": "17069df1-80f4-439e-86a7-4121863e4678"
    }
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactor = await bt.reactors.create({
  name: 'My Reactor',
  configuration: {
    SERVICE_API_KEY: 'key_abcd1234',
  },
  formula: {
    id: '17069df1-80f4-439e-86a7-4121863e4678',
  },
});
using BasisTheory.net.Reactors;

var client = new ReactorClient("key_N88mVGsp3sCXkykyN2EFED");

var reactor = await client.CreateAsync(new Reactor {
  Name = "My Reactor",
  Configuration = new Dictionary<string, string> {
    { "SERVICE_API_KEY", "key_abcd1234" }
  },
  Formula = new Formula {
    Id = new Guid("17069df1-80f4-439e-86a7-4121863e4678")
  }
});

Response

{
  "id": "5b493235-6917-4307-906a-2cd6f1a90b13",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Reactor",
  "formula": {...},
  "configuration": {
    "SERVICE_API_KEY": "key_abcd1234"
  },
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/reactors

Create a new Reactor from a Reactor Formula for the Tenant.

Permissions

reactor:create

Request Parameters

Attribute Required Type Default Description
name true string null The name of the reactor. Has a maximum length of 200
configuration true object null A key-value map of all configuration name and values for an Reactor Formula configuration
formula.id true uuid null Unique identifier of the Reactor Formula to configure a Reactor for

Response

Returns an reactor if the Reactor was created. Returns an error if there were validation errors, or the Reactor failed to create.

List Reactors

Request

curl "https://api.basistheory.com/reactors" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactors = await bt.reactors.list();
using BasisTheory.net.Reactors;

var client = new ReactorClient("key_N88mVGsp3sCXkykyN2EFED");

var reactors = await client.GetAsync();

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "5b493235-6917-4307-906a-2cd6f1a90b13",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "name": "My Reactor",
      "formula": {...},
      "configuration": {
        "SERVICE_API_KEY": "key_abcd1234"
      },
      "created_at": "2020-09-15T15:53:00+00:00",
      "modified_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/reactors

Get a list of reactors for the Tenant.

Permissions

reactor:read

Query Parameters

Parameter Required Type Default Description
id false array [] An optional list of Reactor ID's to filter the list of reactors by
name false string null Wildcard search of reactors by name
source_token_type false string null Filter reactors by Reactor Formulas source token type

Response

Returns a paginated object with the data property containing an array of reactors. Providing any query parameters will filter the results. Returns an error if reactors could not be retrieved.

Get a Reactor

Request

curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactor = await bt.reactors.retrieve('5b493235-6917-4307-906a-2cd6f1a90b13');
using BasisTheory.net.Reactors;

var client = new ReactorClient("key_N88mVGsp3sCXkykyN2EFED");

var reactor = await client.GetByIdAsync("5b493235-6917-4307-906a-2cd6f1a90b13");

Response

{
  "id": "5b493235-6917-4307-906a-2cd6f1a90b13",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Reactor",
  "formula": {...},
  "configuration": {
    "SERVICE_API_KEY": "key_abcd1234"
  },
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/reactors/{id}

Get a Reactor by ID in the Tenant.

Permissions

reactor:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the reactor

Response

Returns an reactor with the id provided. Returns an error if the Reactor could not be retrieved.

Update Reactor

Request

curl "https://api.basistheory.com/reactors/5b493235-6917-4307-906a-2cd6f1a90b13" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "PUT" \
  -d '{
    "name": "My Reactor",
    "configuration": {
      "SERVICE_API_KEY": "key_abcd1234"
    }
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const reactor = await bt.reactors.update('5b493235-6917-4307-906a-2cd6f1a90b13', {
  name: 'My Reactor',
  configuration: {
    SERVICE_API_KEY: 'key_abcd1234',
  },
});
using BasisTheory.net.Reactors;

var client = new ReactorClient("key_N88mVGsp3sCXkykyN2EFED");

var reactor = await client.UpdateAsync("5b493235-6917-4307-906a-2cd6f1a90b13", 
  new Reactor {
    Name = "My Reactor",
    Configuration = new Dictionary<string, string> {
      { "SERVICE_API_KEY", "key_abcd1234" }
    }
  }
);

Response

{
  "id": "5b493235-6917-4307-906a-2cd6f1a90b13",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "name": "My Reactor",
  "formula": {...},
  "configuration": {
    "SERVICE_API_KEY": "key_abcd1234"
  },
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

PUT https://api.basistheory.com/reactors/{id}

Update a Reactor by ID in the Tenant.

Permissions

reactor:update

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the reactor

Request Parameters

Attribute Required Type Default Description
name true string null The name of the reactor. Has a maximum length of 200
configuration true object null A key-value map of all configuration name and values for an Reactor Formula configuration

Response

Returns an reactor if the Reactor was updated. Returns an error if there were validation errors, or the Reactor failed to update.

Delete Reactor

Request

curl "https://api.basistheory.com/reactors/fb124bba-f90d-45f0-9a59-5edca27b3b4a" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.reactors.delete('fb124bba-f90d-45f0-9a59-5edca27b3b4a');
using BasisTheory.net.Reactors;

var client = new ReactorClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("fb124bba-f90d-45f0-9a59-5edca27b3b4a");

DELETE https://api.basistheory.com/reactors/{id}

Delete a Reactor by ID in the Tenant.

Permissions

reactor:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the reactor

Response

Returns an error if the Reactor failed to delete.

Tenants

Tenants provide a way to logically group your Applications and tokens. Common use cases for Tenants may be to create one per environment such as development, QA, and production or to isolate business domains from each other. Tenant data is isolated from other tenants unless explicitly shared.

Tenant Object

Attribute Type Description
id uuid Unique identifier of the Tenants
owner_id uuid The user ID which owns the Tenants
name string The name of the Tenants
created_at date Created date of the Tenant in ISO 8601 format
modified_at date Last modified date of the Tenant in ISO 8601 format

Get a Tenant

Request

curl "https://api.basistheory.com/tenants/self" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const tenant = await bt.tenants.retrieve();
using BasisTheory.net.Tenants;

var client = new TenantClient("key_N88mVGsp3sCXkykyN2EFED");

var tenant = await client.GetSelfAsync();

Response

{
  "id": "f88da999-b124-4a14-acde-cbc121444f14",
  "owner_id": "97cec6e8-a143-4fb4-9ab0-cf7e49242d21",
  "name": "My Tenant",
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/tenants/self

Retrieves the Tenant associated with the provided X-API-KEY.

Permissions

tenant:read

Response

Returns a Tenants for the provided X-API-KEY. Returns an error if the Tenant could not be retrieved.

Update Tenant

Request

curl "https://api.basistheory.com/tenants/self" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "PUT" \
  -d '{
    "name": "My Example Tenant"
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const tenant = await bt.tenants.update({
  name: 'My Example Tenant',
});
using BasisTheory.net.Tenants;

var client = new TenantClient("key_N88mVGsp3sCXkykyN2EFED");

var tenant = await client.UpdateAsync(new Tenant {
  Name = "My Example Tenant"
});

Response

{
  "id": "f88da999-b124-4a14-acde-cbc121444f14",
  "owner_id": "97cec6e8-a143-4fb4-9ab0-cf7e49242d21",
  "name": "My Example Tenant",
  "created_at": "2020-09-15T15:53:00+00:00",
  "modified_at": "2021-03-01T08:23:14+00:00"
}

PUT https://api.basistheory.com/tenants/self

Update the Tenant associated with the provided X-API-KEY.

Permissions

application:update

Request Parameters

Attribute Required Type Default Description
name true string null The name of the Tenant. Has a maximum length of 200

Response

Returns a tenant if the Tenant was updated. Returns an error if there were validation errors, or the Tenant failed to update.

Delete Tenant

Request

curl "https://api.basistheory.com/tenants/self" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.tenants.delete();
using BasisTheory.net.Tenants;

var client = new TenantClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync();

DELETE https://api.basistheory.com/tenants/self

Delete the Tenant associated with the provided X-API-KEY.

Permissions

tenant:write

Response

Returns an error if the Tenant failed to delete.

Tokens

Token Object

Attribute Type Description
id uuid Unique identifier of the token which can be used to get a token
tenant_id uuid The Tenant ID which owns the token
type string Token type
data any Token data
metadata map A key-value map of non-sensitive data.
encryption encryption object Encryption metadata for an encrypted token data value
children array Array of child tokens where this token is the parent in an association
created_by uuid The Application ID which created the token
created_at date Created date of the token in ISO 8601 format

Encryption Object

Attribute Type Description
cek encryption key Content encryption key
kek encryption key Key encryption key

Encryption Key Object

Attribute Type Description
key string Encryption key or key identifier
prov string Optional encryption provider (e.g. AWS, AZURE, GCP, etc.)
alg string Encryption algorithm (e.g. AES, RSA, etc)

Token Types

Name Type Description
Token token Generic token type. This is the default token type if none is provided when creating a new token
Card card Atomic card token type
Bank bank Atomic bank token type
Card Reaction card:reaction This token type is the resulting token type of a reacted Atomic card token
Bank Reaction bank:reaction This token type is the resulting token type of a reacted Atomic bank token

Create Token

Request

curl "https://api.basistheory.com/tokens" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "type": "token",
    "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
    "metadata": {
      "nonSensitiveField": "Non-Sensitive Value"
    },
    "encryption": {
      "cek": {
        "key": "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
        "alg": "AES"
      },
      "kek": {
        "key": "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
        "prov": "AWS",
        "alg": "RSA"
      }
    },
    "children": [
      {...},
      {...}
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const token = await bt.tokens.create({
  type: 'token',
  data: 'ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==',
  metadata: {
    nonSensitiveField: 'Non-Sensitive Value'
  },
  encryption: {
    cek: {
      key: 'JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==',
      alg: 'AES'
    },
    kek: {
      key: 'vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==',
      prov: 'AWS',
      alg: 'RSA'
    }
  },
  children: [
    { ... },
    { ... }
  ]
});
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var token = await client.CreateAsync(new Token {
  Type = "token",
  Data = "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
  Metadata = new Dictionary<string, string> {
    { "nonSensitiveField",  "Non-Sensitive Value" }
  },
  Encryption = new Encryption {
    ContentEncryptionKey = new EncryptionKey {
      Key = "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
      Algorithm: "AES"
    },
    KeyEncryptionKey = new EncryptionKey {
      Key = "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
      Provider: "AWS",
      Algorithm: "RSA"
    }
  },
  Children = new List<Token> {
    new Token { ... },
    new Token { ... }
  }
});

Response

{
  "id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "token",
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "children": [
    {...},
    {...}
  ],
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00"
}

POST https://api.basistheory.com/tokens

Create a new token for the Tenant.

Permissions

token:create

Request Parameters

Attribute Required Type Default Description
type false string token Token type of the token
data true any null Token data. Can be an object, array, or any primitive type such as an integer, boolean, or string
metadata false map null A key-value map of non-sensitive data.
encryption false encryption object null Encryption metadata for an encrypted token data value
children false array [] An array of tokens. Can be used to bulk create tokens with token associations

Response

Returns a token if the token was created. Returns an error if there were validation errors, or the token failed to create.

List Tokens

Request

curl "https://api.basistheory.com/tokens" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const tokens = await bt.tokens.list();
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var tokens = await client.GetAsync();

Response

{
  "pagination": {...},
  "data": [
    {
      "id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
      "type": "token",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      },
      "encryption": {
        "cek": {
          "key": "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
          "alg": "AES"
        },
        "kek": {
          "key": "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
          "prov": "AWS",
          "alg": "RSA" 
        }
      },
      "children": [
        {...},
        {...}
      ],
      "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "created_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/tokens

Get a list of tokens for the Tenant.

Permissions

token:read

Query Parameters

Parameter Required Type Default Description
id false array [] An optional list of token ID's to filter the list of tokens by
type false array [] An optional array of token types to filter the list of tokens by
children false boolean false Include child tokens where the token is a parent in token association
children_type false array [] An optional array of token types to filter child tokens where the token is a parent in the token association

Response

Returns a paginated object with the data property containing an array of tokens. Providing any query parameters will filter the results. Returns an error if tokens could not be retrieved.

List Decrypted Tokens

Request

curl "https://api.basistheory.com/tokens/decrypt" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const tokens = await bt.tokens.listDecrypted();
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var tokens = await client.GetAsync(new TokenGetRequest { Decrypt = true });

Response

{
  "pagination": {...},
  "data": [
    {
      "id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
      "type": "token",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      },
      "children": [
        {...},
        {...}
      ],
      "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "created_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/tokens/decrypt

Get a list of decrypted tokens for the Tenant.

Permissions

token:decrypt

Query Parameters

Parameter Required Type Default Description
id false array [] An optional list of token ID's to filter the list of tokens by
type false array [] An optional array of token types to filter the list of tokens by
children false boolean false Include child tokens where the token is a parent in token association
children_type false array [] An optional array of token types to filter child tokens where the token is a parent in the token association
decrypt_type false array [] An optional array of token types to filter token types that should be decrypted

Response

Returns a paginated object with the data property containing an array of decrypted tokens. Providing any query parameters will filter the results. Returns an error if tokens could not be retrieved. Token types other than token or non-BasisTheory encrypted tokens will not be decrypted.

Get a Token

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const token = await bt.tokens.retrieve('c06d0789-0a38-40be-b7cc-c28a718f76f1');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var token = await client.GetByIdAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1");

Response

{
  "id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
  "type": "token",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "encryption": {
    "cek": {
      "key": "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
      "alg": "AES"
    },
    "kek": {
      "key": "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
      "prov": "AWS",
      "alg": "RSA"
    }
  },
  "children": [
    {...},
    {...}
  ],
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/tokens/{id}

Get a token by ID in the Tenant.

Permissions

token:read

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the token

Query Parameters

Parameter Required Type Default Description
children false boolean false Include child tokens where the token is a parent in token association
children_type false array [] An optional array of token types to filter child tokens where the token is a parent in the token association

Response

Returns a token with the id provided. Returns an error if the token could not be retrieved.

Get a Decrypted Token

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1/decrypt" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const token = await bt.tokens.retrieveDecrypted('c06d0789-0a38-40be-b7cc-c28a718f76f1');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var token = await client.GetByIdAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1", new TokenGetByIdRequest { Decrypt = true });

Response

{
  "id": "c06d0789-0a38-40be-b7cc-c28a718f76f1",
  "type": "token",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "children": [
    {...},
    {...}
  ],
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2021-03-01T08:23:14+00:00"
}

GET https://api.basistheory.com/tokens/{id}/decrypt

Get a decrypted token by ID in the Tenant.

Permissions

token:decrypt

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the token

Query Parameters

Parameter Required Type Default Description
children false boolean false Include child tokens where the token is a parent in token association
children_type false array [] An optional array of token types to filter child tokens where the token is a parent in the token association
decrypt_type false array [] An optional array of token types to filter token types that should be decrypted

Response

Returns a decrypted token with the id provided. Returns an error if the token could not be retrieved. Token types other than token or non-BasisTheory encrypted tokens will not be decrypted.

Delete Token

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.tokens.delete('c06d0789-0a38-40be-b7cc-c28a718f76f1');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1");

DELETE https://api.basistheory.com/tokens/{id}

Delete a token by ID in the Tenant.

Permissions

token:delete

URI Parameters

Parameter Required Type Default Description
id true uuid null The ID of the token

Response

Returns an error if the token failed to delete.

Token Associations

Token associations allow you to associate any two tokens, of any type, together. This allows you to create parent-child relationships between tokens and traverse between tokens.

Create Token Association

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1/children/c1e565009-1984-4638-8fca-dce8a82cc2af" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.tokens.createAssociation('c06d0789-0a38-40be-b7cc-c28a718f76f1', 
  'c1e565009-1984-4638-8fca-dce8a82cc2af');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

await client.CreateAssociationAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1", 
  "c1e565009-1984-4638-8fca-dce8a82cc2af");

POST https://api.basistheory.com/tokens/{parent_id}/children/{child_id}

Create a new parent/child association between two tokens in the Tenants.

Permissions

token:create

URI Parameters

Parameter Required Type Default Description
parent_id true uuid null The ID of the parent token
child_id true uuid null The ID of the child token

Response

Returns an error if the token association failed to create.

Delete Token Association

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1/children/c1e565009-1984-4638-8fca-dce8a82cc2af" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "DELETE"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

await bt.tokens.deleteAssociation('c06d0789-0a38-40be-b7cc-c28a718f76f1', 
  'c1e565009-1984-4638-8fca-dce8a82cc2af');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

await client.DeleteAssociationAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1", 
  "c1e565009-1984-4638-8fca-dce8a82cc2af");

DELETE https://api.basistheory.com/tokens/{parent_id}/children/{child_id}

Delete a parent/child association between two tokens in the Tenant.

Permissions

token:delete

URI Parameters

Parameter Required Type Default Description
parent_id true uuid null The ID of the parent token
child_id true uuid null The ID of the child token

Response

Returns an error if the token association failed to delete.

Create Child Token for a Token

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1/children" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED" \
  -H "Content-Type: application/json" \
  -X "POST" \
  -d '{
    "type": "token",
    "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
    "metadata": {
      "nonSensitiveField": "Non-Sensitive Value"
    }
    "encryption": {
      "cek": {
        "key": "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
        "alg": "AES"
      },
      "kek": {
        "key": "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
        "alg": "RSA"
      }
    },
    "children": [
      {...},
      {...}
    ]
  }'
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const token = await bt.tokens.createChild('c06d0789-0a38-40be-b7cc-c28a718f76f1', {
  type: 'token',
  data: 'ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==',
  metadata: {
    nonSensitiveField: 'Non-Sensitive Value'
  },
  encryption: {
    cek: {
      key: 'JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==',
      alg: 'AES'
    },
    kek: {
      key: 'vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==',
      alg: 'RSA'
    }
  },
  children: [
    { ... },
    { ... }
  ]
});
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var token = await client.CreateChildAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1", 
  new Token {
    Type = "token",
    Data = "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
    Metadata = new Dictionary<string, string> {
      { "nonSensitiveField", "Non-Sensitive Value" }
    },
    Encryption = new Encryption {
      ContentEncryptionKey = new EncryptionKey {
        Key = "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
        Algorithm: "AES"
      },
      KeyEncryptionKey = new EncryptionKey {
        Key = "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
        Algorithm: "RSA"
      }
    },
    Children = new List<Token> {
      new Token { ... },
      new Token { ... }
    }
  }
);

Response

{
  "id": "c1e565009-1984-4638-8fca-dce8a82cc2af",
  "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
  "type": "token",
  "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
  "created_at": "2020-09-15T15:53:00+00:00",
  "metadata": {
    "nonSensitiveField": "Non-Sensitive Value"
  },
  "children": [
    {...},
    {...}
  ]
}

POST https://api.basistheory.com/tokens/{parent_id}/children

Create a new child token a token in the Tenant.

Permissions

token:create

URI Parameters

Parameter Required Type Default Description
parent_id true string null The ID of the parent token

Request Parameters

Attribute Required Type Default Description
type false string token Token type of the token
data true any null Token data
metadata false map null A key-value map of non-sensitive data.
encryption false encryption object null Encryption metadata for an encrypted token data value
children false array [] An array of tokens. Can be used to bulk create tokens with token associations

Response

Returns a token if the child token was created for the parent token. Returns an error if there were validation errors, or the token failed to create.

List Child Tokens for a Token

Request

curl "https://api.basistheory.com/tokens/c06d0789-0a38-40be-b7cc-c28a718f76f1/children" \
  -H "X-API-KEY: key_N88mVGsp3sCXkykyN2EFED"
import { BasisTheory } from '@basis-theory/basis-theory-js';

const bt = await new BasisTheory().init('key_N88mVGsp3sCXkykyN2EFED');

const tokens = await bt.tokens.listChildren('c06d0789-0a38-40be-b7cc-c28a718f76f1');
using BasisTheory.net.Tokens;

var client = new TokenClient("key_N88mVGsp3sCXkykyN2EFED");

var tokens = await client.GetChildrenAsync("c06d0789-0a38-40be-b7cc-c28a718f76f1");

Response

{
  "pagination": {...}
  "data": [
    {
      "id": "c1e565009-1984-4638-8fca-dce8a82cc2af",
      "type": "token",
      "tenant_id": "77cb0024-123e-41a8-8ff8-a3d5a0fa8a08",
      "data": "ebSG3IohNmg5gTOjN2HBwBbhjDZ6BY3fCWZJfXSucVMfQ+7YNMXQYrPuRSXgSkhuTMYS+BNfVUur4qZSvUbgCA==",
      "metadata": {
        "nonSensitiveField": "Non-Sensitive Value"
      }
      "encryption": {
        "cek": {
          "key": "JLrtGbYSN5/dbqdKtLVG8tHu3QefcZnKsFOPBBXlXcG4zL9US01mW2MqZs6Px4ckSQM8CrRakwLKilrQ0f37Iw==",
          "alg": "AES"
        },
        "kek": {
          "key": "vpXn45HnsoQPR1q8ptngmPvPaqIDJ4vO+FFyQclglePCt8d1SyTDJU0T+F54T7GnAz7vz5OKsjgsFNo9lVB3UA==",
          "alg": "RSA"
        }
      },
      "children": [
        {...},
        {...}
      ]
      "created_by": "fb124bba-f90d-45f0-9a59-5edca27b3b4a",
      "created_at": "2021-03-01T08:23:14+00:00"
    },
    {...},
    {...}
  ]
}

GET https://api.basistheory.com/tokens/{parent_id}/children

Get a list of child tokens for a token in the Tenant.

Permissions

token:read

URI Parameters

Parameter Required Type Default Description
parent_id true string null The ID of the parent token

Query Parameters

Parameter Required Type Default Description
id false array [] An optional list of token ID's to filter the list of child tokens by
type false array [] An optional array of token types to filter the list of child tokens by
children false boolean false Include child tokens where the child token is a parent in token association
children_type false array [] An optional array of token types to filter child tokens where the child token is a parent in the token association

Response

Returns a paginated object with the data property containing an array of child tokens for the parent token. Providing any query parameters will filter the child tokens. Returns an error if tokens could not be retrieved.