> For the complete documentation index, see [llms.txt](https://docs.lahza.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lahza.io/payments/metadata.md).

# Metadata

### Designing Metadata

With metadata, you can include extra parameters that may not be naturally supported by an endpoint. The process of creating metadata depends on how your programming language handles JSON. Some commonly used metadata includes:

* Invoice ID
* Cart ID
* Cart Items

There are two methods to include parameters in the metadata object:

1. **Key/value pair**: To include a parameter using this method, you pass it as a key/value pair. For example, "cart\_id: 928324". Parameters passed in this way may not be visible on the dashboard, but they are included in the API response.
2. **Custom Fields:** The "custom\_fields" key is specifically designated for an array of custom fields that will be displayed on the dashboard when you click on the transaction.

\
Custom fields consist of three keys: "display\_name", "variable\_name", and "value". The "display\_name" represents the label or name associated with the displayed value.

{% code overflow="wrap" lineNumbers="true" %}

```json
"metadata":{
  "cart_id":1,
  "custom_fields":[
    {
      "display_name":"Invoice ID",
      "variable_name":"Invoice ID",
      "value":122
    },
    {
      "display_name":"Cart Items",
      "variable_name":"cart_items",
      "value":"Coffee"
    }
  ]
}
```

{% endcode %}

### Cancel Action <a href="#cancel-action" id="cancel-action"></a>

To redirect users to a specific URL when they cancel a payment, you can utilize the "cancel\_action" attribute within your metadata.

{% code overflow="wrap" lineNumbers="true" %}

```json
"metadata": {
  "cancel_action": "https://example.com"
}
```

{% endcode %}

<br>

<br>

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.lahza.io/payments/metadata.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
