Infrastructure
Emails
Configure email providers, manage transactional email types, and monitor email delivery events in the Banata Auth dashboard.
The Emails section of the Banata Auth dashboard lets you configure email delivery providers, control which transactional emails are sent to your users, and monitor email events. It is the default delivery surface for Banata Auth. Your frontend triggers auth flows, but Banata sends the actual emails using the provider, branding, and templates configured here unless you explicitly override delivery in code.
Email Sub-Pages
| Page | Path | Description |
|---|---|---|
| Events | /emails/events | Monitor email delivery, opens, and bounces |
| Providers | /emails/providers | Configure third-party email delivery services |
| Configuration | /emails/configuration | Toggle individual email types on or off |
Navigating to /emails automatically redirects to /emails/events.
Email Providers
Configure which third-party email delivery provider handles transactional emails for your Banata Auth instance. Five providers are supported out of the box:
| Provider | Key Label | Docs |
|---|---|---|
| Resend | Resend API Key | resend.com/api-keys |
| SendGrid | SendGrid API Key | app.sendgrid.com/settings/api_keys |
| Amazon SES | AWS Access Key ID | AWS SES Documentation |
| Mailgun | Mailgun API Key | app.mailgun.com/settings/api_security |
| Postmark | Postmark Server Token | account.postmarkapp.com/servers |
Setting Up a Provider
- Navigate to Emails > Providers
- Click Enable on your preferred provider
- Enter your API key in the input field that appears
- Click Save Key to persist the credential
- The enabled provider becomes the active provider automatically
Only one provider can be active at a time. Enabling a new provider makes it the active one. Disabling the active provider sets it to none.
Sending Test Emails
Once a provider is active, click the Send test email button in the page header. Enter a recipient email address and click Send. The test email is dispatched through your active provider to verify that delivery works correctly.
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/auth/banata/config/email-providers/get | POST | Get current provider configuration |
/api/auth/banata/config/email-providers/save | POST | Update provider configuration (partial) |
/api/auth/banata/test-email | POST | Send a test email via the active provider |
Provider Config Shape
interface EmailProviderConfig {
providers: Record<string, {
enabled: boolean;
apiKey?: string;
}>;
activeProvider: string | null;
}Example: Setting Up Resend
import { saveEmailProviderConfig } from "@/lib/dashboard-api";
await saveEmailProviderConfig({
providers: {
resend: { enabled: true, apiKey: "re_xxxxx..." }
},
activeProvider: "resend",
});Email Configuration
Control which categories of transactional emails are sent to your users. Each email type can be independently enabled or disabled.
Authentication Emails
| ID | Name | Description | Default |
|---|---|---|---|
magic-auth | Magic Auth | Magic link and OTP authentication emails | Enabled |
user-invitation | User invitation | Invitation emails sent to new users | Enabled |
email-verification | Email verification | Verification for new sign-ups and email changes | Enabled |
password-reset | Password reset | Password reset request emails | Enabled |
Organization Emails
| ID | Name | Description | Default |
|---|---|---|---|
critical-notifications | Critical notifications | Important system notifications to org admins | Enabled |
invitations | Invitations | Organization membership invitation emails | Enabled |
Toggling an Email Type
Each email type has a Switch toggle. Changes are saved immediately when toggled. The server returns the full updated configuration after each change.
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/auth/banata/config/emails/list | POST | Get all email toggle states |
/api/auth/banata/config/emails/toggle | POST | Toggle a specific email type |
Email Toggle Shape
interface EmailToggle {
id: string;
name: string;
description: string;
enabled: boolean;
category: "auth" | "org";
}Example: Disabling Password Reset Emails
import { toggleEmail } from "@/lib/dashboard-api";
// Returns the full updated EmailToggle[] list
const updated = await toggleEmail("password-reset", false);Email Events
The Events page provides a real-time view of email-related activity in your Banata Auth instance. Events are filtered from the global audit log based on email-related action keywords.
What's Tracked
Events matching these keywords are displayed:
email— General email eventsverification— Email verification sends and confirmationsmagic-link— Magic link deliveryotp— One-time password emailspassword-reset— Password reset emailsinvitation— Invitation emails
Event Table Columns
| Column | Description |
|---|---|
| Event | The action type displayed as a badge |
| Recipient | The email address of the recipient |
| Time | Relative timestamp (e.g., "2 hours ago") |
Empty State
If no email events exist in the audit log, the page shows an empty state with the message: "No email events found in the last 30 days. Events will appear here once emails are sent through your configured provider."
Note: Email events are derived from the audit log. They appear once you have a provider configured and transactional emails are being sent through your auth flows.
Data Model
Email configuration is stored in two separate config tables:
Email Toggles
Stored in the emailConfig table as a JSON blob:
defineTable({
configJson: v.string(), // JSON array of EmailToggle objects
createdAt: v.float64(),
updatedAt: v.float64(),
})Email Provider Config
Stored in the emailProviderConfig table as a JSON blob:
defineTable({
configJson: v.string(), // JSON: { providers, activeProvider }
createdAt: v.float64(),
updatedAt: v.float64(),
})Note: API keys are stored in the config JSON. In a production deployment, consider encrypting these values at rest or using a secrets manager.
Using Emails Programmatically
import {
getEmailConfig,
toggleEmail,
getEmailProviderConfig,
saveEmailProviderConfig,
} from "@/lib/dashboard-api";
// List all email toggle states
const emails = await getEmailConfig();
console.log(emails.find(e => e.id === "magic-auth")?.enabled); // true
// Disable magic link emails
const updated = await toggleEmail("magic-auth", false);
// Get provider config
const providers = await getEmailProviderConfig();
console.log(providers.activeProvider); // "resend"
// Switch to SendGrid
const newConfig = await saveEmailProviderConfig({
providers: { sendgrid: { enabled: true, apiKey: "SG.xxx" } },
activeProvider: "sendgrid",
});What's Next
- Notifications — Configure system notifications
- Domains — Set up custom domains for auth email links
- Settings — Configure project-level settings