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:
All OTP factors have following general configuration options:
config.window: string) - Time indication how long an OTP remains valid.config.storage_mode: string) - Selection of the storage mode. Valid values are none, internal and external.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
Logging in: the code sent to the email address
The storage mode defines how the value, e.g. email or phone number, will be stored. You can choose between following storage modes:
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.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:
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.
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:
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:
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.
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.
OTP_PENDING); otherwise the response is pending with cause INPUT_REQUIRED, and you first send the email address or phone number with the ID of the enrollment.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" }]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 }}