What you will build
Prerequisites
- An Auth0 tenant with a Database or Passwordless connection
- A published to send
How this differs from a webhook
Clerk and Stripe post to a route you host, so you verify a signature and run your own code. Auth0 Actions are your code, running inside Auth0. Three consequences follow. No route, no signature, no tunnel. There is nothing public to host and nothing to verify, because nothing crossed the internet to reach you. Local development needs nongrok.
Secrets live in the Action. Auth0 stores them and exposes them as event.secrets, so your Courier key never sits in your app’s environment.
It is non-blocking, and that cuts both ways. Auth0 does not wait for the Action to finish, so a slow or failing Action never blocks a signup. It also means a failure is invisible unless you look. Auth0’s own logs are where you find it.
Set it up
1
Create the Action
In the Auth0 Dashboard, go to Actions → Library, select Build Custom, and create an Action on the Post User Registration trigger.
2
Add the SDK and your key
In the Action editor, open the Dependencies panel in the left sidebar and add
@trycourier/courier. Actions install npm packages into the runtime, so the works here exactly as it does on your own server.Then open the key icon in the same sidebar and add a secret named COURIER_API_KEY with your Courier key as its value.Auth0 exposes the secret to the Action as event.secrets.COURIER_API_KEY. It is never in your application’s environment and never in the Action’s source.3
Write the Action
The Action receives the newly created user on Actions are CommonJS, so the SDK comes in with
event.user. Create the profile, then send.Post User Registration
require rather than import. Everything else is the same code you would write on your own server, and the applies unchanged.4
Deploy and add it to the flow
Select Deploy, then go to Actions → Triggers → post-user-registration and drag the Action into the flow between Start and Complete. An Action that is deployed but not in the flow never runs, which is the most common reason nothing happens.
Verify
1
Register a test user
Create a user through your app’s signup, or from User Management → Users in the Auth0 Dashboard. The trigger fires for Database and Passwordless connections.
2
Check the Auth0 log
In Monitoring → Logs, find the registration event. A failing Action shows up here and nowhere else.
3
Confirm the send
Open in Courier and confirm the message.
The trigger fires for Database and Passwordless connections only. A user arriving through a social or enterprise connection does not fire it, so a Google sign-up sends nothing. For those, use a post-login Action and check whether the login is the user’s first.
Adapt it for other triggers
post-login runs on every login, so gate anything you send there on a condition. Sending on each login is how a welcome email becomes a complaint.