# Accounting Template Endpoints {#accounting-template-endpoints}


Manage invoice and estimate templates for custom document layouts.


## Base Path {#base-path}


```
/api/accounting-template
```


## Endpoints {#endpoints}



### List Templates {#list-templates}


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

**Query Parameters:**

| Parameter      | Type   | Description                |
| -------------- | ------ | -------------------------- |
| `templateType` | string | `INVOICE` or `ESTIMATE`    |
| `languageCode` | string | Language code (e.g., `en`) |


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


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


### Create Template {#create-template}


```
POST /api/accounting-template
Authorization: Bearer {token}
```

**Request Body:**

```json
{
  "name": "Professional Invoice",
  "languageCode": "en",
  "templateType": "INVOICE",
  "mjml": "<mjml>...</mjml>",
  "hbs": "<div>{{invoiceNumber}}</div>"
}
```


### Update Template {#update-template}


```
PUT /api/accounting-template/:id
Authorization: Bearer {token}
```


### Delete Template {#delete-template}


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


### Generate Preview {#generate-preview}


```
POST /api/accounting-template/template/preview
Authorization: Bearer {token}
```

Renders a template with sample data for preview.


### Save Template {#save-template}


```
POST /api/accounting-template/template/save
Authorization: Bearer {token}
```


## Template Types {#template-types}


| Type       | Description             |
| ---------- | ----------------------- |
| `INVOICE`  | Invoice document        |
| `ESTIMATE` | Estimate/quote document |
| `RECEIPT`  | Payment receipt         |


## Template Variables {#template-variables}


Templates use Handlebars syntax for data interpolation:

| Variable               | Description       |
| ---------------------- | ----------------- |
| `{{invoiceNumber}}`    | Invoice number    |
| `{{invoiceDate}}`      | Invoice date      |
| `{{dueDate}}`          | Payment due date  |
| `{{terms}}`            | Payment terms     |
| `{{fromOrganization}}` | Sender details    |
| `{{toContact}}`        | Recipient details |
| `{{invoiceItems}}`     | Line items array  |
| `{{totalValue}}`       | Invoice total     |
| `{{tax}}`              | Tax amount        |
| `{{discountValue}}`    | Discount amount   |


## Related Pages {#related-pages}


- [Email Template Endpoints](https://sourcey-gauzy.pages.dev/api/email-template-endpoints/index.md) — email templates
- [Invoice Endpoints](https://sourcey-gauzy.pages.dev/api/invoice-endpoints/index.md) — invoice management
- [Invoicing Feature](https://sourcey-gauzy.pages.dev/features/invoicing/index.md) — invoicing feature
