Loomup Docs
Guide /docs/email Read Markdown

Transactional auth email

Loomup sends project authentication email through Amazon SES v2. Each hosted project receives its own SES tenant and configuration set, with tenant-scoped bounce and complaint suppression. Auth email is separate from marketing email and should use a dedicated sender subdomain such as auth.acme.com.

Project schema

Configure the entire flow in one schema publish or from Studio’s Email page:

yaml
$auth:
  registration: public
  password_reset_url: https://app.acme.com/reset-password
  email_verification:
    required: true
    url: https://app.acme.com/verify-email
  invitation_url: https://app.acme.com/accept-invite

$email:
  mode: custom
  from: no-reply@auth.acme.com
  name: Acme
  reply_to: support@acme.com
  brand:
    name: Acme
    logo_url: https://acme.com/logo.png
    accent_color: "#255f43"
    support_url: https://acme.com/support
  templates:
    email_verification:
      subject: Verify your Acme email
      html: '<p>Open <a href="{{action_url}}">this verification link</a>.</p>'
      text: 'Verify your email: {{action_url}}'
    password_reset:
      subject: Reset your Acme password
      text: 'Reset your password: {{action_url}}'
    invitation:
      subject: You are invited to Acme
      text: 'Accept your invitation: {{action_url}}'

Custom bodies must include {{action_url}}. Other allowed placeholders are {{brand_name}}, {{recipient_email}}, and {{support_url}}. Subjects reject newlines; {{expires_in}} is also available. Template bodies are limited to 100 KB, and external brand URLs must use HTTPS.

Managed and custom senders

managed mode sends immediately from LOOMUP_SES_MANAGED_FROM, branded as <project> via Loomup. In custom mode Loomup creates the SES identity and shows DKIM CNAME records plus a custom MAIL FROM MX/SPF pair. The active sender stays managed until SES reports the identity, DKIM, and MAIL FROM as successful. This prevents an unverified configuration from interrupting password reset or verification delivery. A custom domain is claimed by its first Loomup workspace; other projects in that workspace may reuse it, but another workspace cannot.

Production configuration

The host needs AWS credentials authorized for SES v2 tenant, configuration-set, identity, association, and send operations, plus:

json
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": [
      "ses:GetAccount",
      "ses:GetEmailIdentity",
      "ses:CreateEmailIdentity",
      "ses:PutEmailIdentityMailFromAttributes",
      "ses:CreateConfigurationSet",
      "ses:CreateTenant",
      "ses:PutTenantSuppressionAttributes",
      "ses:CreateTenantResourceAssociation",
      "ses:SendEmail"
    ],
    "Resource": "*"
  }]
}

The wildcard is the bootstrap policy: narrow it to the production region, account, managed identity, and Loomup-created tenant/configuration-set name prefix once provisioning has been exercised in that AWS account.

dotenv
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
LOOMUP_SES_REGION=us-east-1
LOOMUP_SES_ACCOUNT_ID=123456789012
LOOMUP_SES_MANAGED_DOMAIN=mailer.tryloomup.com
LOOMUP_SES_MANAGED_FROM=auth@mailer.tryloomup.com

Before enabling production traffic, request SES production access in the chosen region and verify the managed domain. The deployment workflow fails when any required SES setting is absent. Applying new or effectively changed $email settings pre-provisions the SES resources before publishing. Unrelated schema changes skip that preflight when the declaration matches the stored schema or active project email configuration, including legacy projects without stored email metadata. Removing $email stops the project email worker on the same schema reload.

Delivery behavior

Messages enter the project-local _email_outbox. A worker claims rows, sends through SES with the project tenant/configuration set, records the provider message ID, retries transient failures with backoff, and redacts recipient/body data on terminal failure. Completed and terminal rows are purged after 30 days. Email verification links last 24 hours, invitations seven days, and every auth token is hashed, single-use, and supersedes older unused tokens for that user.

Applications with their own workspace or organization invitation token can pass its URL as redirect_to to POST /auth/users/invite. Loomup carries that URL through the password-setup link for new identities and uses it directly as the invitation action for existing identities. Redirects are limited to the project's configured HTTPS origins.

Email ownership without an account

POST /email-verifications and POST /email-verifications/confirm require a project:backend key. They are separate from account email verification: no user, password, membership, or session is created. Applications can verify waitlist applicants before approving an account invitation.

Creation accepts email, purpose, reference, and redirect_to, with a required Idempotency-Key header. The callback must be an allowed project HTTPS origin, without credentials or a fragment. The result contains id and expires_at (Unix seconds). The raw token appears only in the emailed callback fragment (#token=...). Applications should remove it from browser history, exclude analytics on the confirmation page, and require an explicit POST action. Customize the message with $email.templates.email_challenge using the existing email template fields and placeholders.

Confirm with { "token": "selector.secret" }. The receipt contains id, email, purpose, reference, and verified_at (Unix seconds). Validate the purpose and application reference before updating application data. Confirmation is repeatable until expiry, allowing recovery from an interrupted application write. Tokens expire after 24 hours; resending invalidates earlier unverified links for the same email/purpose/reference.

Fresh creation requests allow one email per minute and five per rolling hour per address. Identical idempotency retries bypass sending and its cooldown; reusing the key with different input returns 409. Tokens, receipts, and email outbox rows commit together. Backend-only receipts are retained for retry safety.

POST /auth/users/invite also accepts an optional Idempotency-Key. Opting in makes invitation-token creation/rotation, email enqueue, and the receipt atomic, with the same per-address limits (separate invitation bucket). Requests without the header preserve the existing behavior. Existing identities receive the provided application destination, and never have their password changed.