> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.monite.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.monite.com/_mcp/server.

# Metadata

## Overview

[Payables](../references/glossary#payable), [Receivables](../accounts-receivable/index), [Entity](../entities/index), [Counterpart](./counterparts/index), and [Counterpart bank account](./counterparts/bank-accounts) 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](#email-templates).

The way to work with metadata varies depending on the object type. Refer to the corresponding section below:

* [Entity and counterpart metadata](#entity-and-counterpart-metadata)
* [Payables, receivables, and counterpart bank account metadata](#payables-receivables-and-counterpart-bank-account-metadata)

## Entity and counterpart metadata

The metadata is not part of the `Entity` and `Counterpart` objects themselves. Instead, it is accessed via the `/partner_metadata` subresource of the corresponding resources:

```
/entities/{entity_id}/partner_metadata

/counterparts/{counterpart_id}/partner_metadata
```

Use the HTTP PUT method to set the metadata, and GET to read it.

### Metadata format \[#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:

```json
{
  "metadata": {

    // Metadata goes here
    "custom_field_1": "value",
    "custom_field_2": 42,
    "custom_field_3": true,
    ...

  }
}
```

### Set metadata \[#set]

Use `PUT <resource>/partner_metadata` to add metadata or replace existing metadata for a specific entity or counterpart. For example:

```sh
curl -X PUT 'https://api.sandbox.monite.com/v1/counterparts/3a9c5...8df/partner_metadata' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "metadata": {
         "external_id": "id_6c8f1262fdbc",
         "comment": ""
       }
     }'
```

A `200 OK` response means the metadata was successfully saved. If the metadata exceeds the 2 KB limit, a `422` response is returned.

### Get metadata \[#get]

Use  `GET <resource>/partner_metadata` to get existing metadata for a specific entity or counterpart. For example:

```sh
curl -X GET 'https://api.sandbox.monite.com/v1/counterparts/3a9c5...8df/partner_metadata' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: ACCESS_TOKEN'
```

If there is no metadata associated with the specified entity or counterpart, the `metadata` field in the response is an empty object `{}`.

### Partially update metadata \[#partial-update]

If you need to add, modify, or delete individual fields within a metadata object, you can use this approach:

1. Call  `GET <resource>/partner_metadata` to read existing metadata.
2. Modify the returned object as needed.
3. Call `PUT <resource>/partner_metadata` to save the modified metadata.

### Delete metadata \[#delete]

To delete the metadata associated with a specific entity or counterpart, you can call `PUT <resource>/partner_metadata` and pass an empty object `{}` as the `metadata` value:

```sh
curl -X PUT 'https://api.sandbox.monite.com/v1/counterparts/3a9c5...8df/partner_metadata' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{"metadata": {}}'
```

## Payables, receivables, and counterpart bank account metadata

### Metadata format \[#format-2]

`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`**

```json Example: Payable object metadata
{
  "currency": "EUR",
  ...

  "partner_metadata": {
    "custom_field_1": "value",
    "custom_field_2": 42,
    "custom_field_3": true,
    ...
  }
}
```

If there is no metadata associated with a specific payable, receivable, or bank account, the `partner_metadata` field returns an empty object—`{}`.

### Set metadata \[#set-2]

When creating a payable, receivable, or counterpart bank account, you can provide the metadata by using the `partner_metadata` field directly in the request object as shown:

**`Example: Set metadata for a payable`**

```sh Example: Set metadata for a payable
curl -X POST 'https://api.sandbox.monite.com/v1/payables' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: Bearer ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "currency": "EUR",
       "amount": 11900,
       ...
       "partner_metadata": {
         "external_id": "id_6c8f1262fdbc",
         "comment": ""
       }
     }'
```

In case of already existing payables, receivables, or counterpart bank accounts, you can add metadata by sending a `PATCH` request to the respective endpoint and including the `partner_metadata` field as shown:

**`Example: Update metadata of a payable`**

```sh Example: Update metadata of a payable
curl -X PATCH 'https://api.sandbox.monite.com/v1/payables/aa314...5c0' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: Bearer ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{
       "partner_metadata": {
         "external_id": "id_6c8f1262fdbc",
         "comment": ""
       }
     }'
```

### Get metadata \[#get-2]

To retrieve the metadata of a payable, receivable, or counterpart bank account, send a `GET` request to the corresponding resource.

The following snippet demonstrates a response from the [`GET /payables`](/api/payables/get-payables) request, which includes the `partner_metadata` of each payable:

```json
{
  "data": [
    {
      "id": "aa314fdd-a763-4920-a8c8-6285fc1745c0",
      ...
      "partner_metadata": {
        "external_id": "id_6c8f1262fdbc",
        "comment": ""
      }
    },
    {
      "id": "f6d57e58-5703-47d4-80c0-2aa2ba0b36c4",
      ...
      "partner_metadata": {}
    },
    ...
  ],
  "prev_pagination_token": null,
  "next_pagination_token": null
}
```

### Partially update metadata \[#partial-update-2]

To add, modify, or delete individual fields within the metadata of a `Payable`, `Receivable`, or `Counterpart Bank Account` object, you can use this approach:

1. Retrieve the object by using the corresponding `GET` request (such as `GET /payables/{payable_id}`).
2. Extract the `partner_metadata` response field to get existing metadata.
3. Modify the `partner_metadata` value as needed.
4. Send a `PATCH` request to update the object and provide the updated `partner_metadata` value in the request.

### Delete metadata \[#delete-2]

To delete existing metadata from a `Payable`, `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`**

```sh Example: Delete a payable's metadata
curl -X PATCH 'https://api.sandbox.monite.com/v1/payables/aa314...5c0' \
     -H 'X-Monite-Version: 2024-05-25' \
     -H 'X-Monite-Entity-Id: ENTITY_ID' \
     -H 'Authorization: Bearer ACCESS_TOKEN' \
     -H 'Content-Type: application/json' \
     -d '{ "partner_metadata": {} }'
```

### Use metadata in email templates \[#email-templates]

> **Note**
>
> This feature is supported only for [receivables](../accounts-receivable/index): invoices, quotes, and credit notes.

Most keys defined in a receivable's `partner_metadata` are automatically exposed as [variables](../advanced/variables) for use in emails and [email templates](../advanced/email-templates/index).
These variable names are in the format

```
{{partner_medatata.<key>}}
```

where `<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:

```json
"partner_metadata": {
  "dashboard_link": "https://myapp.example.com/invoices/123",
  "reference": "deal-ref",
  "priority": 3,
  "is_vip": true,

  "extra": {
    "key": "value"
  },
  "labels": ["marketing", "contract"]
}
```

You can use the following additional variables in email templates:

* `{{partner_metadata.dashboard_link}}`
* `{{partner_metadata.reference}}`
* `{{partner_metadata.priority}}`
* `{{partner_metadata.is_vip}}`

The `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`**

```json title="POST /mail_templates"
{
  "type": "receivables_invoice",
  "name": "New invoice template",
  "language": "en",
  "is_default": true,

  "subject_template": "Invoice {{invoice_number}} from {{entity_name}}",
  "body_template": "<!DOCTYPE html><html lang=\"en\"><body>... <a href=\"{{partner_metadata.dashboard_link}}\" target=\"_blank\">View invoice</a> ...</body></html>"
}
```

## See also

* [Tags](./tags) - add user-defined tags (labels) to various resources to categorize them.
* [Projects](./projects) - group related documents into projects.