Create and manage email templates
/mail_templates*
endpoints require a partner access token.Create an email template
To create a custom email template, call 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.
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:
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 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.
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}
endpoint:
A successful response returns information about the custom template with the specified ID:
Set template as 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
:
The successful response sets the template as default for the type
and language
.
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
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
:
- The
body
andsubject
fields in the request object represent the text to replace thesubject_text
andbody_template
variables in the mail template. - If the
subject_text
andbody_template
variables are not used in the template, any text provided in thebody
andsubject
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
To retrieve all templates, call GET /mail_templates
:
A successful request returns an array of all custom templates created.
Sort and filter custom templates
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:
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
To retrieve all Monite system templates, call GET /mail_templates/system
:
A successful response returns an array of all Monite system templates.
Update a template
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}
:
A successful request returns an object with the updated custom template details.
Only custom templates can be updated or deleted. Monite system templates cannot be modified.
Delete a template
To delete an existing custom template, call DELETE /mail_templates/{template_id}
:
A successful request returns a 204
status code with no payload.
Default custom templates cannot be deleted. Attempting to delete a default template will return a 409 conflict
error.