The
/mail-templates* endpoints require a app access
token.Create an email template
To create a custom email template, callPOST /mail-templates endpoint. The type field in the request body represents one of Tesouro’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}}.Retrieve a template
To get information about a specific custom template, callGET /mail-templates/{template_id} endpoint:
Set template as default
You can set a custom template as default when creating custom templates by specifying theis_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:
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 Tesouro’s system template or your custom template. To preview a mail template, callPOST /mail-templates/preview:
- The
bodyandsubjectfields in the request object represent the text to replace thesubject_textandbody_templatevariables in the mail template. - If the
subject_textandbody_templatevariables are not used in the template, any text provided in thebodyandsubjectfields will be voided. You can provide an empty string if these variables are not used in the template.
Get all templates
To retrieve all templates, callGET /mail-templates:
Sort and filter custom templates
You can sort the returned custom templates byname 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:
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 Tesouro system templates, callGET /mail-templates/system:
Update a template
You can update thelanguage_code, body_template, and subject_template properties of a custom template. To update a template, call PATCH /mail-templates/{template_id}:
Only custom templates can be updated or deleted. Tesouro system templates cannot be modified.
Delete a template
To delete an existing custom template, callDELETE /mail-templates/{template_id}:
204 status code with no payload.