Factors — OTP

Factors

This factor operates by generating a One-Time Password (OTP) on-demand and sending it to the account across some trusted channel, such as email or SMS, but this can also be over chat, voice, etc. The OTP is generated by our service and is typically only valid for a short time as it's meant to be used immediately. Besides the default custom factor we also provide support for following out-of-the-box options:

  • Email - In this setup the OTP is sent to the account over email and you can choose between using our (internal) email provider or your own (external).
  • Phone - In this setup the OTP is sent to the account over SMS and you can choose between using our (internal) SMS provider or your own (external).

Configuration

All OTP factors have following general configuration options:

  • Window (config.window: string) - Time indication how long an OTP remains valid.
  • Storage Mode (config.storage_mode: string) - Selection of the storage mode. Valid values are none, internal and external.
  • Unique OTP (config.unique_otp: boolean) - Only relevant if the factor is configured as unique. When validating a factor by its factor ID rather than a specific enrollment ID (initial login before the enrollment is known), this indicates whether the OTP code itself may be submitted directly against the factor ID. If disabled, only the trigger value (e.g. email or phone) is accepted against the factor ID, in order to look up the matching enrollment and send it a new OTP; the code must then be submitted against that enrollment ID.

In the Login UI the user enters their email address to sign up, after which the OTP is sent to it; at login the OTP is sent to the address of the enrollment, and the user enters it before it expires:

Signing up: the email address to send the OTP to

  1. 1Receiving the OTP proves the user owns this address

Logging in: the code sent to the email address

  1. 1How long the OTP remains valid (Window); failed attempts count towards locking the enrollment

Storage Mode

The storage mode defines how the value, e.g. email or phone number, will be stored. You can choose between following storage modes:

  • None - In this mode the value will not be stored in clear; only hashed. This means that every time an account wants to use this factor they'll have to provide the value in clear. Upon login the value is then compared to the hash and if correct the value will also be included in the OTP event.
  • Internal - In this mode the value will be stored (encrypted) in our platform as claim of an attribute. This requires a source between the factor and the attribute (with claim input), which captures the value and links the claim to the enrollment. Upon login the value is then retrieved through the link, so the user doesn't have to provide it. If there is no linked claim (e.g. because the account deleted it), the value will be requested again.
  • External - In this mode the value will be stored in clear by you in some external system. This means you can't use our internal provider and the value will not be present during login in the OTP event.
  1. 1Turned on automatically with storage mode Internal or External: the email is passed on in a data event, for a source (Internal) or your extension (External)
  2. 2Internal: the email is also kept, encrypted, as claim of an attribute, so an OTP can be sent without the user entering the email again

Provider

The provider defines whether the OTP is sent using our service or using your own and is only available for the standard email or phone OTP factors:

  • Internal - Meaning we'll send out the OTP using our own service. Please note that in this case no OTP event is generated.
  • External - Meaning you'll send out the OTP using your own service. In this case a OTP event is generated and you must create an extension that triggers on this event and sends the details to your service.
  1. 1External: Quasr doesn't send the email itself, your extension on the send-otp event does, e.g. with your own email service and template

The OTP event looks as follows:

{    "type": "COMMUNICATION",    "origin": "{factor_id}",    "action": "send-otp",    "values": {        "input": "{email|phone|channel}",        "otp": "{otp}",        "params": {            "{key}": "{value}"        }    },    "result": "PENDING",    "reason": "DELIVERY_PENDING",    "tenant_id": "{tenant_id}",    "account_id": "{account_id}",    "detail": {        "expires_at": "{otp_expiration_in_iso_format}",        "enrollment_id": "{enrollment_id}",        "enrollment_status": "PENDING|ENABLED"    }}

When triggering the OTP (login) or creating/updating the enrollment (signup), you can include a params object (up to 5 keys, values up to 100 characters) alongside the factor/enrollment input. These values are passed through untouched into the values.params field of the OTP event above, so your extension can use them, for example to select a message template or track a campaign.

Email OTP

We offer an out-of-the-box email OTP factor which allows you to get started quickly.

With our email provider, the code is sent from noreply@quasr.io, in your tenant's color and name:

  1. 1Let your users know, or have their mail admins allow this sender, so codes don't end up in spam
  2. 2The color and label set for your tenant's interfaces, as in the Login UI
  3. 3The factor's Window exactly as entered (e.g. 10m), so pick a value your users can read

Phone OTP

We offer an out-of-the-box phone OTP factor which allows you to get started quickly.

With our SMS provider, the text message gives the code and when it expires:

  1. 1An exact time in UTC (ISO 8601), not a countdown like the email - your users may need to convert it to their own time zone

API

Below are the steps for the factors endpoint of the Authentication API. See Factors — Authentication API for how requests, responses, sessions and the Management API work in general.

Login

1. Send the email address or phone number with the ID of the OTP factor. This sends the OTP and returns the ID of the enrollment:

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioContent-Type: application/json [    {        "id": "{otp_factor_id}",        "input": "jane@example.com"    }]
{    "result": "PENDING",    "feedback": {        "cause": "OTP_PENDING",        "enrollment_id": "{enrollment_id}",        "expires_at": "2026-11-06T10:10:00.000Z",        "regex": "^[A-Z0-9]{6}$"    }}

2. Send the OTP with the ID of the enrollment (and the session token, if any):

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioContent-Type: application/json [    {        "id": "{enrollment_id}",        "input": "A1B2C3"    }]
{    "result": "SUCCESS",    "feedback": {        "cause": "",        "enrollment_id": "{enrollment_id}"    },    "account_id": "{account_id}",    "session_token": "{session_token}",    "session_score": 2,    "session_exp": 1767225600}

A wrong, expired or already used OTP returns FAILED with cause INCORRECT_INPUT.

Signup

1. With the signup session token, send the email address or phone number with the ID of the OTP factor. This creates a pending enrollment and sends the OTP:

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioAuthorization: Bearer {signup_session_token}Content-Type: application/json [    {        "id": "{otp_factor_id}",        "input": "jane@example.com"    }]
{    "result": "PENDING",    "feedback": {        "cause": "ENROLLMENT_PENDING",        "enrollment_id": "{enrollment_id}",        "expires_at": "2026-11-06T10:10:00.000Z",        "regex": "^[A-Z0-9]{6}$"    }}

2. Send the OTP with the ID of the enrollment, which completes the enrollment:

POST /factors HTTP/1.1Host: {tenant_id}.api.quasr.ioAuthorization: Bearer {signup_session_token}Content-Type: application/json [    {        "id": "{enrollment_id}",        "input": "A1B2C3"    }]
Management API

A signed-in user adds an email address with createEnrollment, which sends an OTP and returns a pending enrollment, and completes it with updateEnrollment. Calling updateEnrollment without input sends a new OTP.

mutation {    createEnrollment(input: {        account: "{account_id}",        factor: "{otp_factor_id}",        subtype: "otp:email",        input: "jane@example.com",        status: ENABLED    }) {        id        status    }} mutation {    updateEnrollment(input: {        id: "{enrollment_id}",        input: "A1B2C3"    }) {        id        status    }}
2026.11.22 | © Copyright 2026 Quasr BV