docs: Document managed email provider and email scheduling features#1282
docs: Document managed email provider and email scheduling features#1282promptless[bot] wants to merge 1 commit intodevfrom
Conversation
There was a problem hiding this comment.
(Line 139)
Citation: New "Managed by Stack Auth" email provider feature. Based on PR implementation in apps/backend/src/lib/managed-email-onboarding.tsx and dashboard UI in apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/emails/page-client.tsx. The setup flow guides users through subdomain configuration, NS record delegation, and domain verification via Resend webhooks.
View source
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| }); | ||
| ``` | ||
|
|
||
| ### Scheduling Emails |
There was a problem hiding this comment.
Citation: Added scheduled_at_millis parameter to the send-email endpoint in apps/backend/src/app/api/latest/emails/send-email/route.tsx. This allows scheduling emails for future delivery.
View source
| html?: string; // Custom HTML content | ||
| templateId?: string; // Template ID to use | ||
| variables?: Record<string, any>; // Template variables | ||
| scheduledAtMillis?: number; // When to send (timestamp in milliseconds) |
There was a problem hiding this comment.
Citation: New scheduled_at_millis option added to the request body schema in apps/backend/src/app/api/latest/emails/send-email/route.tsx.
View source
|
|
Greptile SummaryThis PR adds documentation for two new email features: the Managed by Stack Auth email provider (from PR #1222) and email scheduling via Key issues:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer Code
participant SDK as StackServerApp (SDK)
participant API as Stack Auth API
Note over Dev,API: Email Scheduling Flow
Dev->>SDK: sendEmail({ scheduledAt: new Date(...) })
SDK->>API: POST /emails/send-email<br/>{ scheduled_at_millis: date.getTime() }
API-->>SDK: 200 OK { results: [...] }
SDK-->>Dev: void
Note over Dev,API: Managed Email Provider Setup
Dev->>API: Dashboard → Email Settings → Managed Setup
API-->>Dev: Display NS records for subdomain
Dev->>Dev: Add NS records at DNS provider
API->>API: Poll for DNS propagation<br/>(pending_verification → verified)
Dev->>API: Click "Use This Domain"
API-->>Dev: Emails sent from sender@subdomain
Reviews (1): Last reviewed commit: "Document managed email provider and emai..." | Re-trigger Greptile |
| userIds: ['user-id'], | ||
| subject: 'Reminder: Your trial ends soon', | ||
| html: '<p>Your trial period ends tomorrow. Upgrade now to keep access.</p>', | ||
| scheduledAtMillis: oneHourFromNow, |
There was a problem hiding this comment.
Wrong property name in scheduling example
The code example uses scheduledAtMillis (a number), but the actual SendEmailOptions type defines the property as scheduledAt (a Date object). Developers copying this example will pass an unrecognised property that is silently ignored, and the email will be sent immediately instead of at the scheduled time.
From packages/stack-shared/src/interface/server-interface.ts:
async sendEmail(options: {
...
scheduledAt?: Date, // ← Date object, not a number
})Internally the SDK converts it via options.scheduledAt?.getTime() before sending scheduled_at_millis to the API.
| scheduledAtMillis: oneHourFromNow, | |
| scheduledAt: new Date(oneHourFromNow), |
| // Schedule an email to be sent in 1 hour | ||
| const oneHourFromNow = Date.now() + 60 * 60 * 1000; |
There was a problem hiding this comment.
Incorrect variable type for scheduled timestamp
Date.now() returns a plain number (milliseconds since epoch), but sendEmail expects a Date object in the scheduledAt field — not a raw millisecond timestamp. The variable should be constructed as a Date:
| // Schedule an email to be sent in 1 hour | |
| const oneHourFromNow = Date.now() + 60 * 60 * 1000; | |
| const oneHourFromNow = new Date(Date.now() + 60 * 60 * 1000); |
| html?: string; // Custom HTML content | ||
| templateId?: string; // Template ID to use | ||
| variables?: Record<string, any>; // Template variables | ||
| scheduledAtMillis?: number; // When to send (timestamp in milliseconds) |
There was a problem hiding this comment.
Wrong property name and type in
SendEmailOptions type definition
The type definition documents scheduledAtMillis?: number, but the actual SDK type (packages/template/src/lib/stack-app/email/index.ts) and the underlying interface (packages/stack-shared/src/interface/server-interface.ts) both use scheduledAt?: Date. Using the documented scheduledAtMillis property will have no effect at runtime.
| scheduledAtMillis?: number; // When to send (timestamp in milliseconds) | |
| scheduledAt?: Date; // When to send (Date object) |
Open this suggestion in Promptless to view citations and reasoning process
Updates the Emails documentation with two new features:
Managed by Stack Auth email provider (from PR Managed email provider #1222): Documents the new email configuration option that automates DNS and domain setup via Resend integration, allowing users to send from their own domain without manually configuring SMTP.
Email scheduling (from PR [Refactor][Feat][Fix] Rework Email Section With New Sent Page, Better Drafts Page, and Settings Page #1221): Documents the new
scheduledAtMillisoption forsendEmailthat allows scheduling emails for future delivery instead of sending immediately.Trigger Events
stack-auth/stack-auth commit (dev): b701fdf Managed email provider (#1222)
Promptless Research (4 files, 1 GitHub PR)
.long_term_context/product_knowledge/product_overview.md.long_term_context/doc_workflow/client_instructions.md.long_term_context/style/client_style_guide.mddocs/content/docs/(guides)/apps/emails.mdxAgent Response
stack-auth/stack-auth commit (dev): 485fa9d [Refactor][Feat][Fix] Rework Email Section With New Sent Page, Better Drafts Page, and Settings Page (#1221)
Promptless Research (4 files, 1 GitHub PR)
.long_term_context/product_knowledge/product_overview.md.long_term_context/doc_workflow/client_instructions.md.long_term_context/style/client_style_guide.mddocs/content/docs/(guides)/apps/emails.mdxAgent Response
Tip: Create additional Docs Collections to keep multiple repositories in sync 📚