# Email Template Endpoints {#email-template-endpoints}


Manage email templates, custom SMTP configurations, and email sending history.


## Base Paths {#base-paths}


| Resource        | Path                  |
| --------------- | --------------------- |
| Email Templates | `/api/email-template` |
| Custom SMTP     | `/api/smtp`           |
| Email History   | `/api/email-history`  |


## Email Template Endpoints {#email-template-endpoints-1}



### List Templates {#list-templates}


```
GET /api/email-template
Authorization: Bearer {token}
```


### Get Template by ID {#get-template-by-id}


```
GET /api/email-template/:id
Authorization: Bearer {token}
```


### Find Template by Name & Language {#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 {#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 {#update-template}


```
PUT /api/email-template/:id
Authorization: Bearer {token}
Content-Type: application/json

{
  "hbs": "<p>Updated template content</p>"
}
```


### Delete Template {#delete-template}


```
DELETE /api/email-template/:id
Authorization: Bearer {token}
```


## Custom SMTP Endpoints {#custom-smtp-endpoints}



### Get SMTP Configuration {#get-smtp-configuration}


```
GET /api/smtp
Authorization: Bearer {token}
```


### Validate SMTP Configuration {#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 {#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 {#email-history-endpoints}



### List Email History {#list-email-history}


```
GET /api/email-history
Authorization: Bearer {token}
```


### Get Email History Count {#get-email-history-count}


```
GET /api/email-history/count
Authorization: Bearer {token}
```


## Built-in Templates {#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 {#data-model}


```typescript
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 {#related-pages}


- [Email Templates Feature](https://sourcey-gauzy.pages.dev/features/email-templates/index.md) — template management guide
- [Custom SMTP Feature](https://sourcey-gauzy.pages.dev/features/custom-smtp/index.md) — SMTP configuration guide
- [Email System](https://sourcey-gauzy.pages.dev/features/email-templates-deep-dive/index.md) — architecture deep dive
