Skip to main content
This page covers two cross-cutting surfaces: client.asyncJobs for polling long-running jobs, and client.on(...) for subscribing to SDK lifecycle events.

Async Jobs

Endpoints that kick off long-running work — currently adverse media screening — return a jobId immediately. Most callers use the typed handle from the originating method (screening.adverseMedia(...)), but client.asyncJobs.get(jobId) lets you resume polling a jobId you persisted earlier (for example, across process restarts).

get(jobId)

Fetch the current state of an async job by ID. Returns AsyncJobSnapshot — a discriminated union on status. result is typed as unknown because the async-jobs surface is service-agnostic; re-parse it against the originating service’s schema to narrow it.
createdAt is epoch seconds (a number); updatedAt is an ISO 8601 string. ready and failed are the terminal states.
Throws ValidationError (empty jobId), AuthenticationError (401), AuthorizationError (403), NotFoundError (404 — unknown ID or pruned by TTL), DeepIDVError.
See also: REST Get Async Job.

Events

The SDK emits lifecycle events for observability, logging, and APM integration. Subscribe with client.on(event, listener).

on(event, listener)

Subscribe to an event. Returns an unsubscribe function — call it to remove the listener.
For one-shot behavior, unsubscribe from inside the listener:

Event map

Execution model

Events dispatch synchronously within the request flow, in registration order. The SDK does not await listener return values. Therefore:
  • Listeners should not perform heavy blocking work — use async logging instead.
  • Listeners cannot modify the request or response — payloads are read-only.

Listener error safety

If a listener throws, the SDK catches the exception, emits a warning event with the details, and continues processing normally — a broken listener never crashes a request. If a warning listener itself throws, that exception is silently swallowed to prevent infinite recursion.

APM integration example