---
title: "TypeScript Types"
url: "https://developer.incode.com/sdk-reference/web-sdk-2-typescript-types/"
section: "sdk-reference"
group: "Incode Web SDK 2 Reference / Reference"
version: "v1.1"
status: "live"
---
# TypeScript Types

:::note
This guide is specific to Web SDK 2.0. If you are still using 1.x, you can find documentation [here](/sdk-reference/web-sdk-reference).  Contact your Incode Representative for upgrade information and check if you are a candidate for this upgrade. <br /><br />Full rollout to all clients still TBD.
:::

The SDK is written in TypeScript and provides full type definitions.

## Importing Types

```typescript
import type { FlowConfig } from '@incodetech/web/flow';
import type { FinishStatus } from '@incodetech/core/flow';
import type {
  PhoneConfig,
  PhoneState,
  PhoneManager,
} from '@incodetech/core/phone';
import type {
  EmailConfig,
  EmailState,
  EmailManager,
} from '@incodetech/core/email';
import type {
  SelfieConfig,
  SelfieState,
  SelfieManager,
} from '@incodetech/core/selfie';
import type {
  IdCaptureConfig,
  IdCaptureState,
  IdCaptureManager,
} from '@incodetech/core/id';
```

Each module's `@incodetech/core/<name>` subpath ships the canonical types — `Config`, `State`, and `Manager` for headless usage. Per-module deep-dives ([Module: Selfie](/sdk-reference/web-sdk-2-module-selfie-1/), [Module: ID](/sdk-reference/web-sdk-2-module-id-capture/), [Module: Phone](/sdk-reference/web-sdk-2-module-phone/), [Module: Email](/sdk-reference/web-sdk-2-module-email/)) cover the property-level breakdowns; the rest of this page focuses on patterns and SDK-wide types.

## Web Component Element Types

The SDK augments `HTMLElementTagNameMap` for `<incode-flow>` and `<incode-workflow>` so that `document.createElement('incode-flow')` and `document.querySelector('incode-flow')` return a fully typed element with `.config`, `.onFinish`, and `.onError` properties:

```typescript
import '@incodetech/web/flow'; // registers the custom element + brings the type augmentation

const flow = document.createElement('incode-flow');
flow.config = {
  // ✅ typed as FlowConfig
  token: 'session-token',
  lang: 'en-US',
  enableHome: true,
};
flow.onFinish = (result) => {
  // ✅ result typed as FinishStatus | undefined
  console.log(result?.action);
};
flow.onError = (error, code) => {
  // ✅ error: string | undefined, code: number | undefined
  console.error(error, code);
};
```

Other module elements (`<incode-selfie>`, `<incode-phone>`, `<incode-email>`, `<incode-id>`, etc.) are registered as plain `HTMLElement` instances with attribute-based config. Set their `.config` and event handlers via property assignment exactly as above; you'll just need to cast or rely on the `HTMLElement` baseline. The full tag catalog lives in [Web Components](/sdk-reference/web-sdk-2-web-components/).

## Configuration Types

Per-module config types (`PhoneConfig`, `EmailConfig`, `SelfieConfig`, `IdCaptureConfig`, `FlowConfig`, etc.) are documented in their respective deep-dive pages with full property tables. Import them from `@incodetech/core/<module>` (or `@incodetech/web/flow` for `FlowConfig`). Your editor's go-to-definition (or hover docs) takes you straight to the canonical declarations.

The remaining types in this section are SDK-wide and don't belong on a single module page.

### WarmupConfig

```typescript
type WasmPipeline = 'selfie' | 'idCapture';

type WarmupConfig = {
  wasmPath: string; // Path to .wasm binary
  glueCodePath: string; // Path to JS glue code
  wasmSimdPath?: string; // SIMD-optimized variant (falls back to wasmPath)
  useSimd?: boolean; // Default: true
  pipelines?: WasmPipeline[]; // Default: ['selfie', 'idCapture']
  modelsBasePath?: string; // Default: derived from wasmPath
  pipelineModels?: Partial<Record<WasmPipeline, string[]>>;
};
```

### SessionInitOptions

```typescript
type SessionInitOptions = {
  /** Custom hosting app name for fingerprint */
  hostingApp?: string;
  /** Abort signal for cancellation */
  signal?: AbortSignal;
};
```

### SessionInitResult

```typescript
type SessionInitResult = {
  features: Features;
  disableIpify: boolean;
  fingerprintSuccess: boolean;
  fingerprintResult: DeviceFingerprintResult | undefined;
};

type DeviceFingerprintResult = {
  success: boolean;
  sessionStatus: string;
  showMandatoryConsent?: boolean;
  regulationType?: RegulationTypes;
};
```

`fingerprintResult` is `undefined` when `setup({ fingerprint: false })` skips fingerprint submission entirely — see the `fingerprint` option in [API Reference](/sdk-reference/web-sdk-2-reference/).

### Features

```typescript
type FeatureName = 
  | 'VIDEO_SELFIE_V2' 
  | 'USE_CLIENT_GLARE' 
  | 'USE_OPEN_VIDU' 
  | 'DISABLE_IPIFY';

type FeatureConfig = {
  enabled: boolean;
  feature: FeatureName;
  config?: number | string;
};

type Features = {
  features?: FeatureConfig[];
  sessionIdentifier: string;
};
```

### SpinnerConfig

```typescript
type SpinnerSize = 'small' | 'medium' | 'large';

type SpinnerRenderMode = 'spinnerAndText' | 'spinnerOnly' | 'textOnly';

/** Loader presentation. Settable globally via `setup({ uiConfig: { spinner } })`
 *  or per element via `config.spinner`. Copy comes from i18n, not from here. */
type SpinnerPresentation = {
  /** Which parts of the loader render */
  renderMode?: SpinnerRenderMode;
  /** Size of the spinner icon (default: 'medium') */
  size?: SpinnerSize;
};

type SpinnerConfig = SpinnerPresentation & {
  /** @deprecated Set copy via i18n translations. Removed in 2.3.0. */
  title?: string;
  /** @deprecated Set copy via i18n translations. Removed in 2.3.0. */
  subtitle?: string;
};
```

### Asset override types

```typescript
type AssetKey =
  | 'faceMatch.success'
  | 'faceMatch.fail'
  | 'documentCapture.tutorial'
  | 'id.uploadScreen'
  | 'id.ageVerification.dob'
  | 'id.ageVerification.scan'
  | 'id.ageVerification.privacy'
  | 'videoSelfie.success'
  | 'videoSelfie.fail'
  | 'videoSelfie.tutorial.permission'
  | 'videoSelfie.tutorial.selfie'
  | 'videoSelfie.tutorial.frontId'
  | 'videoSelfie.tutorial.backId'
  | 'videoSelfie.tutorial.poa'
  | 'videoSelfie.tutorial.questions'
  | 'videoSelfie.tutorial.speech'
  | 'loader.spinner';

type AnimationKey =
  | 'id.tutorial.front'
  | 'id.tutorial.back'
  | 'id.tutorial.passport'
  | 'id.flip'
  | 'id.processing'
  | 'selfie.tutorial'
  | 'loader.spinner';

type AssetOverride =
  | string // URL, or raw `<svg …>` markup (leading '<')
  | { url: string }
  | { raw: string } // sanitized before injection
  | { svg: SvgComponent }; // precompiled Preact component

type AnimationOverride =
  | LottieAnimationData
  | { url: string }
  | { animationData: LottieAnimationData };

type AssetOverrides = Partial<Record<AssetKey, AssetOverride>>;
type AnimationOverrides = Partial<Record<AnimationKey, AnimationOverride>>;
```

Import from `@incodetech/web` (or `@incodetech/web/extensibility`). `AssetOverrides` / `AnimationOverrides` are the maps accepted by `UiConfig.assets` / `UiConfig.animations` (global) and by `FlowConfig` / any module `config` prop (per-instance). See [Asset Overrides](/sdk-reference/web-sdk-2-asset-overrides/) for the full allowlist and precedence rules.

## State Types

Every module's state is a discriminated union keyed on `status`. `PhoneState` is shown here as the canonical example; the same pattern applies to `EmailState`, `SelfieState`, `IdCaptureState`, and `FlowState`. Per-module pages list each state with its full property shape.

```typescript
type PhoneState =
  | { status: 'idle' }
  | { status: 'loadingPrefill' }
  | {
      status: 'inputting';
      countryCode: string;
      phonePrefix: string;
      phoneError?: string;
    }
  | { status: 'submitting' }
  | { status: 'sendingInitialOtp' }
  | { status: 'resendingOtp' }
  | {
      status: 'awaitingOtp';
      resendTimer: number;
      canResend: boolean;
      attemptsRemaining: number;
    }
  | { status: 'verifyingOtp'; resendTimer: number; canResend: boolean }
  | {
      status: 'otpError';
      otpError: string;
      attemptsRemaining: number;
      resendTimer: number;
      canResend: boolean;
    }
  | { status: 'finished' } // terminal success state
  | { status: 'error'; error: string };
```

### Using Discriminated Unions

```typescript
function handleState(state: PhoneState) {
  switch (state.status) {
    case 'inputting':
      // TypeScript knows state.countryCode exists here
      console.log(state.countryCode);
      break;
    case 'awaitingOtp':
      // TypeScript knows state.resendTimer exists here
      console.log(state.resendTimer);
      break;
  }
}
```

## Completion Result

The result delivered to the `IncodeFlow` `onFinish` callback (and to your code via the `getFinishStatus` helper) is `FinishStatus`, exported from `@incodetech/core/flow`:

```typescript
import type { FinishStatus } from '@incodetech/core/flow';

// type FinishStatus = {
//   redirectionUrl: string;
//   action: 'approved' | 'rejected' | 'none';
//   scoreStatus: 'OK' | 'WARN' | 'MANUAL_OK' | 'FAIL' | 'UNKNOWN' | 'MANUAL_FAIL';
// };
```

## Manager Types

Every headless manager exposes the same shape:

```typescript
type Manager<TState> = {
  getState(): TState;
  subscribe(listener: (state: TState) => void): () => void;
  // module-specific methods (e.g. setPhoneNumber, submitOtp, capture, retryCapture, ...)
  load(): void;
  reset(): void;
  stop(): void;
};
```

The module-specific method set is the actionable API. See each module's per-page deep-dive for the full table:

- [Module: Selfie § API Methods](/sdk-reference/web-sdk-2-module-selfie-1/#api-methods)
- [Module: ID § API Methods](/sdk-reference/web-sdk-2-module-id-capture/#api-methods)
- [Module: Phone § API Methods](/sdk-reference/web-sdk-2-module-phone/#api-methods)
- [Module: Email § API Methods](/sdk-reference/web-sdk-2-module-email/#api-methods)

Or import the manager type directly: `import type { PhoneManager } from '@incodetech/core/phone'` (and equivalents for `EmailManager`, `SelfieManager`, `IdCaptureManager`).

## See Also

- [API Reference](/sdk-reference/web-sdk-2-reference/): Full API documentation
- [Headless Mode](/sdk-reference/web-sdk-2-headless-mode/): Using managers
- [Asset Overrides](/sdk-reference/web-sdk-2-asset-overrides/): Replacing branded illustrations and animations