{ "status_code": 400, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "invalid_user_id", "error_message": "user_id format is invalid.", "error_url": "https://stytch.com/docs/api/errors/400"}
{ "status_code": 404, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "user_not_found", "error_message": "User could not be found.", "error_url": "https://stytch.com/docs/api/errors/404"}
{ "status_code": 429, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "too_many_requests", "error_message": "Too many requests have been made.", "error_url": "https://stytch.com/docs/api/errors/429"}
{ "status_code": 500, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "internal_server_error", "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.", "error_url": "https://stytch.com/docs/api/errors/500"}
import { StytchClient } from '@stytch/vanilla-js';const stytch = new StytchClient('${publicToken}');export const create = () => {stytch.totps.create({ expiration_minutes: 60 });};
{ "status_code": 400, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "invalid_user_id", "error_message": "user_id format is invalid.", "error_url": "https://stytch.com/docs/api/errors/400"}
{ "status_code": 404, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "user_not_found", "error_message": "User could not be found.", "error_url": "https://stytch.com/docs/api/errors/404"}
{ "status_code": 429, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "too_many_requests", "error_message": "Too many requests have been made.", "error_url": "https://stytch.com/docs/api/errors/429"}
{ "status_code": 500, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "internal_server_error", "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.", "error_url": "https://stytch.com/docs/api/errors/500"}
Time-Based One-Time Passcodes (TOTPs)
Create
Create a TOTP instance using the Stytch Vanilla JS SDK
import { StytchClient } from '@stytch/vanilla-js';const stytch = new StytchClient('${publicToken}');export const create = () => {stytch.totps.create({ expiration_minutes: 60 });};
{ "status_code": 400, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "invalid_user_id", "error_message": "user_id format is invalid.", "error_url": "https://stytch.com/docs/api/errors/400"}
{ "status_code": 404, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "user_not_found", "error_message": "User could not be found.", "error_url": "https://stytch.com/docs/api/errors/404"}
{ "status_code": 429, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "too_many_requests", "error_message": "Too many requests have been made.", "error_url": "https://stytch.com/docs/api/errors/429"}
{ "status_code": 500, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "internal_server_error", "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.", "error_url": "https://stytch.com/docs/api/errors/500"}
import { StytchClient } from '@stytch/vanilla-js';const stytch = new StytchClient('${publicToken}');export const create = () => {stytch.totps.create({ expiration_minutes: 60 });};
{ "status_code": 400, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "invalid_user_id", "error_message": "user_id format is invalid.", "error_url": "https://stytch.com/docs/api/errors/400"}
{ "status_code": 404, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "user_not_found", "error_message": "User could not be found.", "error_url": "https://stytch.com/docs/api/errors/404"}
{ "status_code": 429, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "too_many_requests", "error_message": "Too many requests have been made.", "error_url": "https://stytch.com/docs/api/errors/429"}
{ "status_code": 500, "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141", "error_type": "internal_server_error", "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.", "error_url": "https://stytch.com/docs/api/errors/500"}
Wraps the Create TOTP endpoint. Call this method to create a new TOTP instance for a user. The user can use the authenticator application of their choice to scan the returned QR code or enter the returned secret.
If a user has enrolled another MFA method, this method will require MFA. See the Multi-factor Authentication section for more details.
Parameters
int
The expiration for the TOTP instance. If the newly created TOTP is not authenticated within this time frame the TOTP will be unusable. Defaults to 1440 (1 day) with a minimum of 5 and a maximum of 1440.
Response
string
The unique ID for a TOTP instance.
string
The TOTP secret key shared between the authenticator app and the server used to generate TOTP codes.
string
The QR code image encoded in base64.
array[strings]
The recovery codes used to authenticate the user without an authenticator app.
string
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we
may ask for this value to help identify a specific API call when helping you debug an issue.
number
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values
equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
string
The unique ID of the affected User.
object
The user object affected by call. See the User object for complete response field details.
Show properties
string
The timestamp of the User’s creation. Values conform to the RFC 3339 standard and are expressed in UTC, e.g. 2021-12-29T12:33:09Z.
array[objects]
An array contains a list of all crypto wallets for a given User in the Stytch API.
Show properties
string
The unique ID for a crypto wallet
string
The actual blockchain address of the User’s crypto wallet.
string
The blockchain that the User’s crypto wallet operates on, e.g. Ethereum, Solana, etc.
boolean
If this method has been successfully authenticated by the User.
array[objects]
An array of email objects for the User.
Show properties
string
The unique ID of a specific email address.
string
The email address.
boolean
If this method has been successfully authenticated by the User.
object
The name of the User. Each field in the name object is optional.
Show properties
string
The first name of the user.
string
The middle name(s) of the user.
string
The last name of the user.
object
The trusted_metadata field contains an arbitrary JSON object of application-specific data. See the Metadata reference for complete field behavior details.
object
The untrusted_metadata field contains an arbitrary JSON object of application-specific data. Untrusted metadata can be edited by end users directly via the SDK, and cannot be used to store critical information. See the Metadata reference for complete field behavior details.
array[objects]
An array of phone number objects linked to the User.
Show properties
string
The unique ID for the phone number.
string
The phone number.
boolean
If this method has been successfully authenticated by the User.
array[objects]
An array of OAuth provider objects linked to the User.
Show properties
string
The unique ID for an OAuth registration.
string
The unique identifier for the User within a given OAuth provider. Also commonly called the “sub” or “Subject field” in OAuth protocols.
string
Denotes the OAuth identity provider that the user has authenticated with, e.g. Google, Facebook, GitHub etc.
string
If available, the profile_picture_url is a url of the User’s profile picture set in OAuth identity the provider that the User has authenticated with, e.g. Facebook profile picture.
string
If available, the locale is the User’s locale set in the OAuth identity provider that the user has authenticated with.
object
The password object is returned for users with a password.
Show properties
string
The unique ID of a specific password
boolean
Indicates whether this password requires a password reset
string
The status of the User. The possible values are pending and active.
array[objects]
An array containing a list of all TOTP instances for a given User in the Stytch API.
Show properties
string
The unique ID for a TOTP instance.
boolean
If this method has been successfully authenticated by the User.
string
The unique ID of the affected User.
array[objects]
An array that contains a list of all Passkey or WebAuthn registrations for a given User in the Stytch API.
Show properties
string
The unique ID for the Passkey or WebAuthn registration.
string
The domain on which Passkey or WebAuthn registration was started. This will be the domain of your app.
string
The user agent of the User.
string
The authenticator_type string displays the requested authenticator type of the Passkey or WebAuthn device. The two valid types are “platform” and “cross-platform”. If no value is present, the Passkey or WebAuthn device was created without an authenticator type preference.
boolean
If this method has been successfully authenticated by the User.
string
The name of the Passkey or WebAuthn registration.
array[objects]
An array that contains a list of all biometric registrations for a given User in the Stytch API.
Show properties
string
The unique ID for a biometric registration.
boolean
If this method has been successfully authenticated by the User.
array[strings]
Roles assigned to this User. See the RBAC guide for more information about role assignment.
Assistant
Responses are generated using AI and may contain mistakes.