Skip to main content

Client Encryption Keys

Client Encryption Keys are asymmetric key pairs generated by Basis Theory for encrypting sensitive data on the client side. The public key is used to encrypt data in your frontend (e.g., with Elements), and the encrypted payload can be sent to your backend and then to Basis Theory for secure storage or processing.

Key Expiration: An encrypted payload is only valid for the lifetime of the encryption key. After a key expires, Basis Theory can no longer decrypt payloads that were encrypted with that key.

API Endpoints​

Create Key​

Create a new key. The public key is only returned when creating a key.

POST
https://api.basistheory.com/keys
Copy

Permissions​

keys:create

Request​

curl -X POST "https://api.basistheory.com/keys" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"expires_at": "2026-05-01T00:00:00Z"
}'

Request Body​

FieldTypeRequiredDescription
expires_atstringNoExpiration date (ISO 8601). Defaults to 6 months from creation. Maximum 1 year from creation.

Response​

Returns a Key if successful. Returns an error if there were validation errors.

{
"key_id": "b1e2c3d4-5678-1234-9abc-def012345678",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nWQ4geAENWHyR7+g94nN6lFZzY7YdGWxPtlX/16fJ4z0=\n-----END PUBLIC KEY-----",
"expires_at": "2026-05-01T00:00:00Z"
}

List Keys​

List all keys for the current tenant. The public key is not included in the response.

GET
https://api.basistheory.com/keys
Copy

Permissions​

keys:read

Request​

curl "https://api.basistheory.com/keys" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>"

Response​

Returns an array of Key.

[
{
"key_id": "b1e2c3d4-5678-1234-9abc-def012345678",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nWQ4geAENWHyR7+g94nN6lFZzY7YdGWxPtlX/16fJ4z0=\n-----END PUBLIC KEY-----",
"expires_at": "2026-05-01T00:00:00Z"
}
]

Get Key by ID​

Get a key by ID. The public key is not included in the response.

GET
https://api.basistheory.com/keys/{id}
Copy

Permissions​

keys:read

Request​

curl "https://api.basistheory.com/keys/{id}" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>"

Response​

Returns a Key. Returns an error if the key does not exist.

{
"key_id": "b1e2c3d4-5678-1234-9abc-def012345678",
"public_key_pem": "-----BEGIN PUBLIC KEY-----\nWQ4geAENWHyR7+g94nN6lFZzY7YdGWxPtlX/16fJ4z0=\n-----END PUBLIC KEY-----",
"expires_at": "2026-05-01T00:00:00Z"
}

Delete Key​

Delete a key by ID.

DELETE
https://api.basistheory.com/keys/{id}
Copy

Permissions​

keys:delete

Request​

curl -X DELETE "https://api.basistheory.com/keys/{id}" \
-H "BT-API-KEY: <MANAGEMENT_API_KEY>"

Response​

Returns no content (204). Returns an error if the key does not exist.


Key Object​

AttributeTypeDescription
key_idstringUnique identifier for the key
public_key_pemstringThe public key in PEM format
expires_atstringWhen this key expires (ISO 8601)