Banata

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

PagePathDescription
Events/emails/eventsMonitor email delivery, opens, and bounces
Providers/emails/providersConfigure third-party email delivery services
Configuration/emails/configurationToggle 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:

ProviderKey LabelDocs
ResendResend API Keyresend.com/api-keys
SendGridSendGrid API Keyapp.sendgrid.com/settings/api_keys
Amazon SESAWS Access Key IDAWS SES Documentation
MailgunMailgun API Keyapp.mailgun.com/settings/api_security
PostmarkPostmark Server Tokenaccount.postmarkapp.com/servers

Setting Up a Provider

  1. Navigate to Emails > Providers
  2. Click Enable on your preferred provider
  3. Enter your API key in the input field that appears
  4. Click Save Key to persist the credential
  5. 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

EndpointMethodDescription
/api/auth/banata/config/email-providers/getPOSTGet current provider configuration
/api/auth/banata/config/email-providers/savePOSTUpdate provider configuration (partial)
/api/auth/banata/test-emailPOSTSend a test email via the active provider

Provider Config Shape

typescript
interface EmailProviderConfig {
  providers: Record<string, {
    enabled: boolean;
    apiKey?: string;
  }>;
  activeProvider: string | null;
}

Example: Setting Up Resend

typescript
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

IDNameDescriptionDefault
magic-authMagic AuthMagic link and OTP authentication emailsEnabled
user-invitationUser invitationInvitation emails sent to new usersEnabled
email-verificationEmail verificationVerification for new sign-ups and email changesEnabled
password-resetPassword resetPassword reset request emailsEnabled

Organization Emails

IDNameDescriptionDefault
critical-notificationsCritical notificationsImportant system notifications to org adminsEnabled
invitationsInvitationsOrganization membership invitation emailsEnabled

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

EndpointMethodDescription
/api/auth/banata/config/emails/listPOSTGet all email toggle states
/api/auth/banata/config/emails/togglePOSTToggle a specific email type

Email Toggle Shape

typescript
interface EmailToggle {
  id: string;
  name: string;
  description: string;
  enabled: boolean;
  category: "auth" | "org";
}

Example: Disabling Password Reset Emails

typescript
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 events
  • verification — Email verification sends and confirmations
  • magic-link — Magic link delivery
  • otp — One-time password emails
  • password-reset — Password reset emails
  • invitation — Invitation emails

Event Table Columns

ColumnDescription
EventThe action type displayed as a badge
RecipientThe email address of the recipient
TimeRelative 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:

typescript
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:

typescript
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

typescript
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