Leave Localhost logoLeave LocalhostDocs
Emails

Notification Emails

The starter includes two categories of notification emails: subscription notifications and sensitive action verification codes.

The starter includes two categories of notification emails: subscription notifications and sensitive action verification codes.

Subscription Emails

File: packages/backend/convex/email/templates/subscriptionEmail.tsx

Two templates are provided:

Subscription Success

Sent when a subscription payment is processed successfully.

  • Confirms the PRO subscription is active
  • Links to the app

Subscription Error

Sent when a subscription payment fails.

  • Notifies the user of the payment issue
  • Assures them they were not charged
  • Links to the app

Wiring into Webhooks

These templates are not wired to a webhook by default. Send them the same way as every other email in the starter: render the template, then call the sendEmail facade from your billing webhook handler (see auth.ts and challenges.ts for the same pattern in use).

import { sendEmail } from "./email";
import {
  renderSubscriptionSuccessEmail,
  renderSubscriptionSuccessText,
} from "./email/templates/subscriptionEmail";

// In your billing webhook handler:
const options = {
  appName: env.APP_NAME,
  email: customerEmail,
  subscriptionId: "sub_123",
  siteUrl: env.SITE_URL,
};

await sendEmail(ctx, {
  to: customerEmail,
  subject: "Successfully Subscribed to PRO",
  html: await renderSubscriptionSuccessEmail(options),
  text: renderSubscriptionSuccessText(options),
});

Sensitive Action Verification Email

File: packages/backend/convex/email/templates/sensitiveActionVerificationEmail.tsx

Sent when a user needs to verify their identity for a sensitive action via email code.

The email contains:

  • A "Verify it's you" heading
  • The specific action being verified (e.g. "Delete this organization")
  • A large, styled verification code
  • Expiration notice
  • Safety message if the user didn't request it

Template Parameters

ParameterDescription
codeThe one-time verification code
actionLabelHuman label for the action (e.g. "Delete your account")
appNameProduct name from APP_NAME env var
expiresInMinutesMinutes until the code expires

Next Reads

On this page