Authentication & MFA
Magic links, password auth, TOTP, passkeys, and adaptive MFA.
/api/v1/auth/magic-linkRequest Magic Link▾Sends a magic link to the provided email address. If the account exists, the user will receive an email with a one-time login link. Returns a generic message regardless of whether the account exists to prevent email enumeration.
Request Body
Response Fields
Response Example
{
"message": "If an account exists, a magic link has been sent"
}Code Examples
/api/v1/auth/verifyVerify Magic Link Token▾Exchanges a magic link token (extracted from the emailed URL) for a full session. Returns access and refresh tokens along with user and organization context. If MFA is required, returns mfaRequired: true and an mfaToken to complete the MFA challenge instead.
Request Body
Response Fields
Response Example
{
"accessToken": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c3JfMTIzIn0.sig",
"refreshToken": "rt_a1b2c3d4e5f6a1b2c3d4e5f6",
"expiresIn": 900,
"tokenType": "Bearer",
"user": {
"id": "usr_01hy5j8x2k3n4m5p6q7r8s9t",
"email": "alice@example.com",
"firstName": "Alice",
"lastName": "Smith",
"organizationId": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"role": "ADMIN"
},
"organization": {
"id": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"name": "Acme Corp",
"slug": "acme-corp",
"role": "ADMIN"
}
}Code Examples
/api/v1/auth/registerRegister with Email & Password▾Creates a new user account with an email and password. Returns a full session immediately upon successful registration. Password must be at least 8 characters.
Request Body
Response Fields
Response Example
{
"accessToken": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c3JfbmV3In0.sig",
"refreshToken": "rt_newuser1234567890abcdef",
"expiresIn": 900,
"tokenType": "Bearer",
"user": {
"id": "usr_02ab3cd4ef5g6h7i8j9k0l1m",
"email": "bob@example.com",
"firstName": null,
"lastName": null,
"organizationId": "org_02ab3cd4ef5g6h7i8j9k0l1m",
"role": "OWNER"
},
"organization": {
"id": "org_02ab3cd4ef5g6h7i8j9k0l1m",
"name": "Bob's Organization",
"slug": "bobs-organization",
"role": "OWNER"
}
}Code Examples
/api/v1/auth/loginLogin with Password▾Authenticates a user with their email and password. Optionally accepts an organizationId to log into a specific organization context. If the account has MFA enabled, the response will include mfaRequired: true and an mfaToken — use the MFA Verify Challenge endpoint to complete the login.
Request Body
Response Fields
Response Example
{
"accessToken": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c3JfMTIzIn0.sig",
"refreshToken": "rt_a1b2c3d4e5f6a1b2c3d4e5f6",
"expiresIn": 900,
"tokenType": "Bearer",
"user": {
"id": "usr_01hy5j8x2k3n4m5p6q7r8s9t",
"email": "alice@example.com",
"firstName": "Alice",
"lastName": "Smith",
"organizationId": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"role": "ADMIN"
},
"organization": {
"id": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"name": "Acme Corp",
"slug": "acme-corp",
"role": "ADMIN"
}
}Code Examples
/api/v1/auth/forgot-passwordRequest Password Reset▾Sends a password reset email to the provided address. Returns a generic message regardless of whether the email is registered, preventing user enumeration.
Request Body
Response Fields
Response Example
{
"message": "If an account exists, a reset link has been sent"
}Code Examples
/api/v1/auth/reset-passwordReset Password▾Resets a user password using the token received in the reset email. The new password must be at least 8 characters. The reset token is single-use and expires after a short period.
Request Body
Response Fields
Response Example
{
"message": "Password reset successfully"
}Code Examples
/api/v1/auth/change-passwordChange PasswordBearer Token▾Changes the password for the currently authenticated user. Requires the current password for verification. The new password must be at least 8 characters.
Request Body
Response Fields
Response Example
{
"message": "Password changed successfully"
}Code Examples
/api/v1/auth/meGet Current UserBearer Token▾Returns the profile of the currently authenticated user. Useful for hydrating application state after a page load or token refresh.
Response Fields
Response Example
{
"user": {
"id": "usr_01hy5j8x2k3n4m5p6q7r8s9t",
"email": "alice@example.com",
"firstName": "Alice",
"lastName": "Smith",
"organizationId": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"role": "ADMIN"
}
}Code Examples
/api/v1/auth/logoutLogoutBearer Token▾Revokes the current session for the authenticated user. The access token is invalidated server-side. Clients should discard stored tokens after calling this endpoint.
Response Fields
Response Example
{
"message": "Logged out successfully"
}Code Examples
/api/v1/auth/mfa/statusGet MFA StatusBearer Token▾Returns the current MFA enrollment status for the authenticated user, including all enrolled methods with their type, verification status, and last usage timestamp.
Response Fields
Response Example
{
"enabled": true,
"methods": [
{
"id": "mfa_01hz1a2b3c4d5e6f7g8h",
"type": "TOTP",
"name": "Authenticator App",
"verified": true,
"enabled": true,
"lastUsedAt": "2025-01-15T10:30:00.000Z"
},
{
"id": "mfa_02ab3cd4ef5g6h7i8j9k",
"type": "BACKUP_CODE",
"name": "Backup Codes",
"verified": true,
"enabled": true,
"lastUsedAt": null
}
]
}Code Examples
/api/v1/auth/mfa/enroll/totpEnroll TOTP AuthenticatorBearer Token▾Initiates TOTP enrollment for the authenticated user. Returns a methodId, the otpauth:// URI, a base64-encoded QR code image, and a set of one-time backup codes. Present the QR code to the user for scanning with an authenticator app, then call the Verify TOTP Enrollment endpoint to confirm.
Response Fields
Response Example
{
"methodId": "mfa_01hz1a2b3c4d5e6f7g8h",
"otpAuthUrl": "otpauth://totp/SutraID%3Aalice%40example.com?secret=BASE32SECRET&issuer=SutraID",
"qrCode": "data:image/png;base64,iVBORw0KGgo...",
"backupCodes": [
"AAAA-BBBB-CCCC",
"DDDD-EEEE-FFFF",
"GGGG-HHHH-IIII",
"JJJJ-KKKK-LLLL",
"MMMM-NNNN-OOOO",
"PPPP-QQQQ-RRRR",
"SSSS-TTTT-UUUU",
"VVVV-WWWW-XXXX"
]
}Code Examples
/api/v1/auth/mfa/enroll/verifyVerify TOTP EnrollmentBearer Token▾Completes TOTP enrollment by submitting the 6-digit code from the authenticator app. Must be called after initiating enrollment with the Enroll TOTP endpoint. On success, TOTP becomes the active MFA method for the account.
Request Body
Response Fields
Response Example
{
"success": true,
"backupCodes": [
"AAAA-BBBB-CCCC",
"DDDD-EEEE-FFFF",
"GGGG-HHHH-IIII",
"JJJJ-KKKK-LLLL"
]
}Code Examples
/api/v1/auth/mfa/verify-challengeVerify MFA Challenge▾Completes the MFA challenge step during a login flow. Submit the mfaToken received from a login response (when mfaRequired is true) along with either a TOTP code or a backup code. On success, returns a full session with access and refresh tokens.
Request Body
Response Fields
Response Example
{
"accessToken": "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJ1c3JfMTIzIn0.sig",
"refreshToken": "rt_a1b2c3d4e5f6a1b2c3d4e5f6",
"expiresIn": 900,
"tokenType": "Bearer",
"user": {
"id": "usr_01hy5j8x2k3n4m5p6q7r8s9t",
"email": "alice@example.com",
"firstName": "Alice",
"lastName": "Smith",
"organizationId": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"role": "ADMIN"
},
"organization": {
"id": "org_01hz1a2b3c4d5e6f7g8h9i0j",
"name": "Acme Corp",
"slug": "acme-corp",
"role": "ADMIN"
}
}Code Examples
/api/v1/auth/mfa/backup-codes/regenerateRegenerate Backup CodesBearer Token▾Generates a new set of backup codes for the authenticated user, invalidating all previously issued backup codes. Store the returned codes securely — they cannot be retrieved again.
Response Fields
Response Example
{
"backupCodes": [
"AAAA-BBBB-CCCC",
"DDDD-EEEE-FFFF",
"GGGG-HHHH-IIII",
"JJJJ-KKKK-LLLL",
"MMMM-NNNN-OOOO",
"PPPP-QQQQ-RRRR",
"SSSS-TTTT-UUUU",
"VVVV-WWWW-XXXX"
]
}Code Examples
/api/v1/auth/mfa/disableDisable MFABearer Token▾Disables MFA for the authenticated user. Requires the current account password as confirmation. All enrolled MFA methods will be removed.
Request Body
Response Fields
Response Example
{
"success": true
}Code Examples
/api/v1/auth/mfa/passkey/optionsGet WebAuthn Registration OptionsBearer Token▾Returns the WebAuthn credential creation options (PublicKeyCredentialCreationOptions) needed to register a passkey. Pass the returned options to navigator.credentials.create() in the browser, then submit the attestation response to the Enroll Passkey endpoint.
Response Fields
Response Example
{
"challenge": "dGhpcyBpcyBhIGNoYWxsZW5nZQ==",
"rp": {
"id": "sutraid.com",
"name": "SutraID"
},
"user": {
"id": "dXNyXzAxaHk1ajh4MmszbjRtNXA2cTdyOHM5dA==",
"name": "alice@example.com",
"displayName": "Alice Smith"
},
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -7
},
{
"type": "public-key",
"alg": -257
}
],
"timeout": 60000,
"attestation": "none",
"authenticatorSelection": {
"authenticatorAttachment": "platform",
"requireResidentKey": false,
"userVerification": "preferred"
}
}Code Examples
/api/v1/auth/mfa/passkey/enrollEnroll PasskeyBearer Token▾Completes passkey enrollment by submitting the WebAuthn attestation response from navigator.credentials.create(). The credential object must be the serialized PublicKeyCredential returned by the browser API.
Request Body
Response Fields
Response Example
{
"success": true,
"methodId": "mfa_03cd4ef5g6h7i8j9k0l1m2n"
}Code Examples
/api/v1/auth/mfa/adaptive/toggleToggle Adaptive MFABearer Token▾Enables or disables adaptive MFA for the authenticated user. When enabled, the system uses contextual signals (IP address, device fingerprint, geolocation) to determine whether an MFA challenge is required on each login, rather than always requiring it.
Request Body
Response Fields
Response Example
{
"enabled": true
}