Overview
Creates a new passwordless authentication code for a user. You must provide exactly one of:email, phoneNumber, or deviceId.
Request Body
Provide exactly one of the following:email(string, optional): Email address to send the code tophoneNumber(string, optional): Phone number to send the code todeviceId(string, optional): Existing device ID to create a new code for (resend scenario)userInputCode(string, optional): Custom code to use instead of generating one
Response
Success Response (200)
preAuthSessionId: Unique session identifier (hashed device ID)codeId: Unique identifier for this specific codedeviceId: Device identifier for this authentication attemptuserInputCode: The short code for the user to enterlinkCode: Code for magic link authenticationtimeCreated: Unix timestamp when code was createdcodeLifetime: Code validity duration in milliseconds
Error Responses
RESTART_FLOW_ERROR (200)
The device ID is invalid or expired. Start a new authentication flow.USER_INPUT_CODE_ALREADY_USED_ERROR (200)
The provided customuserInputCode is already in use.
Examples
Create code for email
Create code for phone number
Resend code (create new code for existing device)
Notes
- Email addresses are automatically normalized
- Phone numbers should include country code (e.g., +1234567890)
- Codes typically expire after 15 minutes (900000ms)
- You cannot provide more than one of: email, phoneNumber, or deviceId
- If
userInputCodeis provided, it cannot be an empty string