For the complete documentation index, see llms.txt. This page is also available as Markdown.

SDK Javascript Integration

Use an SDK for the fastest production integration.

Node.js / TypeScript

Install:

npm install @veilio/sdk

Example:

import { VeilioClient } from "@veilio/sdk";

const veilio = new VeilioClient({
  apiKey: process.env.VEILIO_API_KEY!,
  baseUrl: process.env.VEILIO_BASE_URL || "https://app.veilio.xyz/api",
});

export async function createCustomer(email: string) {
  const { token } = await veilio.tokenize({
    data: email,
    type: "email",
  });

  // Store token in your DB, not the raw email.
  return { emailToken: token };
}

export async function sendWelcomeEmail(emailToken: string) {
  const { data: email } = await veilio.detokenize({
    token: emailToken,
    reason: "Send welcome email",
  });

  return email;
}

// Call when a user requests account deletion (GDPR right to erasure)
export async function deleteUserData(emailToken: string) {
  await veilio.shredToken({
    token: emailToken,
    reason: "GDPR - user deletion request",
  });
}

Client configuration

For on-premise deployments, point baseUrl to your instance:

Environment variables:

Variable
Description

VEILIO_API_KEY

API key from the Veilio dashboard

VEILIO_BASE_URL

API base URL (optional, defaults to SaaS)

API reference

tokenize(options)

Tokenize a single field.

tokenizeBulk(options)

Tokenize multiple fields in one request.

detokenize(options)

detokenizeBulk(options)

shredToken(options)

Immediately and irreversibly destroy a token (cryptographic erasure).

tokenizeFormat(options)

Tokenize structured data (JSON, CSV, or SQL).

detokenizeFormat(options)

Restore original values in structured data.

Bulk operations

For imports, migrations, or high-throughput jobs:

  • tokenizeBulk

  • detokenizeBulk

Use batching and retry logic for 429 responses. The SDK retries automatically (respecting Retry-After headers) up to maxRetries times.

Retention and shredding

Schedule automatic shredding at tokenization time, or shred immediately:

Error handling

Error codes

Code
HTTP
Description

AUTH_ERROR

401

Invalid or missing API key

VALIDATION_ERROR

400

Invalid request data

PLAN_LIMIT

403

Plan quota exceeded

RATE_LIMIT_ERROR

429

Rate limit exceeded

TOKEN_SHREDDED

410

Token has been cryptographically shredded

TIMEOUT_ERROR

408

Request timed out

INTERNAL_ERROR

5xx

Server error

TypeScript

Full type definitions are included:

Requirements

  • Node.js 18+ (native fetch) or install node-fetch for older versions

  • A valid Veilio API key

Links

Last updated

Was this helpful?