# Task 008 — Email Templates Module

## Objective

Implement Email Templates for authoring and previewing reusable business emails to be used later by Campaigns.

## Scope

- EmailTemplate schema enhancements (`description`, `category`)
- Template utilities: extract/render/validate variables
- Email template service
- Protected APIs under `/api/email-templates/*`
- UI pages under `/email-templates/*`
- Sidebar + middleware protection

**Out of scope:** Campaign sending, SMTP sending, inbox, AI.

## Acceptance criteria

- [x] `npm run build` succeeds
- [x] `npm run lint` succeeds
- [x] `/email-templates` exists and is protected
- [x] Create/edit/archive template works
- [x] Variables extracted automatically and invalid variables rejected
- [x] Preview unsaved + preview saved work
- [x] Docs + changelog + task index updated

## Documentation updates required

- `docs/01-architecture.md`
- `docs/02-database-schema.md`
- `docs/03-api-specification.md`
- `docs/04-ui-pages.md`
- `docs/05-email-system.md`
- `docs/16-changelog.md`
- `docs/14-roadmap.md`
- `tasks/README.md`
