Skip to Content
API ReferenceTokenization API

Tokenization API

The Tokenization API provides endpoints for encrypting PII values into reversible tokens, managing tokenization policies, and controlling detokenization access through time-limited grants.

Base URL: https://api.slim.io/api/v1/tokens

Authentication

  • Tokenize endpoint: Requires X-API-Key header (API key authentication).
  • All other endpoints: Require Authorization: Bearer <jwt> header (JWT authentication).
  • Health check: No authentication required.

Endpoints

MethodPathAuthDescription
POST/tokenizeAPI KeyTokenize one or more PII values
POST/grantJWTRequest a detokenization grant
POST/detokenizeJWTDetokenize tokens using a grant
GET/vaultJWTList token vault entries (paginated)
DELETE/vault/:token_idJWTRevoke a token
GET/policiesJWTList tokenization policies
POST/policiesJWTCreate a policy
PUT/policies/:idJWTUpdate a policy
GET/usageJWTUsage summary for billing
GET/healthNoneReadiness check

POST /tokenize

Tokenize one or more PII values according to a policy.

Request

{ "items": [ {"value": "123-45-6789", "pii_type": "us_ssn", "mode": "format_preserving"}, {"value": "john@example.com", "pii_type": "email"} ], "policy_id": "pol_abc123", "idempotency_key": "idk_xyz789", "batch_mode": "BEST_EFFORT" }
FieldTypeRequiredDescription
itemsarrayYesPII values to tokenize (max 1,000 per request)
items[].valuestringYesThe raw PII value
items[].pii_typestringYesPII type (us_ssn, email, phone, ca_sin, date, passport_us, etc.)
items[].modestringNoOverride mode (deterministic, randomized, format_preserving). If omitted, uses policy default.
policy_idstringYesWhich policy to apply
idempotency_keystringNoClient-provided key for deduplication (max 256 chars)
batch_modestringNoBEST_EFFORT (default) or ALL_OR_NOTHING

Add ?dry_run=true to preview results without writing to the vault.

Response (200)

{ "results": [ {"token": "541-89-6743", "token_id": "abc...", "status": "TOKENIZED", "mode": "format_preserving"}, {"token": "slim_AQAB...", "token_id": "def...", "status": "TOKENIZED", "mode": "deterministic"} ], "success_count": 2, "failure_count": 0, "batch_policy_version": 3, "trace_id": "uuid" }

POST /grant

Request a time-limited detokenization grant.

Request

{ "token_ids": ["tok_abc123", "tok_def456"], "purpose": "customer_support", "reason": "Case #12345 — customer identity verification" }
FieldTypeRequiredDescription
token_idsarrayYesToken IDs to grant access to (max 100)
purposestringYesMust be in the policy’s allowed_purposes list
reasonstringDependsRequired if the policy has require_reason: true

Response (200)

{ "grant_jwt": "eyJ...", "expires_in_seconds": 300, "trace_id": "uuid" }

Grants are single-use and expire after 5 minutes. The grant JWT is bound to the requesting user, tenant, and specific token IDs.

POST /detokenize

Decrypt tokens using a valid grant.

Request

{ "tokens": ["tok_abc123", "tok_def456"], "grant_jwt": "eyJ..." }

Response (200)

{ "results": [ {"token_id": "tok_abc123", "status": "GRANTED", "value": "123-45-6789"}, {"token_id": "tok_def456", "status": "REVOKED", "value": null, "revoked_at": "2026-07-10T..."} ], "success_count": 1, "failure_count": 1, "trace_id": "uuid" }

Token status codes:

StatusDescription
GRANTEDAuthorized and decrypted
NOT_FOUNDToken ID does not exist
REVOKEDToken was explicitly revoked
EXPIREDToken TTL exceeded
DENIEDPolicy denied (role, purpose, rate limit)

GET /vault

List token vault entries with cursor-based pagination.

GET /api/v1/tokens/vault?limit=50&pii_type=us_ssn&status=active
ParamTypeDescription
limitintMax results per page (1-100, default 50)
cursorstringPagination cursor from previous response
pii_typestringFilter by PII type
statusstringFilter: active, revoked, expired

DELETE /vault/:token_id

Revoke (soft-delete) a token. The token cannot be detokenized after revocation.

{ "reason": "GDPR Article 17 request — ticket PRIV-1234" }

Error Codes

All error responses follow a consistent format:

{ "error": { "code": "RATE_LIMIT_EXCEEDED", "message": "Rate limit exceeded", "detail": "Per-user limit of 10/minute reached", "retryable": true, "retry_after_seconds": 5 } }
CodeHTTPRetryableDescription
INVALID_INPUT400NoRequest body is malformed
EMPTY_VALUE400NoValue cannot be empty
UNSUPPORTED_PII_TYPE400NoPII type is not supported
RATE_LIMIT_EXCEEDED429YesRate limit exceeded (check Retry-After header)
QUOTA_EXCEEDED429NoQuota exceeded
UNAUTHORIZED401NoAuthentication required
GRANT_EXPIRED403NoGrant has expired
GRANT_NONCE_REUSED403NoGrant has already been used
TOKEN_NOT_FOUND404NoToken not found
TOKEN_REVOKED403NoToken has been revoked
KILL_SWITCH_ACTIVE503NoService temporarily disabled
SERVICE_UNAVAILABLE503YesTransient service failure

Rate Limits

EndpointPer-User/minPer-Tenant/min
Tokenize1,00010,000
Detokenize10100
Grant10100
Vault list60600
Revoke10100

Rate limit headers are included on every response:

X-RateLimit-Limit: 1000 X-RateLimit-Remaining: 995 X-RateLimit-Reset: 1720000000 Retry-After: 5 (on 429 only)

SDK Version Header

SDKs must send X-Slim-SDK-Version with every request. The backend rejects requests from unsupported major versions with 426 Upgrade Required.

X-Slim-SDK-Version: 1.0.0
Last updated on