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

OpenAPI 3.1 Specification (1.0.0-dev-pilot)

Generated directly from docs/openapi.yaml reflecting verified Runtime API v1 routes.

openapi.yaml
openapi: 3.1.0
info:
  title: Trustlith Runtime API v1
  version: 1.0.0-dev-pilot
  description: >
    Authoritative REST API for Trustlith cryptographic authentication and
    high-trust transaction authorization (Public Runtime API v1).
    Application-facing routes require a server-side `Authorization: Bearer <key>`
    credential scoped to one tenant and application; Trustlith derives scope
    from the credential and rejects caller-supplied `tenantId` or `applicationId`.
    Device-facing endpoints use `Authorization: Device <retrieval-token>` or
    one-time enrollment handoff redemption. Custom Auditable Transactions (V2)
    remain planned under proposed ADR 0022 and are not exposed on this API.
servers:
  - url: https://provisioning-dev.trustlith.com
    description: Controlled DEV Runtime (Access/WAF protected)
  - url: http://localhost:8787
    description: Local Wrangler development runtime
tags:
  - name: Health
    description: Service availability probe
  - name: Application API (Server-Side)
    description: Endpoints called exclusively from your trusted application backend using Bearer API credentials
  - name: Enrollment & Device Protocol
    description: Endpoints called by Trustlith Authenticator mobile clients using one-time handoffs or device Bearer tokens
paths:
  /health:
    get:
      tags: [Health]
      operationId: getHealth
      summary: Check Trustlith Runtime availability
      responses:
        "200":
          description: Service is reachable and configured.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthResponse"
  /v1/enrollments:
    post:
      tags: [Application API (Server-Side)]
      operationId: createEnrollment
      summary: Create a one-time primary device enrollment for a mapped user
      description: Requires scope `enrollments:create` and an existing `ACTIVE` user mapping for `externalUserId`.
      security: [{ ApplicationBearer: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateEnrollmentRequest"
      responses:
        "201":
          description: One-time enrollment created (valid for 10 minutes).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateEnrollmentResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "404": { $ref: "#/components/responses/ApiErrorResponse" }
        "429": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/enrollment-handoffs:
    post:
      tags: [Application API (Server-Side)]
      operationId: createEnrollmentHandoff
      summary: Mint an opaque QR/deep-link handoff token for an existing pending enrollment
      description: Requires scope `enrollments:create`. Returns the single-use opaque `ref` exactly once (expires within 5 minutes, capped by underlying enrollment expiry).
      security: [{ ApplicationBearer: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateEnrollmentHandoffRequest"
      responses:
        "201":
          description: Opaque handoff created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateEnrollmentHandoffResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "404": { $ref: "#/components/responses/ApiErrorResponse" }
        "409": { $ref: "#/components/responses/ApiErrorResponse" }
        "410": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/enrollments/{enrollmentId}/complete:
    post:
      tags: [Enrollment & Device Protocol]
      operationId: completeEnrollment
      summary: Complete primary enrollment with a device-generated P-256 public key
      parameters:
        - in: path
          name: enrollmentId
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompleteEnrollmentRequest"
      responses:
        "201":
          description: Device and P-256 credential registered.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompleteEnrollmentResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "409": { $ref: "#/components/responses/ApiErrorResponse" }
        "429": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/enrollment-handoffs/redeem:
    post:
      tags: [Enrollment & Device Protocol]
      operationId: redeemEnrollmentHandoff
      summary: Redeem an opaque QR/deep-link handoff reference from Trustlith Authenticator
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RedeemEnrollmentHandoffRequest"
      responses:
        "201":
          description: Handoff redeemed and enrollment or additional-device claim completed.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "409": { $ref: "#/components/responses/ApiErrorResponse" }
        "410": { $ref: "#/components/responses/ApiErrorResponse" }
        "429": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/challenges:
    post:
      tags: [Application API (Server-Side)]
      operationId: createChallenge
      summary: Create a V1 login or fund_transfer authentication challenge
      description: >
        Requires scope `challenges:create`. Caller must NOT include `tenantId`
        or `applicationId` in the JSON body (`400 SCOPE_NOT_ACCEPTED`).
        `context.origin` must exactly match the registered application origin.
        When `action` is `"fund_transfer"`, `transactionContext` is mandatory and
        must include `type: "fund_transfer"`.
      security: [{ ApplicationBearer: [] }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateChallengeRequest"
      responses:
        "201":
          description: Pending challenge created (TTL 120 seconds).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CreateChallengeResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "404": { $ref: "#/components/responses/ApiErrorResponse" }
        "429": { $ref: "#/components/responses/ApiErrorResponse" }
        "503": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/challenges/{challengeId}/status:
    get:
      tags: [Application API (Server-Side)]
      operationId: getChallengeStatus
      summary: Read authoritative challenge status within the credential's tenant and application
      description: Requires scope `challenges:read`. Lazily expires overdue `PENDING` challenges before returning status.
      security: [{ ApplicationBearer: [] }]
      parameters:
        - in: path
          name: challengeId
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Authoritative challenge status.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChallengeStatusResponse"
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "404": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/challenges/{challengeId}/cancel:
    post:
      tags: [Application API (Server-Side)]
      operationId: cancelChallenge
      summary: Cancel a pending unexpired challenge
      description: >
        Requires scope `challenges:cancel`. Atomically transitions an unexpired
        `PENDING` challenge in the caller's tenant and application to `CANCELLED`.
        Overdue or non-pending challenges fail closed with `409 INVALID_STATE_TRANSITION`.
      security: [{ ApplicationBearer: [] }]
      parameters:
        - in: path
          name: challengeId
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Pending challenge cancelled.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CancelChallengeResponse"
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
        "409": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/devices/{deviceId}/challenges:
    get:
      tags: [Enrollment & Device Protocol]
      operationId: listDeviceChallenges
      summary: Fetch active pending challenges eligible for this registered device
      security: [{ DeviceBearer: [] }]
      parameters:
        - in: path
          name: deviceId
          required: true
          schema: { type: string }
      responses:
        "200":
          description: Pending challenges with canonical TRUSTLITH-AUTH-V1 fields.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeviceChallengesResponse"
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/challenges/{challengeId}/approve:
    post:
      tags: [Enrollment & Device Protocol]
      operationId: approveChallenge
      summary: Verify an ES256 P-256 device signature over TRUSTLITH-AUTH-V1\0 and approve a challenge
      security: [{ DeviceBearer: [] }]
      parameters:
        - in: path
          name: challengeId
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ApprovalRequest"
      responses:
        "200":
          description: Signature verified (`APPROVED`) or challenge already resolved (`already_resolved`).
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChallengeResolutionResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "429": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/challenges/{challengeId}/reject:
    post:
      tags: [Enrollment & Device Protocol]
      operationId: rejectChallenge
      summary: Reject a pending challenge from an authorized device
      description: V1 accepts an authenticated device rejection with `credentialId` (`accepted_unsigned_device_rejection`).
      security: [{ DeviceBearer: [] }]
      parameters:
        - in: path
          name: challengeId
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [credentialId]
              properties:
                credentialId:
                  type: string
                  maxLength: 100
      responses:
        "200":
          description: Challenge rejected or already resolved.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChallengeResolutionResponse"
        "400": { $ref: "#/components/responses/ApiErrorResponse" }
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
  /v1/development/overview:
    get:
      tags: [Application API (Server-Side)]
      operationId: getDevelopmentOverview
      summary: Read application-scoped development observability projections
      description: Requires scope `development:read` (not granted to standard V1 pilot keys unless explicitly provisioned).
      security: [{ ApplicationBearer: [] }]
      responses:
        "200":
          description: Application-scoped telemetry, devices, challenges, and audit summary.
        "401": { $ref: "#/components/responses/ApiErrorResponse" }
        "403": { $ref: "#/components/responses/ApiErrorResponse" }
components:
  securitySchemes:
    ApplicationBearer:
      type: http
      scheme: bearer
      description: "Server-only API credential (`Authorization: Bearer trl_pd1_...`). Scoped strictly to one tenant and application."
    DeviceBearer:
      type: apiKey
      in: header
      name: Authorization
      description: "Device authorization header formatted as `Authorization: Device <retrieval-token>`."
  responses:
    ApiErrorResponse:
      description: Structured error payload
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ApiError"
  schemas:
    ApiError:
      type: object
      additionalProperties: false
      required: [error]
      properties:
        error:
          type: object
          additionalProperties: false
          required: [code, message]
          properties:
            code: { type: string, example: INVALID_REQUEST }
            message: { type: string }
    HealthResponse:
      type: object
      additionalProperties: false
      required: [status, service, environment, phase]
      properties:
        status: { type: string, const: ok }
        service: { type: string, const: trustlith-api }
        environment: { type: string, enum: [development, staging, production] }
        phase: { type: integer }
    CreateEnrollmentRequest:
      type: object
      additionalProperties: false
      required: [externalUserId]
      properties:
        externalUserId:
          type: string
          minLength: 1
          maxLength: 128
          description: External application user identifier already mapped as ACTIVE in the tenant/application.
    CreateEnrollmentResponse:
      type: object
      additionalProperties: false
      required: [enrollmentId, enrollmentToken, expiresAt, developmentOnly]
      properties:
        enrollmentId: { type: string }
        enrollmentToken: { type: string, description: "One-time enrollment secret; mint a QR handoff or deliver securely without logging." }
        expiresAt: { type: string, format: date-time }
        developmentOnly: { type: boolean }
    CreateEnrollmentHandoffRequest:
      type: object
      additionalProperties: false
      required: [enrollmentId, ceremonyType]
      properties:
        enrollmentId: { type: string, maxLength: 100 }
        ceremonyType: { type: string, enum: [FIRST_DEVICE, ADDITIONAL_DEVICE] }
    CreateEnrollmentHandoffResponse:
      type: object
      additionalProperties: false
      required: [handoffId, ceremonyType, expiresAt, ref]
      properties:
        handoffId: { type: string }
        ceremonyType: { type: string, enum: [FIRST_DEVICE, ADDITIONAL_DEVICE] }
        expiresAt: { type: string, format: date-time }
        ref: { type: string, description: "Opaque one-time QR/deep-link handoff reference; returned once." }
    CompleteEnrollmentRequest:
      type: object
      additionalProperties: false
      required: [enrollmentToken, displayName, platform, publicKeyJwk]
      properties:
        enrollmentToken: { type: string, maxLength: 160 }
        displayName: { type: string, maxLength: 80 }
        platform: { type: string, enum: [IOS, ANDROID, WINDOWS, MACOS] }
        publicKeyJwk:
          type: object
          required: [kty, crv, x, y]
          properties:
            kty: { type: string, const: EC }
            crv: { type: string, const: P-256 }
            x: { type: string }
            y: { type: string }
        assurance:
          type: string
          enum: [SOFTWARE, HARDWARE_BACKED]
          default: SOFTWARE
          description: Device-reported key protection claim (NOT_EVALUATED per ADR 0010; ATTESTED is rejected).
        idempotencyKey: { type: string, maxLength: 200 }
        retrievalTokenHash:
          type: string
          pattern: "^[a-f0-9]{64}$"
          description: Optional SHA-256 hex digest of caller-generated retrieval token for replayable idempotent completion.
    CompleteEnrollmentResponse:
      type: object
      required: [deviceId, credentialId, algorithm, assurance, tenantId, applicationId, externalUserId, serviceName, developmentOnly]
      properties:
        deviceId: { type: string }
        credentialId: { type: string }
        credentialDbId: { type: string }
        credentialPublicId: { type: string }
        retrievalToken: { type: string, description: Present on first completion when server-minted; never replayed. }
        retrievalTokenFrozen: { type: boolean }
        idempotentReplay: { type: boolean }
        algorithm: { type: string, const: ES256 }
        assurance: { type: string, enum: [SOFTWARE, HARDWARE_BACKED] }
        tenantId: { type: string }
        applicationId: { type: string }
        externalUserId: { type: string }
        serviceName: { type: string }
        developmentOnly: { type: boolean }
    RedeemEnrollmentHandoffRequest:
      type: object
      additionalProperties: false
      required: [ref, redemptionId, displayName, platform, publicKeyJwk, retrievalTokenHash]
      properties:
        ref: { type: string }
        redemptionId: { type: string }
        displayName: { type: string, maxLength: 80 }
        platform: { type: string, enum: [IOS, ANDROID, WINDOWS, MACOS] }
        publicKeyJwk:
          type: object
          required: [kty, crv, x, y]
          properties:
            kty: { type: string, const: EC }
            crv: { type: string, const: P-256 }
            x: { type: string }
            y: { type: string }
        assurance: { type: string, enum: [SOFTWARE, HARDWARE_BACKED], default: SOFTWARE }
        retrievalTokenHash: { type: string, pattern: "^[a-f0-9]{64}$" }
    CreateChallengeRequest:
      type: object
      additionalProperties: false
      required: [externalUserId, action, context]
      properties:
        externalUserId:
          type: string
          minLength: 1
          maxLength: 128
          description: Registered ACTIVE external user identifier for this application.
        action:
          type: string
          enum: [login, fund_transfer]
          description: Case-insensitive at ingress; lowercase canonical form is recommended.
        context:
          type: object
          additionalProperties: false
          required: [origin, device]
          properties:
            origin:
              type: string
              maxLength: 200
              description: Must match the registered origin configured on your Trustlith application.
            device:
              type: string
              maxLength: 100
              description: Human-readable initiator label displayed on the Authenticator prompt (e.g. Web Session).
        transactionContext:
          $ref: "#/components/schemas/TransactionContext"
    TransactionContext:
      type: object
      additionalProperties: false
      required: [type, amount, currency, recipientId, recipientDisplay, transactionReference]
      properties:
        type:
          type: string
          const: fund_transfer
          description: Mandatory literal `"fund_transfer"` required by `validateTransaction`.
        amount:
          type: string
          pattern: "^[0-9]{1,12}\\.[0-9]{2}$"
          example: "250.00"
        currency:
          type: string
          pattern: "^[A-Z]{3}$"
          example: "USD"
        recipientId: { type: string, maxLength: 100, example: acct_vendor_01 }
        recipientDisplay: { type: string, maxLength: 120, example: Acme Cloud Services }
        transactionReference: { type: string, maxLength: 100, example: INV-2026-041 }
    CreateChallengeResponse:
      type: object
      additionalProperties: false
      required: [challengeId, status, expiresAt]
      properties:
        challengeId: { type: string }
        status: { type: string, const: PENDING }
        expiresAt: { type: string, format: date-time }
    ChallengeStatusResponse:
      type: object
      additionalProperties: false
      required: [challengeId, status, expiresAt, action]
      properties:
        challengeId: { type: string }
        status:
          type: string
          enum: [PENDING, APPROVED, REJECTED, CANCELLED, EXPIRED]
        expiresAt: { type: string, format: date-time }
        action:
          type: string
          enum: [login, fund_transfer]
    CancelChallengeResponse:
      type: object
      additionalProperties: false
      required: [challengeId, status]
      properties:
        challengeId: { type: string }
        status: { type: string, const: CANCELLED }
    ApprovalRequest:
      type: object
      additionalProperties: false
      required: [credentialId, algorithm, signature]
      properties:
        credentialId: { type: string, maxLength: 100 }
        algorithm: { type: string, const: ES256 }
        signature: { type: string, maxLength: 200, description: Unpadded base64url 64-byte IEEE-P1363 ES256 signature over TRUSTLITH-AUTH-V1\0 payload. }
    ChallengeResolutionResponse:
      type: object
      required: [challengeId, status, result]
      properties:
        challengeId: { type: string }
        status: { type: string, enum: [PENDING, APPROVED, REJECTED, CANCELLED, EXPIRED] }
        result: { type: string }
    DeviceChallengesResponse:
      type: object
      required: [challenges]
      properties:
        challenges:
          type: array
          items:
            $ref: "#/components/schemas/AuthenticationChallenge"
    AuthenticationChallenge:
      type: object
      description: Device-facing canonical TRUSTLITH-AUTH-V1 fields.
      required: [version, challengeId, tenantId, applicationId, externalUserId, action, nonce, origin, device, createdAt, expiresAt, transactionContext, credentialId]
      properties:
        version: { type: integer, minimum: 1 }
        challengeId: { type: string }
        tenantId: { type: string }
        applicationId: { type: string }
        externalUserId: { type: string }
        action: { type: string, enum: [LOGIN, FUND_TRANSFER] }
        nonce: { type: string }
        origin: { type: string }
        device: { type: string }
        createdAt: { type: string, format: date-time }
        expiresAt: { type: string, format: date-time }
        transactionContext:
          oneOf:
            - { type: "null" }
            - { $ref: "#/components/schemas/TransactionContext" }
        credentialId: { type: string }
        status: { type: string, const: PENDING }
        accountDisplay: { type: string }
        applicationName: { type: string }