Skip to main content

Protekt Authentication API (1.0.0)

Download OpenAPI specification:Download

The Authentication API handles all end-user identity operations for applications built on Protekt. You can perform signup, login, passwordless flows, SSO, MFA, and session management. All requests require a project API key via the X-Protekt-Key header.

Auth

Email/password signup, login, and logout

Sign up a new user

Register a new user with email and password. Protekt hashes and stores credentials internally. Optionally triggers an email verification flow.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
required
string <email>
password
required
string <password> >= 8 characters
object

Arbitrary key-value pairs stored alongside the user profile

send_verification
boolean

If true, sends an email verification link. Defaults to project setting.

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "password": "pa$$word",
  • "metadata": { },
  • "send_verification": true
}

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGci...",
  • "refresh_token": "rt_xYz...",
  • "expires_in": 3600,
  • "token_type": "Bearer",
  • "user": {
    }
}

Log in a user

Authenticate a user with email and password. Returns a signed JWT and refresh token on success. If MFA is required, returns a mfa_required challenge response instead of tokens.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
required
string <email>
password
required
string <password>

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "password": "pa$$word"
}

Response samples

Content type
application/json
Example
{
  • "access_token": "eyJhbGci...",
  • "refresh_token": "rt_xYz...",
  • "expires_in": 3600,
  • "token_type": "Bearer",
  • "user": {
    }
}

Log out a user

End a user session by revoking the current access token and its associated refresh token.

Authorizations:
ApiKeyUserToken

Responses

Response samples

Content type
application/json
{
  • "logged_out": true
}

Tokens

JWT refresh, verification, and revocation

Refresh an access token

Obtain a new access token using a valid refresh token. The old refresh token is rotated and invalidated on each successful call.

Authorizations:
ApiKey
Request Body schema: application/json
required
refresh_token
required
string

Responses

Request samples

Content type
application/json
{
  • "refresh_token": "rt_xYz..."
}

Response samples

Content type
application/json
{
  • "access_token": "string",
  • "refresh_token": "string",
  • "expires_in": 3600
}

Verify an access token

Validate an access token and return its decoded claims. Use this on your backend to confirm a user is authenticated before granting access to protected resources.

Authorizations:
ApiKey
Request Body schema: application/json
required
token
required
string

The JWT access token to verify

Responses

Request samples

Content type
application/json
{
  • "token": "string"
}

Response samples

Content type
application/json
{
  • "valid": true,
  • "claims": {
    }
}

Revoke a token

Immediately invalidate a specific access or refresh token without ending the entire session.

Authorizations:
ApiKey
Request Body schema: application/json
required
token
required
string

The token to revoke

Responses

Request samples

Content type
application/json
{
  • "token": "string"
}

Response samples

Content type
application/json
{
  • "revoked": true
}

Passwords

Password reset, confirmation, and change

Request a password reset

Trigger a password reset email. Protekt sends a one-time reset link to the user's registered email, expiring after 15 minutes. Always returns 200 OK regardless of whether the email exists, to prevent user enumeration attacks.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
required
string <email>

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com"
}

Response samples

Content type
application/json
{
  • "message": "If that email is registered, a reset link has been sent."
}

Confirm a password reset

Complete the password reset flow by submitting the reset token (from the email link) and the new password.

Authorizations:
ApiKey
Request Body schema: application/json
required
reset_token
required
string

One-time reset token from the email link

new_password
required
string <password> >= 8 characters

Responses

Request samples

Content type
application/json
{
  • "reset_token": "string",
  • "new_password": "pa$$word"
}

Response samples

Content type
application/json
{
  • "message": "Password has been reset successfully."
}

Change password (authenticated)

Allow an authenticated user to change their own password by providing their current password and the desired new password.

Authorizations:
ApiKeyUserToken
Request Body schema: application/json
required
current_password
required
string <password>
new_password
required
string <password> >= 8 characters

Responses

Request samples

Content type
application/json
{
  • "current_password": "pa$$word",
  • "new_password": "pa$$word"
}

Response samples

Content type
application/json
{
  • "message": "Password changed successfully."
}

OTP

One-time passcode (passwordless) flows

Send an OTP

Send a one-time passcode to a user's email or phone for passwordless authentication or as a second factor. OTPs expire after 10 minutes.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
string <email>

Required if phone is not provided

phone
string

E.164 format. Required if email is not provided

channel
string
Default: "email"
Enum: "email" "sms"

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "phone": "+2348012345678",
  • "channel": "email"
}

Response samples

Content type
application/json
{
  • "message": "OTP sent",
  • "expires_in": 600
}

Verify an OTP

Verify an OTP code sent via POST /auth/otp/send. Returns a JWT and refresh token on success.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
string <email>

Required if OTP was sent to an email

phone
string

Required if OTP was sent to a phone number

otp
required
string

The 6-digit OTP

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "phone": "string",
  • "otp": "482910"
}

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGci...",
  • "refresh_token": "rt_xYz...",
  • "expires_in": 3600,
  • "token_type": "Bearer",
  • "user": {
    }
}

Send a magic link

Send a magic link to the user's email. When clicked, the link authenticates the user without a password. The link expires after 15 minutes and is single-use.

Authorizations:
ApiKey
Request Body schema: application/json
required
email
required
string <email>
redirect_url
string <uri>

Override the project's default redirect URL for this request

Responses

Request samples

Content type
application/json
{}

Response samples

Content type
application/json
{
  • "message": "Magic link sent",
  • "expires_in": 900
}

Verify a magic link token

Verify a magic link token extracted from the URL after the user clicks the emailed link. Returns a JWT and refresh token on success.

Authorizations:
ApiKey
Request Body schema: application/json
required
token
required
string

The magic link token from the email URL parameter

Responses

Request samples

Content type
application/json
{
  • "token": "string"
}

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGci...",
  • "refresh_token": "rt_xYz...",
  • "expires_in": 3600,
  • "token_type": "Bearer",
  • "user": {
    }
}

SSO

Single Sign-On (OIDC / SAML) flows

Initiate an SSO login

Initiate an SSO login flow. Redirects the user to their configured identity provider (IdP). Supports OIDC and SAML 2.0 providers configured in the Protekt Dashboard.

Authorizations:
ApiKey
query Parameters
provider
required
string
Example: provider=google

The SSO provider slug (for example, google, okta, azure-ad)

redirect_url
string <uri>

Override the post-login redirect URL for this request

state
string

Opaque string passed back in the callback for CSRF protection

Responses

Response samples

Content type
application/json
{
  • "error": {
    }
}

SSO callback

The redirect target for the SSO provider after authentication. Protekt exchanges the authorization code for a session and redirects with tokens. Register https://auth.protekt.io/v1/auth/sso/callback as the callback URL in your IdP configuration.

Authorizations:
ApiKey
query Parameters
code
required
string

Authorization code from the IdP

state
string

The state value originally passed to /auth/sso/authorize

Responses

MFA

Multi-factor authentication enrollment and verification

Enroll in MFA

Begin enrolling a user in MFA. Enrollment is not finalized until the user verifies a code via POST /auth/mfa/verify.

Authorizations:
ApiKeyUserToken
Request Body schema: application/json
required
method
required
string
Enum: "totp" "sms"
phone
string

E.164 phone number. Required when method is sms.

Responses

Request samples

Content type
application/json
{
  • "method": "totp",
  • "phone": "string"
}

Response samples

Content type
application/json
{
  • "method": "totp",
  • "totp_uri": "otpauth://totp/Protekt:user@example.com?secret=BASE32SECRET&issuer=Protekt",
  • "qr_code": "data:image/png;base64,..."
}

Verify an MFA code

Verify an MFA code. Used both to finalize MFA enrollment and to complete a login challenge. On a successful login challenge, returns a full JWT session.

Authorizations:
ApiKey
Request Body schema: application/json
required
mfa_token
string

Temporary MFA challenge token from POST /auth/login. Required during login.

code
required
string

The 6-digit TOTP or SMS code

Responses

Request samples

Content type
application/json
{
  • "mfa_token": "mfa_tmp_abc...",
  • "code": "482910"
}

Response samples

Content type
application/json
{
  • "access_token": "eyJhbGci...",
  • "refresh_token": "rt_xYz...",
  • "expires_in": 3600,
  • "token_type": "Bearer",
  • "user": {
    }
}

Remove an MFA method

Remove an MFA method from a user's account. Requires a valid user access token. Returns 403 if the project enforces MFA (mfa_required: true).

Authorizations:
ApiKeyUserToken
Request Body schema: application/json
required
method
required
string
Enum: "totp" "sms"

Responses

Request samples

Content type
application/json
{
  • "method": "totp"
}

Response samples

Content type
application/json
{
  • "unenrolled": true
}

Users

User profile management

List users

List all users registered within a project. Intended for admin/backend use. Requires an API key with users:read scope.

Authorizations:
ApiKey
query Parameters
limit
integer <= 100
Default: 20

Max number of results per page

cursor
string

Pagination cursor from the previous response

search
string

Filter by email (partial match)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "next_cursor": "cur_abc123",
  • "has_more": true
}

Get a user

Retrieve a user's full profile by ID, including metadata, MFA status, and account state.

Authorizations:
ApiKey
path Parameters
id
required
string

The unique user ID (for example, usr_9klabc)

Responses

Response samples

Content type
application/json
{
  • "id": "usr_9klabc",
  • "email": "user@example.com",
  • "email_verified": true,
  • "mfa_enabled": true,
  • "mfa_methods": [
    ],
  • "metadata": { },
  • "disabled": true,
  • "created_at": "2019-08-24T14:15:22Z",
  • "last_login_at": "2019-08-24T14:15:22Z"
}

Update a user

Update a user's profile or metadata. Admins can update any user; users can update their own profile via their access token.

Authorizations:
ApiKeyUserToken
path Parameters
id
required
string

The unique user ID (for example, usr_9klabc)

Request Body schema: application/json
required
email
string <email>

New email address. Triggers a re-verification email.

object

Merged (not replaced) into existing metadata

disabled
boolean

Set to true to lock the account. Admin only.

Responses

Request samples

Content type
application/json
{
  • "email": "user@example.com",
  • "metadata": { },
  • "disabled": true
}

Response samples

Content type
application/json
{
  • "id": "usr_9klabc",
  • "email": "user@example.com",
  • "email_verified": true,
  • "mfa_enabled": true,
  • "mfa_methods": [
    ],
  • "metadata": { },
  • "disabled": true,
  • "created_at": "2019-08-24T14:15:22Z",
  • "last_login_at": "2019-08-24T14:15:22Z"
}

Delete a user

Permanently delete a user and all their sessions, tokens, and stored data from the project. This is irreversible.

Authorizations:
ApiKey
path Parameters
id
required
string

The unique user ID (for example, usr_9klabc)

Responses

Response samples

Content type
application/json
{
  • "deleted": true,
  • "id": "usr_9klabc"
}

Sessions

Session listing and revocation

List active sessions

List all active sessions for the currently authenticated user, including device, IP address, and last active time.

Authorizations:
ApiKeyUserToken

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Revoke all sessions

Revoke all active sessions for the current user — "sign out everywhere". The current session is also terminated unless keep_current is true.

Authorizations:
ApiKeyUserToken
Request Body schema: application/json
keep_current
boolean
Default: false

If true, the current session is preserved

Responses

Request samples

Content type
application/json
{
  • "keep_current": false
}

Response samples

Content type
application/json
{
  • "revoked_count": 4
}

Revoke a session

Terminate a specific session by ID. Useful for "sign out this device" functionality.

Authorizations:
ApiKeyUserToken
path Parameters
id
required
string

The unique session ID (for example, sess_kl8abc)

Responses

Response samples

Content type
application/json
{
  • "revoked": true,
  • "session_id": "sess_kl8abc"
}