> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.monite.com/v2023-09-01/advanced/email-templates/manage/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.monite.com/_mcp/server. # Create and manage email templates > **Info** > > The `/mail_templates*` endpoints require a [partner access token](../../get-started/server-side#generate-partner-access-token). ## Create an email template To create a custom [email template](./index), call [`POST /mail_templates`](/v2023-09-01/api/mail-templates/post-mail-templates) endpoint. The `type` field in the request body represents one of Monite's customizable email templates. For the complete list of template types, see [Template types](./index#types). You can create a default template for a template type by setting the value of the `is_default` field to `true`. If the `is_default` field is left unspecified, its value is set to `false`. The following request creates a new default template for English invoice emails: ```sh curl -X POST 'https://api.sandbox.monite.com/v1/mail_templates' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "language": "en", "subject_template": "New invoice from {{entity_name}}!", "body_template": " \n \n
\n \n\n\n", "name": "New invoice template", "type": "receivables_invoice", "is_default": true }' ``` > **Info** > > The `subject_template` and `body_template` fields can include variables related to the template type. To view the list of available variables for each template type, see the [Retrieving variables](../variables#list). Variables for custom templates should be enclosed in curly braces, as shown: `{{YOUR_VARIABLES}}`. The successful response the ID created of the created template and other details of the template. ```json { "id": "5b031d0c-dcb6-4aa0-b660-44df31ebf0db", "type": "receivables_invoice", "name": "New invoice template", "is_default": true, "language": "en", "subject_template": "New invoice from {{entity_name}}!", "body_template": " \n \n \n \n\n\n", "created_at": "2023-12-01T16:04:59.177241+00:00", "updated_at": "2023-12-01T16:04:59.177255+00:00" } ``` > **Warning** > > **Default templates** > > You can only have one default template per `language` and `type` combination. Therefore, creating a new default template will overwrite any existing default template for that language and template type. ## Retrieve a template To get information about a specific custom template, call [`GET /mail_templates/{template_id}`](/v2023-09-01/api/mail-templates/get-mail-templates-id) endpoint: ```sh curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates/44df31ebf0db...5b031d0c' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` A successful response returns information about the custom template with the specified ID: ```json { "id": "44df31ebf0db-dcb6-4aa0-b660-5b031d0c", "type": "receivables_quote", "name": "New quote template", "is_default": false, "language": "en", "subject_template": "New invoice from {{entity_name}}!", "body_template": " \n \n \n \n\n\n", "created_at": "2023-12-11T16:04:59.177241+00:00", "updated_at": "2023-12-12T19:54:59.177255+00:00" } ``` ## Set template as default \[#default] You can set a custom template as default when creating custom templates by specifying the `is_default` field to `true` in the request object. You can also mark a template as default by calling [`POST /mail_templates/{template_id}/make_default`](/v2023-09-01/api/mail-templates/post-mail-templates-id-make-default): ```sh curl -X POST 'https://api.sandbox.monite.com/v1/mail_templates/44df31ebf0db...5b031d0c/make_default' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` The successful response sets the template as default for the `type` and `language`. > **Info** > > To make a template of the same `type` the default for another language, you must send another `POST` request to the `/mail_templates/{template_id}/make_default` endpoint with template UUID. ## Preview mail templates \[#preview] You can preview the current default mail template for all template types. The preview endpoint returns the default template for the template type and language requested. This can be either Monite's system template or your custom template. To preview a mail template, call `POST /mail_templates/preview`: ```sh curl -X POST 'https://api.sandbox.monite.com/v1/mail_templates/preview' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer ACCESS_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "body": "Find attached the current rates for the items requested", "document_type": "receivables_quote", "language_code": "en", "subject": "Your new quote is here" }' ``` * The `body` and `subject` fields in the request object represent the text to replace the `subject_text` and `body_template` variables in the mail template. * If the `subject_text` and `body_template` variables are not used in the template, any text provided in the `body` and `subject` fields will be voided. You can provide an empty string if these variables are not used in the template. The successful request returns a preview of the email body and subject for the current default mail template in the response. ## Get all templates \[#get-all] To retrieve all templates, call [`GET /mail_templates`](/v2023-09-01/api/mail-templates/get-mail-templates): ```sh curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` A successful request returns an array of all custom templates created. ### Sort and filter custom templates \[#sort-and-filter] You can sort the returned custom templates by `name` and `type`. You can also filter the results by `name`, `type`, `is_default`, and other fields. For a list of available sort and filter parameters, see the description of the `GET /mail_templates` endpoint. For example, the following request will return all custom templates for credit note emails: ```sh curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates?type=receivables_credit_note' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` Here are some other filtering examples: * `GET /mail_templates?type=receivables_credit_note&sort=name` - retrieves custom templates for credit note emails and sorts them by name. * `GET /mail_templates?counterpart_name__icontains=invoices` - retrieves all custom template whose name contains "invoices" (case-insensitive). ## Get system templates \[#system] To retrieve all Monite system templates, call [`GET /mail_templates/system`](/v2023-09-01/api/mail-templates/get-mail-templates-system): ```sh curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates/system' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` A successful response returns an array of all Monite system templates. ## Update a template \[#update] You can update the `language_code`, `body_template`, and `subject_template` properties of a custom template. To update a template, call [`PATCH /mail_templates/{template_id}`](/v2023-09-01/api/mail-templates/patch-mail-templates-id): ```sh curl -X PATCH 'https://api.sandbox.monite.com/v1/mail_templates/5b031d0c...44df31ebf0db' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "body_template": " \n \n \n \nContact support if you have already paid this invoice
{{invoice_number}}, {{currency}}, {{discount}} ,{{total_value}}, {{due_date}}, {{entity_name}},{{body_text}}\n\n", }' ``` A successful request returns an object with the updated custom template details. > **Info** > > Only custom templates can be updated or deleted. Monite system templates cannot be modified. ## Delete a template \[#delete] To delete an existing custom template, call [`DELETE /mail_templates/{template_id}`](/v2023-09-01/api/mail-templates/delete-mail-templates-id): ```sh curl -X DELETE 'https://api.sandbox.monite.com/v1/mail_templates/5b031d0c...44df31ebf0db' \ -H 'X-Monite-Version: 2023-09-01' \ -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' ``` A successful request returns a `204` status code with no payload. > **Warning** > > Default custom templates cannot be deleted. Attempting to delete a default template will return a `409 conflict` error.