Email Template Endpoints
Manage email templates, custom SMTP configurations, and email sending history.
Base Pathsβ
| Resource | Path |
|---|---|
| Email Templates | /api/email-template |
| Custom SMTP | /api/smtp |
| Email History | /api/email-history |
Email Template Endpointsβ
List Templatesβ
GET /api/email-template
Authorization: Bearer {token}
Get Template by IDβ
GET /api/email-template/:id
Authorization: Bearer {token}
Find Template by Name & Languageβ
GET /api/email-template/find
Authorization: Bearer {token}
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
name | string | Template name |
languageCode | string | Language code (e.g., en) |
Create Templateβ
POST /api/email-template
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "WELCOME_USER",
"languageCode": "en",
"mjml": "<mjml>...</mjml>",
"hbs": "<p>Welcome {{name}}!</p>",
"organizationId": "uuid"
}
Update Templateβ
PUT /api/email-template/:id
Authorization: Bearer {token}
Content-Type: application/json
{
"hbs": "<p>Updated template content</p>"
}
Delete Templateβ
DELETE /api/email-template/:id
Authorization: Bearer {token}
Custom SMTP Endpointsβ
Get SMTP Configurationβ
GET /api/smtp
Authorization: Bearer {token}
Validate SMTP Configurationβ
POST /api/smtp/validate
Authorization: Bearer {token}
Content-Type: application/json
{
"host": "smtp.gmail.com",
"port": 587,
"secure": false,
"username": "user@gmail.com",
"password": "app-password"
}
Save SMTP Configurationβ
POST /api/smtp
Authorization: Bearer {token}
Content-Type: application/json
{
"host": "smtp.gmail.com",
"port": 587,
"secure": false,
"username": "user@gmail.com",
"password": "app-password",
"fromAddress": "no-reply@mycompany.com",
"organizationId": "uuid"
}
Email History Endpointsβ
List Email Historyβ
GET /api/email-history
Authorization: Bearer {token}
Get Email History Countβ
GET /api/email-history/count
Authorization: Bearer {token}
Built-in Templatesβ
| Template Name | Purpose |
|---|---|
WELCOME_USER | New user welcome email |
PASSWORD_RESET | Password reset request |
INVITE_EMPLOYEE | Employee invitation |
INVITE_USER | User invitation |
TIME_OFF_APPROVED | Time off request approved |
TIME_OFF_REJECTED | Time off request rejected |
INVOICE | Invoice email |
ESTIMATE | Estimate email |
EMAIL_VERIFICATION | Email address verification |
Data Modelβ
interface IEmailTemplate {
id: string;
name: string;
languageCode: string;
mjml?: string;
hbs: string;
organizationId?: string;
tenantId: string;
}
interface ICustomSmtp {
id: string;
host: string;
port: number;
secure: boolean;
username: string;
password: string;
fromAddress?: string;
isValidate?: boolean;
organizationId?: string;
tenantId: string;
}
interface IEmailHistory {
id: string;
name: string;
content: string;
email: string;
status?: EmailStatusEnum;
organizationId?: string;
tenantId: string;
}
Related Pagesβ
- Email Templates Feature β template management guide
- Custom SMTP Feature β SMTP configuration guide
- Email System β architecture deep dive