Public Runtime API v1 Live (1.0.0-dev-pilot) Custom Transactions V2: Planned (Not Deployed) @trustlith/sdk-js: Local Prototype Only

5-Step Quickstart (Public Runtime API v1)

Follow this sequence to connect an application to Trustlith using your Developer Portal workspace:

Step 1 — Register Your Application & Origin

In Developer Portal → Applications, register your application name and exact canonical origin URL (for example https://app.example.com). Every POST /v1/challenges request must submit this exact context.origin string.

Step 2 — Issue, Reveal & Activate a Backend API Credential

  1. Open Developer Portal → API Credentials for your application.
  2. Issue a new credential and complete the one-time reveal step.
  3. Save the credential in your backend server's secret store as TRUSTLITH_API_KEY.
  4. Click Activate in Portal. Keys that remain ISSUED or are REVOKED / EXPIRED fail closed with 401.

Security Warning: Never place TRUSTLITH_API_KEY inside browser JavaScript, mobile apps, or client-visible environment variables (NEXT_PUBLIC_*).

Step 3 — Map an External User

Open Developer Portal → Test Users and register an immutable external user identifier (externalUserId, max 128 chars, for example a database user UUID or "user_12345").

Step 4 — Enroll Trustlith Authenticator

Open Developer Portal → Enrollment (or follow User Enrollment Guide programmatically), generate a one-time QR handoff for the mapped user, and scan it with Trustlith Authenticator on iOS or Android. Wait until the Portal shows an active hardware-bound P-256 device.

Step 5 — Trigger & Verify a Challenge from Your Backend

  1. Call POST /v1/challenges with action: "login" or action: "fund_transfer" (see Code Examples).
  2. Instruct your frontend to display a waiting state ("Approve in Trustlith Authenticator within 2 minutes").
  3. Poll GET /v1/challenges/:challengeId/status from your backend every 2–3 seconds (stopping immediately on terminal status or user cancel).
  4. Grant access or execute the sensitive mutation only when your backend observes status === "APPROVED". Reject cleanly on REJECTED, CANCELLED, or EXPIRED.

User Enrollment Guide (V1)

Before a user can approve login or fund_transfer challenges, they must be mapped in your application and have at least one enrolled Trustlith Authenticator device holding a P-256 key.

Option 1 — Developer Portal Test Workbench (Fastest for Pilot Setup)

  1. Open Developer Portal → Test Users and register your user's immutable externalUserId.
  2. Open Developer Portal → Enrollment, choose the user, and click Start First-Device QR Enrollment.
  3. Scan the rendered QR code using Trustlith Authenticator on iOS or Android and confirm biometric prompt completion.

Option 2 — Programmatic Backend Handoff (POST /v1/enrollments + POST /v1/enrollment-handoffs)

For an active mapped user in tenant_users:

  1. Create a 10-minute enrollment (enrollments:create):

```http POST /v1/enrollments Authorization: Bearer <TRUSTLITH_API_KEY> Content-Type: application/json

{ "externalUserId": "user_12345" } `` Returns { enrollmentId, enrollmentToken, expiresAt, developmentOnly }. Keep enrollmentToken` server-side!

  1. Mint an opaque single-use QR/deep-link handoff (enrollments:create):

```http POST /v1/enrollment-handoffs Authorization: Bearer <TRUSTLITH_API_KEY> Content-Type: application/json

{ "enrollmentId": "<enrollmentId>", "ceremonyType": "FIRST_DEVICE" } `` Returns { handoffId, ceremonyType, expiresAt, ref } (ref expires within 5 minutes, returned once and never logged). Encode ref into your UI's one-time QR code or mobile deep link; Trustlith Authenticator redeems ref directly against /v1/enrollment-handoffs/redeem without ever seeing enrollmentToken`.


Public Runtime API v1 Reference

Machine-readable schema: docs/openapi.yaml.

Authentication & Scoping Rules

Application Bearer Endpoints

Method & Path Required Scope Request Body Success Response
GET /health None — 200 { status: "ok", service: "trustlith-api", environment, phase }
POST /v1/enrollments enrollments:create { externalUserId } 201 { enrollmentId, enrollmentToken, expiresAt, developmentOnly }
POST /v1/enrollment-handoffs enrollments:create `{ enrollmentId, ceremonyType: "FIRST_DEVICE" \ "ADDITIONAL_DEVICE" }` 201 { handoffId, ceremonyType, expiresAt, ref }
POST /v1/challenges challenges:create `{ externalUserId, action: "login" \ "fund_transfer", context: { origin, device }, transactionContext? }` 201 { challengeId, status: "PENDING", expiresAt }
GET /v1/challenges/:challengeId/status challenges:read — 200 { challengeId, status, expiresAt, action }
POST /v1/challenges/:challengeId/cancel challenges:cancel — 200 { challengeId, status: "CANCELLED" }

Challenge status State Machine

Common Error Codes