Overview
Payables, Receivables, Entity, Counterpart, and Counterpart bank account objects can have arbitrary metadata associated with them. Monite API Partners can use metadata to store additional structured information about these objects, such as the object IDs from other systems. Receivables’ metadata can also be used in emails. The way to work with metadata varies depending on the object type. Refer to the corresponding section below:Entity and counterpart metadata
The metadata is not part of theEntity and Counterpart objects themselves. Instead, it is accessed via the /partner_metadata subresource of the corresponding resources:
Metadata format
The<resource>/partner_metadata endpoint accepts and returns the metadata in the following format, where metadata can be an arbitrary JSON object up to 2000 bytes in size:
Set metadata
UsePUT <resource>/partner_metadata to add metadata or replace existing metadata for a specific entity or counterpart. For example:
200 OK response means the metadata was successfully saved. If the metadata exceeds the 2 KB limit, a 422 response is returned.
Get metadata
UseGET <resource>/partner_metadata to get existing metadata for a specific entity or counterpart. For example:
metadata field in the response is an empty object {}.
Partially update metadata
If you need to add, modify, or delete individual fields within a metadata object, you can use this approach:- Call
GET <resource>/partner_metadatato read existing metadata. - Modify the returned object as needed.
- Call
PUT <resource>/partner_metadatato save the modified metadata.
Delete metadata
To delete the metadata associated with a specific entity or counterpart, you can callPUT <resource>/partner_metadata and pass an empty object {} as the metadata value:
Payables, receivables, and counterpart bank account metadata
Metadata format
Payable, Receivable, and Counterpart Bank Account objects have the partner_metadata field to store partner-provided metadata. The value can be an arbitrary JSON object up to 2000 bytes in size:
Example: Payable object metadata
partner_metadata field returns an empty object—{}.
Set metadata
When creating a payable, receivable, or counterpart bank account, you can provide the metadata by using thepartner_metadata field directly in the request object as shown:
Example: Set metadata for a payable
PATCH request to the respective endpoint and including the partner_metadata field as shown:
Example: Update metadata of a payable
Get metadata
To retrieve the metadata of a payable, receivable, or counterpart bank account, send aGET request to the corresponding resource.
The following snippet demonstrates a response from the GET /payables request, which includes the partner_metadata of each payable:
Partially update metadata
To add, modify, or delete individual fields within the metadata of aPayable, Receivable, or Counterpart Bank Account object, you can use this approach:
- Retrieve the object by using the corresponding
GETrequest (such asGET /payables/{payable_id}). - Extract the
partner_metadataresponse field to get existing metadata. - Modify the
partner_metadatavalue as needed. - Send a
PATCHrequest to update the object and provide the updatedpartner_metadatavalue in the request.
Delete metadata
To delete existing metadata from aPayable, Receivable or Counterpart Bank Account object, send a PATCH request to the corresponding endpoint and set partner_metadata to an empty object {} as shown:
Example: Delete a payable's metadata
Use metadata in email templates
This feature is supported only for receivables: invoices, quotes, and credit notes.
partner_metadata are automatically exposed as variables for use in emails and email templates.
These variable names are in the format
<key> is the name of a field inside partner_metadata.
Only top-level metadata keys with primitive values (strings, numbers, booleans) are exposed as email template variables.
Nested keys and keys with array or object values are not exposed as variables.
Since metadata keys can vary per receivable, the {{partner_metadata.<key>}} variables are evaluated at the moment when emails are composed to be sent.
Variable names that refer to non-existing metadata keys do not raise errors but evaluate to an empty string.
Example
Consider an invoice with the following metadata:{{partner_metadata.dashboard_link}}{{partner_metadata.reference}}{{partner_metadata.priority}}{{partner_metadata.is_vip}}
extra and labels metadata keys are not exposed as variables because they are not primitives.
The following example includes {{partner_metadata.dashboard_link}} in the email body contents:
POST /mail_templates