Email Triggers
Claxx Auth owns every auth-domain email sent in the connected apps: invitations, password resets, welcome emails, and (roadmap) email verification. Downstream apps do not send these emails themselves — they trigger a Claxx Auth operation which causes Claxx Auth to send the email, themed for the tenant that initiated the action.
This page describes each trigger, the template that renders it, the variables substituted, and how to override the template per tenant via Theme Studio.
Delivery pipeline
- A Claxx Auth operation triggers an email (invitation created, password-reset requested, signup completed).
- Claxx Auth resolves the tenant theme for the triggering client (
resolveEmailTheme(clientId)). - The template renders themed HTML + plain-text bodies via
renderEmailBase+ per-concept template module. sendEmail()throwsEmail sending is not configured. Password reset and invitations fail at send time. There is no email binding inwrangler.jsonc. Do not add one in a drive-by change.
Source: server/utils/email/send.ts, server/utils/email/resolve-theme.ts, shared/utils/email/templates/.
The four emails
| When it sends | Template | Sender | |
|---|---|---|---|
| Invitation | Admin creates an invitation for a new user | shared/utils/email/templates/invitation.ts | Not sent. sendEmail() throws. |
| Password Reset | User submits /forgot-password | shared/utils/email/templates/password-reset.ts | Not sent. sendEmail() throws. |
| Welcome | User accepts invitation or completes self-signup | shared/utils/email/templates/welcome.ts | Not sent. sendEmail() throws. |
| Address confirmation | Self-service sign-up, or a password sign-in to an account whose address is not confirmed yet | shared/utils/email/templates/verify-email.ts | The tenant's name. |
The templates still render. sendEmail() does not deliver them. They differ in subject line, body HTML, and CTA link.
Template variables
Each template renders from a small, explicit set of inputs. No user-controlled HTML is interpolated.
Invitation — renderInvitationEmail
| Variable | Example | Notes |
|---|---|---|
theme | Resolved tenant theme object | Drives logo, primary color, font preset, footer text, tenant display name. |
acceptUrl | https://auth.example.com/invite?token=<opaque> | Single-use invitation link. Token valid until expiresAt. |
clientName | "Example App" | Used in the headline copy ("You're invited to Example App"). |
recipientName | "Jane Doe" or null | Greeting line. Falls back to "Hi there" when null. |
inviterName | "Clay Levering" | Personalizes the body ("Clay invited you"). |
expiresAt | Date | Rendered as a human-friendly expiry. |
Password reset — renderPasswordResetEmail
| Variable | Example | Notes |
|---|---|---|
theme | Resolved tenant theme object | Chrome and branding. |
resetUrl | https://auth.example.com/reset-password-token?token=<opaque> | Single-use link, 1-hour default TTL. |
userName | "Jane" or null | Greeting. |
Welcome — renderWelcomeEmail
| Variable | Example | Notes |
|---|---|---|
theme | Resolved tenant theme object | Chrome and branding. |
signInUrl | https://auth.example.com/login | CTA link. |
userName | "Jane" or null | Greeting. |
Theme resolution
At send time, Claxx Auth resolves the theme for the triggering client:
- Look up the OAuth client by ID.
- Load the
client_themesrow bound to the client. - Fall back to the service-default theme if no client-bound theme exists.
- Fall back to
HOSTED_LOGIN_THEME_DEFAULTSfor any missing fields.
Resolved values that affect email rendering:
name— tenant display name. It is used in subject copy. Mail is not sent, so there is no From address in production.primaryColor— hex color for CTA buttons and accent strokes.logoUrl— tenant logo rendered in the email header.footerText— legal/support line in the email footer.fontFamilyPreset— web-safe stack referenced in the email stylesheet.
Every email Claxx Auth sends is theme-accurate for the tenant initiating the action. Changes made in Theme Studio (/admin/themes) take effect on the next send without redeploy.
Triggering from downstream apps
You don't invoke the email sender directly. You trigger a Claxx Auth operation that causes Claxx Auth to send.
Trigger an invitation email
POST https://auth.example.com/api/admin/invitations
Authorization: Bearer <admin-token>
Content-Type: application/json
{
"email": "invitee@example.com",
"recipientName": "First Last",
"clientId": "7f9b0e7e-...-a11c",
"expiresAt": "2026-04-23T00:00:00.000Z"
}
Claxx Auth creates the invitations row and publishes invitation.created. The invitation mail is not sent. sendEmail() throws Email sending is not configured. The same is true for password reset and welcome.
Trigger a password-reset email
POST https://auth.example.com/api/auth/forgot-password
Content-Type: application/json
{
"email": "user@example.com"
}
This endpoint is exposed through the Better Auth catch-all at server/api/auth/[...all].ts. The reset token can be persisted. The themed reset email is not sent.
Trigger a welcome email
You don't trigger it directly. The welcome template is selected when:
- A user accepts an invitation at
/api/auth/accept-invite. - A user completes self-signup (where self-signup is enabled on the client).
That path calls sendEmail(), which throws. Users do not receive a welcome message.
What downstream apps should do
- Don't duplicate these emails. Claxx Auth owns the invitation, password-reset, and welcome templates. If your app wants to send a different welcome-to-the-product sequence after the auth welcome lands, subscribe to the
user.createdorinvitation.acceptedwebhook and drive your sequence from there. - Do subscribe to webhooks (webhook events) when you need to react to these lifecycle events — e.g. to create a tenant record in your app the moment a user signs up.
- Do customize your theme in
/admin/themes. Every email inherits the theme bound to the initiating client, including logo, colors, and footer copy.
Previewing and testing templates
Admins can preview and test-send any template from /admin/settings → Email test (backed by POST /api/admin/email-test).
Preview only (renders HTML, does not send)
POST https://auth.example.com/api/admin/email-test
Authorization: Bearer <admin-token>
Content-Type: application/json
{
"themeId": "b1f2c3d4-...-0001",
"recipientEmail": "qa@example.com",
"previewOnly": true,
"emailConcept": "invitation"
}
Response:
{
"success": true,
"data": {
"html": "<!doctype html>...",
"text": "You're invited...",
"theme": "Example App",
"emailConcept": "invitation"
}
}
The admin UI renders this HTML in a sandboxed iframe so you can review layout, colors, logo, and copy without sending anything.
Test send
Omit previewOnly (or set it to false). The route calls sendEmail(), which throws Email sending is not configured. No message leaves the Worker.
emailConcept accepts "password-reset", "welcome", or "invitation". The test route is admin-only.
Source: server/api/admin/email-test.post.ts.
Sender identity
Mail is not configured. There is no From address and no Cloudflare email binding. Do not add an email provider in this change.
Localization
Not implemented — all emails are English. Localization is gated on the first tenant with a non-English primary locale. When added, locale will be resolved from the recipient's profile locale field, falling back to the tenant default, falling back to en-US.
Logging
Nothing is sent, so there is no provider message id to search for.