# Metering Elements

## Metering Elements Overview

### Monetization Use Case

Metering Elements are commonly used in monetization when a transactional pricing model is not detailed enough for the service you are selling. A common scenario for element usage is when certain activities cost you far more to deliver than others, and where you wish to scale costs for users based on different types of usage.

For example, imagine that you operate a shipping tracking service, and you want to charge a subscription fee based on how many regions that an end subscriber accessed in a subscription period. In this example, you don't want to charge transactionally, but instead you will charge a flat fee per region accessed. You can accomplish this type of pricing model using Metering Elements.

### Metering Element Auto-Creation

{% hint style="info" %}
Metering elements are created automatically when detected in your traffic. If you wish to create specific elements manually before sending traffic containing them, you can do so using the instructions below. You can disable this functionality using a toggle on the metering elements page (though in general we don't recommend you do this as it requires more manual setup)
{% endhint %}

### Steps to Enable Element-Based Pricing Models:

1. If not using auto-creation for metering elements, create the metering element key value pair using the instructions on this page.
2. Configure the relevant source with the metering elements you desire Revenium to monitor on the [Source](/ai-and-api-monetization/assets.md) configuration page. This allows the transaction engine to capture metering element information involving transactions from the targeted sources.
3. Add element-based pricing to your [Product](/ai-and-api-monetization/products.md) configuration (note, the sources configured in step 2 must be included in the Product). This will tell the Revenium metering engine how to charge the end subscriber when the metering elements are received.

### Manually Creating & Managing Metering Elements

Click the 'plus' sign or 'edit' icon to create or manage existing elements respectively. A modal will open allowing you to create or edit an existing Metering Element. (Figure 2)

<figure><img src="/files/CQC5RjvkNqKplLXyDGX2" alt=""><figcaption><p>Figure 2: Create Metering Elements</p></figcaption></figure>

| Attribute               | Usage                                                                                                                                                                                                                      |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Element Description** | A human readable value that will help you to identify the purpose of the element when viewed in reports, on invoices, etc.                                                                                                 |
| **Element Key Name**    | The key in the JSON key-value pair that makes up the element. Revenium will look for this key & value in the data you send and rate it according to the pricing rules you define in the Product.                           |
| **Element Type**        | Defining your element as a string or number enables different Product billing models like 'max' or 'average' value calculations. If your use case will contain a mix of numbers and strings, define the value as a string. |

### Analytics Use Case

If you simply wish to capture the usage of different query parameters in your API calls, the configuration is exactly the same as the monetization use case, with the exception of Step 3. There is no need to define a pricing model for metering element usage if you are not charging subscribers based on the elements sent to Revenium.

## Sending Element Usage Data to Revenium

You can send test element data to the Revenium platform using a curl call like the one below.

{% hint style="info" %}
*Note that our* [*Data Connectors* ](/ai-and-api-monetization/readme.md)*have built in capabilities to convert query parameters and their values into metering element data as well.*
{% endhint %}

Note that the `url` parameter in the data block below must match the resource configuration on the related [Source](/ai-and-api-monetization/assets.md) for the element to be metered properly (see image below for an example)

```bash
// Sending element data to Revenium

curl --verbose --request POST \
     --url 'https://api.revenium.io/meter/v1/api/meter' \
     --header 'content-type: application/json' \
     --header 'x-api-key: ENTER_APIKEY_HERE' \
     --data '
{
  "url": "https://test-asset-url.com/test/",
  "application": "any_application_id",
  "contentType": "application/json",
  "httpProtocol": "HTTP/1.0",
  "method": "POST",
  "responseCode": 200,
  "elements": [{"name": "yourElementName",
                "value": "yourElementValue"}]
}

```

<figure><img src="/files/UJjm2wFItq419ZeYLZjJ" alt=""><figcaption><p>Example of a source configuration that would allow the metering elements in this call to be metered properly.</p></figcaption></figure>


---

# 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.revenium.io/ai-and-api-monetization/assets/metering-elements.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.
