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

# Sample Use Cases: Actions with Passwordless Authentication

> Learn how to use Actions to customize passwordless authentication flows, including routing SMS and email OTPs through custom providers.

With [Actions](/docs/docs/customize/actions/actions-overview), you can extend [passwordless connections](/docs/docs/authenticate/passwordless) by routing SMS and email OTP delivery through custom providers. Auth0 Actions give you control over which phone and email services handle your authentication messages.

## Send passwordless email with a custom email provider

When a user [authenticates through a passwordless email connection](/docs/docs/authenticate/passwordless/authentication-methods/email-otp), Auth0 triggers the `custom-email-provider` Action to deliver the OTP. Use this Action to route messages through any email service.

To configure the Action, navigate to [**Branding > Email Provider**](https://manage.auth0.com/#/templates/provider) and toggle on Use my own email provider, then select the **Custom Provider** option. Add the default address from your custom provider in the From field. To learn more, read [Configure an Email Provider with a Customized Action](/docs/docs/customize/email/smtp-email-providers/custom/configure-action).

In the Actions editor, use the following example.

You need to add your email provider's service endpoint to the Actions code and API key in the Secrets tab of the Actions editor.

```javascript lines theme={null}
/**
 * Handler called when Auth0 needs to deliver a passwordless email OTP.
 * @param {Event} event - Details about the notification.
 * @param {CustomEmailProviderAPI} api - Methods for controlling notification behavior.
 */
exports.onExecuteCustomEmailProvider = async (event, api) => {
  try {
    const response = await fetch('https://api.example.com/send-email', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${event.secrets.API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        to: event.notification.to,
        from: event.notification.from,
        subject: event.notification.subject,
        html: event.notification.html,
        text: event.notification.text,
      }),
    });

    if (response.status >= 400) {
      api.notification.retry(`Request failed with status: ${response.status}`);
      return;
    }
  } catch (error) {
    api.notification.drop(`Unexpected error: ${error.message}`);
  }
};
```

Choose **Send Test Email** to test your configuration.

To learn more about available event properties, read [Actions Triggers: custom-email-provider - Event Object](/docs/docs/customize/email/smtp-email-providers/custom/action-triggers-custom-email-provider-event-object).

## Send passwordless SMS with a custom phone provider

When a user [authenticates through a passwordless SMS connection](/docs/docs/authenticate/passwordless/authentication-methods/sms-otp), Auth0 triggers the `custom-phone-provider` Action to deliver the OTP. Use this Action to route messages through any SMS provider.

To configure the Action, navigate to [**Branding > Phone Provider**](https://manage.auth0.com/dashboard/#/phone/templates/phone/provider). Toggle on Phone Message Provider and select the **Custom** option. Determine your delivery method to be Text, Voice, or both. To learn more, read [Configure a Custom Phone Provider](/docs/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider).

In the Actions editor, use the following example.

You need to add your phone provider's service endpoint to the Actions code and API key in the Secrets tab of the Actions editor.

```javascript lines theme={null}
/**
 * Handler called when Auth0 needs to deliver a passwordless SMS OTP.
 * @param {Event} event - Details about the notification.
 * @param {CustomPhoneProviderAPI} api - Methods for controlling notification behavior.
 */
exports.onExecuteCustomPhoneProvider = async (event, api) => {
  const response = await fetch('https://api.example.com/messages', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${event.secrets.API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      to: event.notification.recipient,
      from: event.notification.from,
      body: event.notification.as_text,
    }),
  });

  if (response.status >= 400) {
    api.notification.retry(`Request failed with status: ${response.status}`);
  }
};
```

Choose **Send Text Message** to test your configuration.

To learn more about available event properties, read [Actions Triggers: custom-phone-provider - Event Object](/docs/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider/actions-triggers-custom-phone-provider-event-object).

## Learn more

* [Configure an Email Provider with a Customized Action](/docs/docs/customize/email/smtp-email-providers/custom/configure-action)
* [Configure a Custom Phone Provider](/docs/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider)
* [Configure a Custom Phone Provider with Twilio Verify](/docs/docs/customize/phone-messages/configure-phone-messaging-providers/configure-a-custom-phone-provider/configure-a-custom-phone-provider-with-twilio-verify)
* [Set Up Custom SMS Gateway for Passwordless Connections](/docs/docs/authenticate/passwordless/authentication-methods/use-sms-gateway-passwordless)
* [Use the Unified Phone Experience for Passwordless](/docs/docs/customize/phone-messages/unified-phone/unified-phone-experience-passwordless)
* [Passwordless Connections Best Practices](/docs/docs/authenticate/passwordless/best-practices)
