Quick Summary
The Trulioo Web SDK initializes a shortcode-backed session and exposes base verification capabilities for browser applications.
Customer applications can expect the SDK to:
- initialize an authorized session from a shortcode
- support configured Device Intelligence capabilities
- return capability results, errors, and diagnostic information
- leave journey decisions and customer policy to the host application
A standard web integration looks like this:
- install
@trulioo/trulioo - initialize with a shortcode
- collect Device Intelligence when required by the journey
- use the result to continue, retry, or route the journey for review
Installation
npm install @trulioo/truliooExample import:
import { Trulioo } from "@trulioo/trulioo";Use the SDK from a CDN:
import { Trulioo } from "https://cdn.trulioo.com/web/sdk/trulioo/latest/dist/esm/trulioo.js";Use a pinned version instead of the latest package:
import { Trulioo } from "https://cdn.trulioo.com/web/sdk/trulioo/VERSION_NUMBER/dist/esm/trulioo.js";Replace VERSION_NUMBER with the SDK version you want to lock to.
Before You Start
Before using the SDK, make sure the host application:
- has a valid shortcode generated through the Trulioo customer handoff flow using the Customer API 3.0 handoff operation
- uses a shortcode configured for Device Intelligence when required by the journey
- initializes a new SDK session for each verification journey
Initialization
Initialize once with the shortcode before starting a verification capability:
const initialized = await Trulioo.initialize(shortcode);initialized is a TruliooInitializationResult for the current verification journey. Retain it only while that journey is active.
What Initialization Does
Initialization:
- resolves the service host from the shortcode
- establishes an authorized SDK session
- retrieves the session configuration
- when Device Intelligence is enabled, loads the managed device runtime
- returns the initialization result for the current verification journey
Initialization Result
initialize(...) returns the current TruliooInitializationResult.
| Field | Type | Meaning |
|---|---|---|
transactionId | string | Identifier for the verification journey. |
debugTrace | TruliooDebugTraceEntry[] | undefined | SDK diagnostic entries for support and troubleshooting. |
The SDK retains the session configuration, resolved service host, and authorization token internally for the active session. Call reset() to clear that session before starting another journey.
Verification Capabilities
Beta - changes are possible.
After initialization, start the capability required by the current verification journey. Availability is determined by the shortcode configuration.
Device Intelligence
Use Device Intelligence when the verification journey needs a device-risk result before deciding the next step.
Choose An Integration Mode
| API | Use when | Returns |
|---|---|---|
collectDeviceIntelligence(...) | The application needs to wait for the device-event lifecycle status. | A lifecycle-only deviceEvent and debugTrace. |
sendDeviceInformation(...) | DI should be submitted in the background without waiting for lifecycle processing. | An accepted or failed submission receipt. |
Recommended: collectDeviceIntelligence(...)
collectDeviceIntelligence(...)For most integrations, use collectDeviceIntelligence(...). It performs collection, submission, and polling in one Promise-based call. It returns a terminal event when processing completes or fails; if the configured polling limit is reached first, it returns the latest non-terminal lifecycle event and records the timeout in debugTrace.
If polling exhausts, the result contains the last non-terminal lifecycle state and debugTrace contains a device_event_terminal timeout entry. Wait and retrieve the detailed result only after the status is COMPLETED. If the event fails, use deviceEvent.failureReason for the failure detail.
- initialize once
- call
collectDeviceIntelligence(...) - use a completed
deviceEventto continue the journey
Explicit collection example:
import { DeviceEventStatus, Trulioo } from "@trulioo/trulioo";
const initialized = await Trulioo.initialize(shortcode);
const result = await Trulioo.collectDeviceIntelligence();
if (result.deviceEvent?.status === DeviceEventStatus.Completed) {
const { eventId, transactionId } = result.deviceEvent;
}collectDeviceIntelligence(...) returns an enriched TruliooInitializationResult for the same session.
| Field | Type | Meaning |
|---|---|---|
deviceEvent | DeviceEventResult | undefined | Device-event lifecycle result, when Device Intelligence was collected. |
deviceEvent.eventId | string | Identifier for the submitted device event. |
deviceEvent.transactionId | string | Identifier used to retrieve the detailed device result after processing completes. |
deviceEvent.status | DeviceEventStatus | Current device-event state: queued, running, completed, or failed. |
deviceEvent.failureReason | string | undefined | Failure explanation when the device event fails. |
debugTrace | TruliooDebugTraceEntry[] | undefined | SDK diagnostic entries for troubleshooting. |
When deviceEvent.status is COMPLETED, use deviceEvent.transactionId to retrieve the detailed result. To retrieve the detailed result, see Retrieve the Detailed Result.
Background Submission: sendDeviceInformation(...)
sendDeviceInformation(...)Use sendDeviceInformation(...) when the application should submit DI without waiting for server evaluation or a final risk result.
import { Trulioo, TruliooSendDeviceInformationStatus } from "@trulioo/trulioo";
const initialized = await Trulioo.initialize(shortcode);
const submission = await Trulioo.sendDeviceInformation();
if (submission.status === TruliooSendDeviceInformationStatus.Accepted) {
console.log(submission.transactionId, submission.eventId);
} else {
console.error(submission.error.code, submission.error.message);
}The submission result is one of two shapes.
Accepted Response Fields
| Field | Type | Meaning |
|---|---|---|
status | TruliooSendDeviceInformationStatus.Accepted | Trulioo accepted the device-event submission. Evaluation may still be processing. |
transactionId | string | Transaction identifier for the submitted device event. |
eventId | string | Device-event identifier for the submitted device event. |
debugTrace | TruliooDebugTraceEntry[] | SDK diagnostic entries captured while collecting and submitting the payload. |
Failed Response Fields
| Field | Type | Meaning |
|---|---|---|
status | TruliooSendDeviceInformationStatus.Failed | The SDK could not initialize the runtime, collect the payload, or submit the device event. |
error.code | TruliooSendDeviceInformationFailureCode | Stable failure code. |
error.stage | string | SDK stage at which the failure occurred. |
error.message | string | Failure detail. |
error.debugTrace | TruliooDebugTraceEntry[] | SDK diagnostic entries captured before the failure. |
sendDeviceInformation(...) is designed for receipt-based background submission. It returns after Trulioo accepts the event, rather than waiting for a final DI outcome.
Neither DI integration mode returns the detailed device result. Use the returned transaction ID with Retrieve the Detailed Result after processing completes.
Retrieve the Detailed Result
Both integration modes provide transactionId after submission. Call GET /transactions/{transactionId}/devices with that value after device processing is complete to retrieve the detailed device result.
collectDeviceIntelligence(...)normally resolves after reachingcompletedorfailed. If its configured polling limit is reached first, it resolves with the latest non-terminal lifecycle state and records the timeout indebugTrace.sendDeviceInformation(...)returnsacceptedbefore evaluation completes.
Retrieve details after the event is completed. If collectDeviceIntelligence(...) returns a non-terminal status, wait and retry the endpoint until processing completes.
See Get transaction devices for authentication, request requirements, and the detailed result fields.
Device Intelligence Options
Device Intelligence options customize explicit DI collection. They are optional; the SDK manages the device runtime automatically.
collectDeviceIntelligence(...) accepts optional polling controls:
| Option | Type | Use |
|---|---|---|
polling | DeviceIntelligencePollingOptions | Controls how long explicit collection waits for a terminal result. Defaults to 32 attempts, 1,250 ms apart. If the event remains non-terminal after the limit, the result contains the last lifecycle-only deviceEvent and records the timeout in debugTrace. |
Provide options directly to explicit collection:
const result = await Trulioo.collectDeviceIntelligence({
polling: {
maxAttempts: 10,
intervalMs: 1000,
},
});Resetting State
Call Trulioo.reset() to clear all internal session state. Use this for logout flows, multi-session apps, or when re-initializing with a new shortcode:
Trulioo.reset();
// Can now call Trulioo.initialize(...) again with a new shortcodereset() clears the internally stored session. Reinitialize before starting another session, and do not reuse a previous initialization result after reset.
Error Handling
Initialization errors:
- reject the initialization promise
Send errors:
- resolve with
{ status: TruliooSendDeviceInformationStatus.Failed, error: { code, stage, message, debugTrace } }
Collection errors:
- resolve with the unchanged initialization result when Device Intelligence is not enabled for the session
- reject the collection promise when device-runtime initialization, payload submission, device-event seeding, or a polling request fails
- resolve with the latest lifecycle-only
deviceEventwhen polling reaches its limit before a terminal status; inspect the returneddebugTracefor the timeout entry
Troubleshooting
If Device Intelligence does not appear:
- Confirm initialization completed successfully.
- Confirm Device Intelligence is enabled for the account and verification journey.
- Confirm you explicitly called
collectDeviceIntelligence(...)orsendDeviceInformation(...). - Inspect
debugTrace.
If results are incomplete:
- Inspect
deviceEvent?.failureReason. - Inspect
debugTracefor a polling timeout or failed stage. - After the event completes, retrieve the detailed result with
GET /transactions/{transactionId}/devices.

