Using the REST API
Passlock includes a REST API, along with the @passlock/server library to manage your tenancy data. The REST API allows you to:
- Create, inspect, verify, and delete mailbox challenges for email one-time code flows
- Enroll, verify, and manage TOTP authenticators for authenticator app codes
- Exchange a passkey registration or authentication code for an ExtendedPrincipal
- List passkeys in your vault
- Fetch a passkey from your vault
- Prepare passkey update, deletion, and pruning operations
- Authorize and complete passkey registration and authentication operations
Tenancy ID
Section titled “Tenancy ID”REST API calls operate on a specific tenancy. You will need your Tenancy ID, along with the relevant API Key. API endpoints are typically prefixed with the Tenancy ID, e.g.
GET https://api.passlock.dev/v2/\{tenancyId\}/passkeys/ HTTP/1.1Authentication
Section titled “Authentication”Server-side REST API calls require authentication. Provide your tenancy-specific API Key via a Bearer authorization header:
GET https://api.passlock.dev/v2/\{tenancyId\}/passkeys/ HTTP/1.1Authorization: Bearer \{apiKey\}The passkey registration and authentication options and verification endpoints are browser-facing continuations of an authorized operation. They use the registrationToken, authenticationToken, or sessionToken issued earlier in the flow rather than a tenancy API key.
REST calls return JSON:
GET https://api.passlock.dev/v2/\{tenancyId\}/passkeys/ HTTP/1.1Authorization: Bearer \{apiKey\}Accept: application/jsonHTTP/1.1 200 OKContent-Type: application/jsonDeleted user IDs
Section titled “Deleted user IDs”After deleteUser succeeds, wait for cleanup to finish before reusing that exact user ID. In every tenancy, a fresh passkey registration authorization, TOTP enrollment or user-bound mailbox challenge can then create a replacement account. Retrying the original delete after recreation deletes the new user. Finish outstanding delete retries before reassigning the ID. Account for application sessions and any previously issued ID tokens that offline verifiers can accept until expiry.
These authenticated POST operations return HTTP 400 when the request explicitly supplies a user ID whose cleanup is pending. REST paths are relative to /v2/{tenancyId}.
| Server SDK method | REST path |
|---|---|
createMailboxChallenge |
/challenges |
authorizePasskeyRegistration |
/passkey/registration/authorize |
authorizePasskeyAuthentication |
/passkey/authentication/authorize |
createTotpAuthenticator |
/totp/authenticators |
updatePasskeys |
/passkeys/update |
deletePasskeys |
/passkeys/delete |
prunePasskeys |
/passkeys/prune |
{ "_tag": "@error/BadRequest", "message": "Deletion cleanup is still in progress for this user ID. Try again after cleanup completes."}The Server SDK returns this as a bad-request result. The tag also covers other invalid requests. Treat the message as diagnostic text for developers.
Endpoint summary
Section titled “Endpoint summary”- GET /v2/{tenancyId}/principal/{code}
- Exchanges a browser-issued code for an
ExtendedPrincipal - GET /v2/{tenancyId}/passkeys/
- Lists passkey summaries
- GET /v2/{tenancyId}/passkeys/{passkeyId}
- Fetches a passkey
- POST /v2/{tenancyId}/passkeys/update
- Updates username metadata and prepares browser update instructions
- POST /v2/{tenancyId}/passkeys/update/exchange
- Exchanges a prepared update token for browser instructions
- POST /v2/{tenancyId}/passkeys/delete
- Deletes passkeys and prepares browser removal instructions
- POST /v2/{tenancyId}/passkeys/delete/exchange
- Exchanges a prepared deletion token for browser instructions
- POST /v2/{tenancyId}/passkeys/prune
- Prepares accepted-credential pruning instructions for a user
- POST /v2/{tenancyId}/passkeys/prune/exchange
- Exchanges a prepared pruning token for browser instructions
- POST /v2/{tenancyId}/challenges
- Creates a mailbox challenge
- GET /v2/{tenancyId}/challenges/{challengeId}
- Reads a pending mailbox challenge
- POST /v2/{tenancyId}/challenges/verify
- Verifies a mailbox challenge
- DELETE /v2/{tenancyId}/challenges/{challengeId}
- Deletes a mailbox challenge
- POST /v2/{tenancyId}/passkey/registration/authorize
- Authorizes a passkey registration
- POST /v2/{tenancyId}/passkey/registration/options
- Creates WebAuthn registration options
- POST /v2/{tenancyId}/passkey/registration/verification
- Verifies a registration response
- POST /v2/{tenancyId}/passkey/authentication/authorize
- Authorizes a passkey authentication
- POST /v2/{tenancyId}/passkey/authentication/options
- Creates WebAuthn authentication options
- POST /v2/{tenancyId}/passkey/authentication/verification
- Verifies an authentication response