> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Passwordless APIs

> Describes how to implement Passwordless authentication using Auth0 APIs.

Passwordless (Passwordless: Form of authentication that does not rely on a password as the first factor.) APIs can be used in two scenarios:

* When implementing Universal Login (Universal Login: Your application redirects to Universal Login, hosted on Auth0's Authorization Server, to verify a user's identity.) and you want to customize the login page using auth0.js to interact with Auth0.
* When you want to embed the login flow in your application.

To learn more about how to implement Passwordless for Universal Login and Embedded login for different scenarios, read [Passwordless Authentication with Universal Login](/docs/docs/authenticate/passwordless/implement-login/universal-login) or [Passwordless Authentication with Embedded Login](/docs/docs/authenticate/passwordless/implement-login/embedded-login).

## Passwordless endpoints

### POST /passwordless/start

You must enable the **Passwordless OTP** grant at [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications) in your application's settings under **Advanced Settings** > **Grant Types**.

The [POST /passwordless/start](/docs/docs/api/authentication#get-code-or-link) endpoint can be called to begin the Passwordless authentication process for both Classic Login and Embedded Login.

Depending on the parameters provided to the endpoint, Auth0 begins the user verification process by sending one of the following:

* A single-use code via email or SMS message
* A single-use link via email

The API call must have the following structure:

If you use a magic link, users will receive a link generated by the Authentication API. Users will select the link and trigger a call to \{`yourAuth0Tenant}.auth0.com/passwordless/verify-redirect`. Auth0 will redirect the user to the application, and the user will be logged in.

If you use a code, your application will need to prompt for that code, and then you should use the `/oauth/token` endpoint, or the `passwordlessLogin` method in the Auth0.js SDK to exchange that code for authentication tokens.

### POST /oauth/token

If you are implementing passwordless for Native Applications or Regular Web Applications, you need to use `/oauth/token` to exchange the OTP code for authentication tokens. You cannot use this endpoint from Single Page Applications.

To achieve this you first need to enable the **Passwordless OTP** grant for your application at [Auth0 Dashboard > Applications > Applications](https://manage.auth0.com/#/applications) in your application's settings under **Advanced Settings** > **Grant Types**.

The user will receive the OTP code and your Native or Web application will prompt the user for it. When the user enters the code, you can complete the authentication flow by calling the `/oauth/token` endpoint with the following parameters:

If all goes well, Auth0 will return a response similar to the following:

```json lines theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
{
"access_token":"eyJz93a...k4laUWw",
"refresh_token":"GEbRxBN...edjnXbL",
"id_token":"eyJ0XAi...4faeEoQ",
"token_type":"Bearer",
"expires_in":86400
}
```

You can then decode the ID Token (ID Token: Credential meant for the client itself, rather than for accessing a resource.) to get information about the user, or use the Access Token (Access Token: Authorization credential, in the form of an opaque string or JWT, used to access an API.) to call your API as normal.

## Using Auth0.js

When implementing Passwordless Authentication in Single Page Applications or in a customized Universal Login page, you should [use Auth0.js and the included passwordlessLogin method](/docs/docs/libraries/auth0js). The implementation is complex, so we recommend that you use the library instead of calling the APIs directly.

## Rate limiting in passwordless endpoints

Auth0 rate limits and attack protection (Attack Protection: Features that Auth0 provides to detect and mitigate attacks, including brute-force protection, suspicious IP throttling, breached password detection, bot detection, and adaptive multi-factor authentication.) features only consider the IP from the machine that is making the API call. When the API call is made from a backend server, you usually want Auth0 to consider the IP from the end user, not the one from the server.

Auth0 supports specifying an `auth0-forwarded-for` header in API calls, but it is only considered when:

* the API call is made for a confidential application.
* the API call authenticates with either the client secret (Client Secret: Secret used by a client (application) to authenticate with the Authorization Server; it should be known to only the client and the Authorization Server and must be sufficiently random to not be guessable.) or a Private Key JWT.
* the **Trust Token Endpoint (Token Endpoint: Endpoint on the Authorization Server that is used to programmatically request tokens.) IP Header** toggle is on.

For a complete explanation, read [Avoid Common Issues with Resource Owner Password Flow and Attack Protection](/docs/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow/avoid-common-issues-with-resource-owner-password-flow-and-attack-protection).

## Customize MFA

> [!WARNING]
>
> **The Customizable MFA with the Resource Owner Password Grant, Embedded, or Refresh Token flows feature is in [Early Access](/docs/docs/troubleshoot/product-lifecycle/product-release-stages).**
>
> By using this feature, you agree to the applicable Free Trial terms in Okta's [Master Subscription Agreement](https://www.okta.com/legal).

Customize MFA (Multi-factor authentication (MFA): User authentication process that uses a factor in addition to username and password such as a code via SMS.) with the Passwordless API. When your application calls `/oauth/token` endpoint to request an access token, the authorization server (Authorization Server: Centralized server that contributes to defining the boundaries of a user’s access. For example, your authorization server can control the data, tasks, and features available to a user.) returns an `mfa_required` error which provides:

* The `mfa_token` you need to call the MFA API for enrollment and challenges.

* The `mfa_requirements` parameter, which provides the factor `type` your application supports for challenges.

```json lines theme={null}
{
  "error": "mfa_required",
  "error_description": "Multifactor authentication required",
  "mfa_token": "Fe26...Ha",
  "mfa_requirements": {
    "challenge": [
      { "type": "otp" },
      { "type": "push-notification" },
      { "type": "phone" },
      { "type": "recovery-code" }
    ]
  }
}
```

Use the `mfa_token` to call the [`mfa/authenticator`](/docs/docs/api/authentication/multi-factor-authentication/list-authenticators) endpoint to list all factors the user has enrolled and match the same `type` your application supports. You also need to obtain the matching `authenticator_type` to issue challenges:

```json lines theme={null}
[
  {
    "type": "recovery-code",
    "id": "recovery-code|dev_qpOkGUOxBpw6R16t",
    "authenticator_type": "recovery-code",
    "active": true
  },
  {
    "type": "otp",
    "id": "totp|dev_6NWz8awwC8brh2dN",
    "authenticator_type": "otp",
    "active": true
  }
]
```

Enforce the MFA challenge by calling the [`request/mfa/challenge`](/docs/docs/api/authentication/multi-factor-authentication/request-mfa-challenge) endpoint.

Further customize your MFA flow with Auth0 Actions. To learn more, read [Actions Triggers: post-challenge - API Object](/docs/docs/actions/reference/password-reset-post-challenge/password-reset-post-challenge-api-object).
