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.
If you have any further questions, please don’t hesitate to reach out.
Have a good one,
Vlad