Server API

List Templates

GET /api/emails - Get all available email templates

The /api/emails endpoint returns a list of all available email templates in your project.

Endpoint

GET /api/emails

Response

Returns an array of email template objects with the following structure:

interface EmailTemplate {
  name: string; // Internal template name (used for rendering)
  filename: string; // Original filename with extension
  displayName: string; // Human-readable display name
}

Examples

Basic Request

curl http://localhost:3000/api/emails

Response:

[
  {
    "name": "WelcomeEmail",
    "filename": "WelcomeEmail.vue",
    "displayName": "Welcome Email"
  },
  {
    "name": "ResetPassword",
    "filename": "ResetPassword.vue",
    "displayName": "Reset Password"
  },
  {
    "name": "OrderConfirmation",
    "filename": "OrderConfirmation.vue",
    "displayName": "Order Confirmation"
  }
]

Template Discovery

The endpoint automatically discovers templates from your configured emailsDir (default: /emails). Templates are discovered based on:

  1. File Extension: Must be .vue files
  2. Location: Must be in the configured emails directory
  3. Format: Must be valid Vue Single File Components

Template Structure

emails/
├── WelcomeEmail.vue      → { name: "WelcomeEmail", ... }
├── auth/
│   └── ResetPassword.vue → { name: "ResetPassword", ... }
└── commerce/
    └── OrderEmail.vue    → { name: "OrderEmail", ... }