Skip to main content
The server-to-server primitives. Access them via client.document, client.face, and client.identity. Each image parameter accepts a FileInput; the SDK handles presigned upload internally. For the full request/response schemas, follow the REST links per method.
// Accepted input for every image parameter on this page
type FileInput = Uint8Array | ReadableStream<Uint8Array> | string;
//  Uint8Array        — raw bytes (Node Buffer extends Uint8Array)
//  ReadableStream    — streaming input (materialized before upload)
//  string            — data URL, base64, or file path (file path not supported on edge runtimes)

type DocumentType = 'passport' | 'drivers_license' | 'national_id' | 'auto';

Document

scan(input)

scan(input: DocumentScanInput): Promise<DocumentScanResult>
Scan a document image and extract structured OCR data.
ParameterTypeRequiredDefaultDescription
input.imageFileInputYesDocument image
input.documentTypeDocumentTypeNo'auto'Document type hint
Returns DocumentScanResult:
interface DocumentScanResult {
  documentType: string;
  fullName: string;
  firstName: string;
  lastName: string;
  dateOfBirth: string;
  gender: string;
  nationality: string;
  documentNumber: string;
  expirationDate: string;
  issuingCountry: string;
  address?: string;
  mrzData?: string;
  faceImage?: string; // extracted face, base64
  rawFields: Record<string, string>;
  confidence: number; // 0–1
}
Throws ValidationError, AuthenticationError, RateLimitError, NetworkError, TimeoutError, DeepIDVError.
import { readFileSync } from 'node:fs';

const result = await client.document.scan({
  image: readFileSync('passport.jpg'),
  documentType: 'passport',
});
console.log(`${result.fullName} — expires ${result.expirationDate}`);
See also: REST Document Scan.

Face

detect(input)

detect(input: FaceDetectInput): Promise<FaceDetectResult>
Detect a face in an image.
ParameterTypeRequiredDescription
input.imageFileInputYesImage to analyze
Returns FaceDetectResult:
interface FaceDetectResult {
  faceDetected: boolean;
  confidence: number; // 0–1
  boundingBox?: { top: number; left: number; width: number; height: number };
  landmarks?: Array<{ type: string; x: number; y: number }>;
}
const result = await client.face.detect({ image: readFileSync('photo.jpg') });
if (result.faceDetected) {
  console.log(`Confidence: ${result.confidence}`);
}
See also: REST Face Detect.

compare(input)

compare(input: FaceCompareInput): Promise<FaceCompareResult>
Compare two face images. Both upload in parallel via batch presign.
ParameterTypeRequiredDescription
input.sourceFileInputYesReference image
input.targetFileInputYesImage to compare against
Returns FaceCompareResult:
interface FaceCompareResult {
  isMatch: boolean; // confidence >= threshold
  confidence: number; // 0–100
  threshold: number; // 0–100
  sourceFaceDetected: boolean;
  targetFaceDetected: boolean;
}
const result = await client.face.compare({
  source: readFileSync('id-photo.jpg'),
  target: readFileSync('selfie.jpg'),
});
console.log(result.isMatch ? 'Same person' : 'Different people');
See also: REST Face Compare.

estimateAge(input)

estimateAge(input: FaceEstimateAgeInput): Promise<FaceEstimateAgeResult>
Estimate age and gender from a face image.
ParameterTypeRequiredDescription
input.imageFileInputYesImage to analyze
Returns FaceEstimateAgeResult:
interface FaceEstimateAgeResult {
  estimatedAge: number;
  ageRange: { low: number; high: number };
  gender: 'male' | 'female';
  genderConfidence: number; // 0–1
  faceDetected: boolean;
}
const result = await client.face.estimateAge({ image: readFileSync('photo.jpg') });
console.log(`Age: ${result.estimatedAge} (${result.ageRange.low}${result.ageRange.high})`);
See also: REST Face Estimate Age.

Identity

verify(input)

verify(input: IdentityVerifyInput): Promise<IdentityVerificationResult>
Full identity verification: document scan + face detection + face comparison in one orchestrated call. Both images upload in parallel.
ParameterTypeRequiredDefaultDescription
input.documentImageFileInputYesDocument image
input.faceImageFileInputYesSelfie / face image
input.documentTypeDocumentTypeNoauto-detectDocument type hint
Returns IdentityVerificationResult. All confidence and threshold values are reported on a 0–100 scale:
interface IdentityVerificationResult {
  verified: boolean;
  overallConfidence: number; // 0–100
  document: IdentityDocumentResult;
  faceDetection: { faceDetected: boolean; confidence: number };
  faceMatch: { isMatch: boolean; confidence: number; threshold: number };
}

interface IdentityDocumentResult {
  documentType: string;
  fullName: string;
  firstName: string;
  lastName: string;
  dateOfBirth: string;
  gender: string;
  nationality: string;
  documentNumber: string;
  expirationDate: string;
  issuingCountry: string;
  address?: string;
  faceImage?: string;
  confidence: number; // 0–100
}
All three sub-results (document, faceDetection, faceMatch) are always present on a 2xx response, even when verified is false. Throws ValidationError, AuthenticationError, RateLimitError, NetworkError, TimeoutError, DeepIDVError.
const result = await client.identity.verify({
  documentImage: readFileSync('passport.jpg'),
  faceImage: readFileSync('selfie.jpg'),
  documentType: 'passport',
});

if (result.verified) {
  console.log(`Verified: ${result.document.fullName}`);
  console.log(`Confidence: ${result.overallConfidence}`);
} else {
  console.log('Verification failed');
  console.log(`Face match: ${result.faceMatch.isMatch}`);
  console.log(`Document confidence: ${result.document.confidence}`);
}
See also: REST Identity Verify.