# Get email notifications on login (api.sendEmail in action)

**URL:** <https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [November 17, 2025, 10:48am UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577 "2025-11-17T10:48:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![axel-insightsphere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/axel-insightsphere/32/72947_2.png) [@axel-insightsphere](https://community.auth0.com/u/axel-insightsphere)\
**Post date:** [November 17, 2025, 10:48am UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577/1 "2025-11-17T10:48:58Z")

</div>

Hello, we’re using a custom action to get an email when user log into the app through auth0 however it stopped working since old runtime were deprecated apparently. We tried to upgrade this code:

```javascript
exports.onExecutePostUserRegistration = async (event, api) => {
  const adminEmail = "info@example.com";
  const userEmail = event.user.email;

  try {
    // Use Auth0's built-in email provider to send an email
    await api.sendEmail({
      to: adminEmail,
      template: {
        subject: "New User Registration",
        body: `A new user has registered with the email: ${userEmail}`,
      },
    });
  } catch (error) {
  if (error instanceof Error) {
    console.error("Error sending admin email:", error.message);
  } else {
    console.error("An unknown error occurred.");
  }
}
};

```

However it now fails, as shown in action real-time logs:

`10:36:39: Error sending admin email: api.sendEmail is not a function`

We wish to be informed of any login in the app: is there an easy way to do this now? Or is there a new way to replace `api.sendEmail` with the same features? Help appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [November 17, 2025, 1:54pm UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577/3 "2025-11-17T13:54:17Z")

</div>

Hi @axel-insightsphere,

The error `api.sendEmail is not a function` occurs because Auth0 Actions do not have a built-in method to send emails. The `api` object in Actions is strictly for manipulating the authentication transaction (like denying access or adding claims).

To send an email (like an admin notification), you must use an **external email provider** (such as SendGrid, AWS SES, or Mailgun) and call their API from within your Action.

Additionally, your code snippet uses `onExecutePostUserRegistration`, which runs only once when a user first creates an account. Still, you’re stating that you want to be “informed of any login.”, which means you will need to use the **Post Login** trigger instead.

This other community post provides an example code snippet that can help.

> [@Send email from Actions](https://community.auth0.com/t/send-email-from-actions/105756/3):
>
> Hi @jeanbaptiste.marie, Welcome to the Auth0 Community! I understand that you are trying to send a password reset email to a user whenever they log in and have not changed their password for a given time. For this, I recommend using a Post-Login Action with the Authentication API, specifically calling the [POST /dbconnections/change\_password endpoint](https://auth0.com/docs/api/authentication#change-password). I have written a code snippet below to make an Axios request to the Change Password endpoint. From here, you will need to write the code to com…

If you have any further questions, please don’t hesitate to reach out.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![axel-insightsphere](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/axel-insightsphere/32/72947_2.png) [@axel-insightsphere](https://community.auth0.com/u/axel-insightsphere)\
**Post date:** [November 17, 2025, 3:31pm UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577/4 "2025-11-17T15:31:04Z")

</div>

Hello Vlad. Thank you for your answer. Are there any alternative? For example (a) where we could receive a notification in auth0 dashboard, by using that `api` object or something else or (b) consult the creation of accounts somewhere? It looks like monitoring \> logs only keep for last 24h which is not useful, apparently it’s depending on the plan we’re at (we want to know account creation even if \>30 days). Do you have simpler suggestions than external email provider? alerts/notifs in auth0 would be great. Thank you.

You’re correct, I meant only for new registration actually.

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [November 17, 2025, 6:17pm UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577/5 "2025-11-17T18:17:24Z")

</div>

Hi @axel-insightsphere,

The Auth0 Dashboard does not have a built-in “Notification Center” or “Inbox” that can be triggered by the `api` object in Actions. However, you can view user accounts indefinitely (beyond the log retention limit) using the **User Management** view. For alerts, you can access Monitoring \> Log Streams and create a Log Stream. A **Webhook** (to Slack or Teams) is often the simplest alternative to email.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 1, 2025, 6:17pm UTC](https://community.auth0.com/t/get-email-notifications-on-login-api-sendemail-in-action/194577/6 "2025-12-01T18:17:26Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
