# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
