Veridi / docs

TypeScript SDK

@veridi/sdk wraps the REST API with typed methods, structured errors, and a webhook verifier.

Install

pnpm add @veridi/sdk

Initialize

import { VeridiClient } from '@veridi/sdk';

const veridi = new VeridiClient({
  baseUrl: 'https://api.veridi.id',
  apiKey: process.env.VERIDI_API_KEY!,
  timeoutMs: 30_000,        // default
  // fetch: customFetch,    // optional — useful for tests / Node < 18
});
The SDK uses the global fetch. Node 18+, modern browsers, Bun, and Cloudflare Workers work out of the box. For older Node, pass a polyfill via options.fetch.

KYC

// Initiate
const kyc = await veridi.kyc.initiate({
  subjectExternalRef: 'user_abc123',
});

// Presigned upload
const intent = await veridi.kyc.documents(kyc.id).createUploadIntent({
  type: 'KTP',
  mimeType: 'image/jpeg',
  sizeBytes: file.size,
});
await fetch(intent.uploadUrl, {
  method: 'PUT',
  headers: intent.requiredHeaders,
  body: file,
});
await veridi.kyc.documents(kyc.id).complete(intent.id);

// Liveness
const session = await veridi.kyc.liveness(kyc.id).initiate();
const result = await veridi.kyc.liveness(kyc.id).result({
  providerPayload: facetecResult,
});

// Final status (prefer webhooks)
const finished = await veridi.kyc.getStatus(kyc.id);

KYB

const kyb = await veridi.kyb.initiate({
  companyName: 'PT Contoh Sejahtera',
  nib: '1234567890123',
  subjectExternalRef: 'tenant_acme',
});

const status = await veridi.kyb.getStatus(kyb.id);

Error handling

import { VeridiError } from '@veridi/sdk';

try {
  await veridi.kyc.getStatus(id);
} catch (err) {
  if (err instanceof VeridiError) {
    switch (err.code) {
      case 'ERR_KYC_001':
        // Not found
        break;
      case 'ERR_AUTH_004':
        // Invalid or revoked API key
        break;
      default:
        console.error(err.code, err.message, err.requestId);
    }
  }
  throw err;
}

Network failures and timeouts also surface as VeridiError with codes ERR_API_NETWORK / ERR_API_TIMEOUT and status: 0.

Reference

The full method table and TypeScript types live in the SDK README on GitHub. The interactive API reference is the source of truth for fields and error codes.