HomeGuidesRecipesAPI ExplorerForumSupport
Partner Portal
Partner Portal

Create and manage email templates

Learn how to create and manage custom email templates.

📘

All API calls mentioned on this page require a partner access token.

Create an email template

To create a custom email template, send a POST request to the /mail_templates endpoint. The template_name field in the request body represents one of Monite's customizable email templates. For the complete list of template types, see Customizable templates.

Sample request:

curl -X POST 'https://api.sandbox.monite.com/v1/mail_templates' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "language_code": "en",
       "subject_template": "{{subject_text}}",
       "body_template": "<!DOCTYPE html> \n <html lang=\"en\">\n <body>\n <ul id=\"navigation\">\n<li>\n<a href=\"{{ payment_link }}\">Pay Invoice Now!</a>\n</li>\n</ul>\n<h1>{{invoice_number}}, {{currency}}, {{discount}}, {{total_value}}, {{due_date}}, {{entity_name}}, {{body_text}}</h1>\n</body>\n</html>",
       "template_name": "discount_reminder"
     }'

📘

Required variables

To successfully create a custom template, the subject_template and body_template fields must include specific variables. These include the body_text and subject_text variables representing the email_body and email_header text template types. To learn more about handling Monite text template variables, see Text templates and Variables.

The successful response the ID created of the created template and other details of the template.

{
  "id": "5b031d0c-dcb6-4aa0-b660-44df31ebf0db",
  "template_name": "discount_reminder",
  "language_code": "en",
  "subject_template": "{{subject_text}}",
  "body_template": "<!DOCTYPE html> \n <html lang=\"en\">\n <body>\n <ul id=\"navigation\">\n<li>\n<a href=\"{{ payment_link }}\">Pay Invoice Now!</a>\n</li>\n</ul>\n<h1>{{invoice_number}}, {{currency}}, {{discount}} ,{{total_value}}, {{due_date}}, {{entity_name}},{{body_text}}</h1>\n</body>\n</html>",
  "created_at": "2023-08-01T16:04:59.177241+00:00",
  "updated_at": "2023-08-01T16:04:59.177255+00:00"
}

🚧

Default templates

You should only create one custom template per template type. Having more than one mail template for an email action will default to a system template.

Retrieve a template

To get information about a specific custom template, send a GET request to the /mail_templates/{template_id} endpoint:

curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates/5b031d0c...44df31ebf0db' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' 

A successful response returns information about the custom template with the specified ID:

{
  "id": "5b031d0c-dcb6-4aa0-b660-44df31ebf0db",
  "template_name": "discount_reminder",
  "language_code": "en",
  "subject_template": "{{subject_text}}",
  "body_template": "<!DOCTYPE html> \n <html lang=\"en\">\n <body>\n <ul id=\"navigation\">\n<li>\n<a href=\"{{ payment_link }}\">Pay Invoice Now!</a>\n</li>\n</ul>\n<h1>{{invoice_number}}, {{currency}}, {{discount}} ,{{total_value}}, {{due_date}}, {{entity_name}},{{body_text}}</h1>\n</body>\n</html>",
  "created_at": "2023-08-01T16:04:59.177241+00:00",
  "updated_at": "2023-08-01T16:04:59.177255+00:00"
}

Get all templates

To retrieve all templates, send a GET request to the /mail_templates endpoint:

curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' 

A successful request returns an array of all custom templates created.

Get system templates

To retrieve all Monite system templates, send a GET request to the /mail_templates/system endpoint:

curl -X GET 'https://api.sandbox.monite.com/v1/mail_templates/system' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' 

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, send a PATCH request to the /mail_templates/{template_id} endpoint:

curl -X PATCH 'https://api.sandbox.monite.com/v1/mail_templates/5b031d0c...44df31ebf0db' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "body_template": "<!DOCTYPE html> \n <html lang=\"en\">\n <body>\n <ul id=\"navigation\">\n<li>\n<a href=\"{{ payment_link }}\">Pay Invoice Now!</a>\n</li>\n</ul>\n<h1><p>Contact support if you have already paid this invoice</p>{{invoice_number}}, {{currency}}, {{discount}} ,{{total_value}}, {{due_date}}, {{entity_name}},{{body_text}}</h1>\n</body>\n</html>",
     }'

A successful request returns an object with the updated custom template details.

📘

Monite system templates are immutable. Therefore, only custom templates can be updated or deleted.

Delete a template

To delete an existing custom template, send a DELETE request to the /mail_templates/{template_id} endpoint:

curl -X DELETE 'https://api.sandbox.monite.com/v1/mail_templates/5b031d0c...44df31ebf0db' \
     -H 'X-Monite-Version: 2023-06-04' \
     -H 'Authorization: Bearer YOUR_PARTNER_TOKEN'

A successful request returns a 204 status code with no payload.