Skip to main content
Use this reference client to connect a borrower, submit an origination, retrieve its results, enroll monitoring and reconcile billing in AMLOK Sandbox. It combines the endpoint examples into one journey and preserves command identities across interruptions.

Download the example

Save these files together: Use Node.js 22 or newer, which supplies fetch, FormData, Blob and structuredClone. No package installation is needed. The file is a reference client, not a distributed product SDK.

Provision the test environment

An Owner obtains the API origin, creates a Sandbox key, and publishes a Hub containing configuration.sandbox.test_integration_id. Approve your return URL and both credit_assessment and continuous_monitoring purposes. For this complete example, the Owner key needs borrowers:read/write, connections:read/write, configuration:read/write, insights:read/write, results:read, evidence:read/write, data:read, signal:read/write, billing:read, exports:read/write and reliability:read. Set AMLOK_BORROWER_TYPE=person and use a fresh state file to run the consumer fixture, which uses gross monthly income, monthly debt payments and a synthetic debt_to_income rule. Check configuration for the corresponding application schema and supported policy dimensions. The default development input file uses a Canadian business, a fixed-rate term loan, annual_revenue application data and a dscr rule. Match the application schema, pricing schema and metric IDs to those returned by configuration. Update the input file if your environment uses different schemas.
The placeholders above are provisioning values, not working credentials. Prefer a secret manager instead of shell history on shared systems. The state file contains synthetic inputs and resource IDs but no API key or launch URL. Keep it private; use a distinct file for each new journey.

Connect, submit and reconcile

Prepare creates the borrower, product/policy versions and embedding session. Open the printed short-lived URL privately and select Connect test institution. Affirm both purposes. Then run:
Complete retrieves the authoritative session, uploads the supplied PDF, submits the origination and waits within a bounded interval. It reads the risk package, all evidence and a complete data snapshot, obtains a change-feed checkpoint, enrolls Signal, appends a lender deal snapshot, reads monitoring runs and alerts, prepares a JSON risk-package export and a controlled download capability, and reads payments, usage and transactions against one billing snapshot. Expected output identifies the origination, package, monitor, deal snapshot and billing snapshot, plus record counts and available credits. IDs and counts come from your API responses. The journey stops visibly on requires_action, waiting_for_credits or failed. Follow recovery instructions, then rerun complete with the same state file. Never replace an accepted origination simply because your client timed out. The example uses bounded transport retries and request receipts; production applications should use a transactional database/outbox for durable state instead of a local JSON file.

Browser integration and event handling

Use the browser helper and Hub protocol to integrate into your own UI. Your authenticated backend supplies the session and verifies completion. Use the downloadable Node.js verifier or Python verifier with a durable event inbox before acknowledging webhooks.

Test failures deliberately

Set AMLOK_SCENARIO to a documented Sandbox scenario and use a new state file. This client exercises the main happy path and exposes structured blocking states. The scenario manifest and acceptance checklist cover additional security, failure, expiry, event and billing behaviors. Use the integration checklist to verify your application’s handling of each outcome.