Skip to main content

Overview

Variables are named placeholders in strings that are later replaced with actual values. For example, if you want to add an invoice note addressing the counterpart (customer) personally, you can use the {company_name} variable in the note text and Tesouro will automatically substitute it with the counterpart name associated with that invoice. Variables can be used in any of the following ways: Variables inserted into the text of the memo and footer fields are immediately substituted with their values. That is, the replacement happens immediately during the document creation (POST) or update (PATCH), rather than later when the document gets issued. Keep this in mind when repeatedly updating draft documents, as the memo text with earlier substitutions might no longer reflect the current values of the variables.
Consider a draft invoice created for a counterpart named Trustwave.If you add an invoice memo containing the {company_name} (counterpart name) variable:
the returned memo value will contain the hard-coded counterpart name:
But if you then change the counterpart_id for this invoice, the memo will still contain the old counterpart name.To avoid issues, you can use these approaches:
  • Add memo and footer as the last update before issuing the document.
  • When calling PATCH /receivables/{receivable_id} to update draft documents, provide the memo and footer values containing {variables} to ensure the resulting formatted strings remain up-to-date.

Retrieving variables

Certain variables are document-specific and can only be used on a particular document. You can retrieve variables depending on the document type. Tesouro provides separate endpoints to retrieve Payable, Purchase order, and Receivable document variables.

Payables

To retrieve variables associated with Payables, call GET /payables/variables:
The successful response returns an object containing an array of variable names and descriptions associated with payables.

Purchase orders

To retrieve variables associated with Purchase order documents, call GET /payable-purchase-orders/variables:
The successful response returns an object containing an array of variable names and descriptions associated with purchase orders.

Receivables

To retrieve variables associated with Accounts Receivable documents, call GET /receivables/variables:
The successful response returns an object containing an array of variable names and descriptions associated with each receivable document type (invoices, quotes, credit notes, etc.) and invoice reminders.

Variable list

When retrieving document variables, their responses include an object_type and object_subtype field that differentiates each document type. The following table shows the object_type values and their corresponding possible object_subtype values and descriptions:

Common variables

These variables are available for all document types, unless noted otherwise:

Additional variables for payables

In addition to the common variables, payables can use the following variables:

Additional variables for purchase orders

In addition to the common variables, purchase orders can use the following variables:

Additional variables for invoices

In addition to the common variables, outgoing invoices can use these variables:

Additional variables for quotes

In addition to the common variables, quotes can use the following variables:

Additional variables for credit notes

In addition to the common variables, credit notes can use these variables:

Additional variables for invoice reminders

Variables for invoice reminders are available in the response from the GET /receivable/variables endpoint. These variables have an object_type value of reminder. The possible object_subtype value for these variables include discount_reminder, final_reminder, and overdue_reminder.

Payment reminders

Payment reminders refer to reminder emails sent to a counterpart before the invoice’s due dates and early discount dates. In addition to the common variables, invoice payment reminders can include the following variables in their email subject and body.

Overdue reminders

In addition to the common variables, overdue reminders can include the following variables in their email subject and body: