TOTP authenticators
Use these endpoints from your backend to implement the TOTP enrollment and sign-in flows. Prefix each path with https://api.passlock.dev/v2/{tenancyId}. Send Authorization: Bearer {apiKey} on every request and Content-Type: application/json on POST requests. Responses are JSON and include Cache-Control: no-store.
| Method and path | Input | Success |
|---|---|---|
POST /totp/authenticators |
JSON with userId, issuer, username, and optional settings |
201 TotpAuthenticatorCreated with authenticator and setup |
POST /totp/authenticators/{authenticatorId}/confirm |
JSON with userId and code |
200 TotpAuthenticatorConfirmed with authenticator |
POST /totp/verify |
JSON with userId, authenticatorId, and code |
200 TotpVerified with userId, authenticatorId, and verifiedAt |
GET /totp/authenticators/{authenticatorId} |
Query userId |
200 TotpAuthenticator |
GET /totp/authenticators |
Query userId and optional cursor |
200 FindAllTotpAuthenticators with records and cursor |
DELETE /totp/authenticators/{authenticatorId} |
Query userId |
200 TotpAuthenticatorDeleted |
Success payloads use _tag for the names in the table. URL-encode path and query values. Treat list cursors as opaque and keep the same userId when following them. An empty page can still have a cursor. Stop when cursor is null.
Create an authenticator
Section titled “Create an authenticator”POST https://api.passlock.dev/v2/{tenancyId}/totp/authenticators HTTP/1.1Authorization: Bearer {apiKey}Content-Type: application/json
{ "userId": "user_123", "issuer": "Acme", "username": "jdoe@example.com", "displayName": "Personal phone"}userId is your exact, case-sensitive application account ID, up to 256 UTF-8 bytes. issuer and username are trimmed labels of up to 128 UTF-8 bytes each, with no colons. Optional displayName is trimmed and supports up to 120 UTF-8 bytes. Labels must be nonblank and cannot contain control characters.
| Optional setting | Supported values | Default |
|---|---|---|
totp.algorithm |
SHA1, SHA256, SHA512 |
SHA1 |
totp.digits |
6, 8 |
6 |
totp.period |
30, 60 seconds |
30 |
verification.window |
0, 1 adjacent steps in each direction |
1 |
enrollmentExpiresIn |
Integer seconds from 300 to 1800 |
900 |
Use the default TOTP settings for broad authenticator app compatibility. The resolved settings are stored on the authenticator and apply to both confirmation and verification.
Creation returns a pending authenticator and a setup object with secret (Base32), uri (otpauth://), and qrCodeDataUrl (PNG). Setup material is available only in this response. The nested authenticator has _tag: "TotpAuthenticator" and the same metadata shape as the get and list endpoints.
Confirm and verify codes
Section titled “Confirm and verify codes”Pass the pending authenticator.id in the confirmation path. The JSON body has userId and a string code, such as "012345". For subsequent sign-ins, call /totp/verify with the same fields plus authenticatorId in the JSON body. Both calls consume the accepted code. Verification requires a confirmed, unsuspended authenticator.
Authenticator metadata includes id, userId, issuer, username, optional displayName, createdAt, totp, and verification. Pending records have status: "pending" and expiresAt. Confirmed records have status: "active", confirmedAt, and optional lastUsed and suspendedAt. lastUsed records successful sign-in verification. suspendedAt is present while the credential is suspended. Timestamp fields, including verifiedAt, are Unix milliseconds.
Errors
Section titled “Errors”Error payloads include _tag and message.
| Status | Error tag | Meaning |
|---|---|---|
400 |
@error/BadRequest |
Invalid request shape or field value. |
400 |
@error/InvalidTotpCode |
The submitted code did not verify. |
401 |
@error/Unauthorized |
Missing authorization. |
403 |
@error/Forbidden |
Invalid API key. |
404 |
@error/NotFound |
The record is unavailable for that tenancy and user. |
409 |
@error/TotpCodeAlreadyUsed |
The matching time step was already consumed or superseded. |
409 |
@error/TotpAuthenticatorNotActive |
The authenticator is pending or suspended. |
409 |
@error/TotpAuthenticatorAlreadyActive |
The authenticator has already been confirmed. |
409 |
@error/TotpAuthenticatorLimit |
Enrollment quota reached. The payload includes kind and limit. |
410 |
@error/TotpEnrollmentExpired |
Start a new enrollment. |
413 |
@error/ContentTooLarge |
The request body exceeds 16 KiB. |
429 |
@error/TotpRateLimited |
Wait for the duration in the Retry-After header and retryAfterSeconds field. |
503 |
@error/ServiceUnavailable |
Passlock could not complete the request or confirm its outcome. |