> For the complete documentation index, see [llms.txt](https://docs.reo.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reo.dev/integrations/input-sources/api-based-integration/custom-product-events-api/aggregated-events.md).

# Aggregated Events

From the product's cloud instance, we get aggregated usage data that provides consolidated metrics for better insights into product usage patterns. This API enables ingestion of aggregated product data with two distinct modes:

**Domain Mode**: Aggregate usage data at the company level.

**User Mode**: Aggregate usage data at the individual user level.&#x20;

{% hint style="info" %}
**Important Note:** The Product API integration is fully dependent on the configuration of custom metrics in the **Product Usage Settings**.\
Without these metrics, data sent via the API will not be received or processed in the Reo.Dev platform. Please refer to [How to Configure Product Usage Metrics in Settings](/configurations/product-usage.md) to ensure your metrics are correctly set up before implementing the Product API.
{% endhint %}

### API Structure

| Header       | Description                                             | Data type |
| ------------ | ------------------------------------------------------- | --------- |
| X-API-KEY    | Generated Reo.Dev `<API_KEY>` for authorization.        | string    |
| Content-Type | Request content-type is always set to application/json. | string    |

**Endpoint**: [`https://ingest.reo.dev/api/product/aggregateusage`](https://ingest.reo.dev/api/product/aggregateusage)

**Method**: `POST`

**Content-Type**: `application/json`

### Domain Mode Example

```
curl --location 'https://ingest.reo.dev/api/product/aggregateusage' \
--header 'X-API-KEY: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
  "payload": {
    "mode": "DOMAIN",
    "activity_type": "DEMO_LOGIN",
    "source": "PRODUCT_CLOUD",
    "environment": "PRODUCTION",
    "event_id": 1231231232,
    "event_at": 639303296,
    "user_id": "",
    "user_id_type": "",
    "count": 1250,
    "domain": "reo.dev",
    "ip_addr": "",
    "product_id": "reoWebApp",
    "user_agent": "Mozilla/5.0 (Macintosh, Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "meta": {
      "property1": "value1",
      "property2": "value2"
    }
  }
}'

```

### User Mode Example

```
curl --location 'https://ingest.reo.dev/api/product/aggregateusage' \
--header 'X-API-KEY: <API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
  "payload": {
    "mode": "USER",
    "activity_type": "probe",
    "source": "PRODUCT_CLOUD",
    "environment": "PRODUCTION",
    "event_id": 1231231232,
    "event_at": 639303296,
    "user_id": "brian@reo.dev",
    "user_id_type": "EMAIL",
    "count": 40,
    "domain": "",
    "ip_addr": "",
    "product_id": "reoWebApp",
    "user_agent": "Mozilla/5.0 (Macintosh, Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "meta": {
      "property1": "value1",
      "property2": "value2"
    }
  }
}'

```

### Tenant API Key

To access your API key, navigate to: **Settings →Configurations → API Keys → Product Usage API**

Note: Only users with Admin Role in Reo.Dev can access the API Keys

### Parameters

| Parameter                                      | Description                                                                                                                                 | Data Type | Possible Values                                     | Example                                                             |
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------- | --------------------------------------------------- | ------------------------------------------------------------------- |
| **mode** (Required)                            | Aggregation mode for the data                                                                                                               | enum      | `DOMAIN`, `USER`                                    | `"DOMAIN"`                                                          |
| **source** (Required)                          | Source of the activity                                                                                                                      | enum      | `PRODUCT_CLOUD`                                     | `"PRODUCT_CLOUD"`                                                   |
| **activity\_type** (Required)                  | Usage Metrics of the product. The definition of primary, secondary1, secondary2, should match with metrics defined in the Reo.Dev settings. | string    | Keys defined in metrics                             | `"LOGIN_ACTIVITY"`                                                  |
| **environment** (optional)                     | Environment where product has been deployed                                                                                                 | string    |                                                     | `"PRODUCTION"`                                                      |
| **user\_id\_type** (mandatory)                 | Type of user ID such as email, Social, LinkedIn, GitHub, Username                                                                           | enum      | `EMAIL`, `SOCIAL`, `LINKEDIN`, `GITHUB`, `USERNAME` | `"EMAIL"`                                                           |
| **user\_id** (mandatory)                       | Unique user ID captured for a customer                                                                                                      | string    |                                                     | `"brian@reo.dev"`                                                   |
| **count** (mandatory)                          | Aggregated count of the activity/usage                                                                                                      | integer   |                                                     | `1250`                                                              |
| <p><strong>ip\_addr</strong><br>(optional)</p> | IP address of the system from where the user has logged in.                                                                                 | string    |                                                     | `"192.127.0.0”`                                                     |
| **domain** (optional)                          | Domain associated with the user or activity                                                                                                 | string    |                                                     | `"reo.dev"`                                                         |
| **event\_id** (optional)                       | A unique identifier for this API call                                                                                                       | string    |                                                     | `1231231232`                                                        |
| **event\_at** (mandatory)                      | The time at which this API request was triggered (Formatted as a UNIX epoch in seconds)                                                     | integer   |                                                     | `639303296`                                                         |
| **product\_id** (Required)                     | Unique identifier of your product                                                                                                           | string    |                                                     | `"reoWebApp"`                                                       |
| **user\_agent** (optional)                     | Additional browser properties                                                                                                               | string    |                                                     | `"Mozilla/5.0 (Macintosh, Intel Mac OS X 10_15_7)...Safari/537.36"` |
| **meta** (optional)                            | Any other parameter that needs to be sent                                                                                                   | object    |                                                     | `{"property1":"value1","property2":"value2"}`                       |

### Sample JSON Request (Domain Mode)

```
{
  "payload": {
    "mode": "DOMAIN",
    "activity_type": "secondary23",
    "source": "PRODUCT_CLOUD",
    "environment": "PRODUCTION",
    "event_id": 1231231232,
    "event_at": 639303296,
    "user_id": "",
    "user_id_type": "",
    "count": 1250,
    "domain": "www.reo.dev",
    "ip_addr": "",
    "product_id": "reoWebApp",
    "user_agent": "Mozilla/5.0 (Macintosh, Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "meta": {
      "property1": "value1",
      "property2": "value2"
    }
  }
}

```

### Sample JSON Request (User Mode)

<pre><code><strong>{
</strong>  "payload": {
    "mode": "USER",
    "activity_type": "LOGIN_ACTIVITY",
    "source": "PRODUCT_CLOUD",
    "environment": "PRODUCTION",
    "event_id": 1231231232,
    "event_at": 639303296,
    "user_id": "brian@reo.dev",
    "user_id_type": "EMAIL",
    "count": 1250,
    "domain": "",
    "ip_addr": "",
    "product_id": "reoWebApp",
    "user_agent": "Mozilla/5.0 (Macintosh, Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    "meta": {
      "property1": "value1",
      "property2": "value2"
    }
  }
}

</code></pre>

### Sample JSON Response \[Success]

```
{
  "response_code": "200",
  "response": "Aggregated Data Uploaded",
  "status": "success"
}

```

### Sample JSON Response \[Wrong API Key]

```
{
  "response_code": 400,
  "response": "Authentication Failure",
  "status": "failure"
}

```

### Sample JSON Response \[Invalid Mode]

```
{
  "response_code": 400,
  "response": "Invalid mode. Supported modes: DOMAIN, USER",
  "status": "failure"
}
```


---

# 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.reo.dev/integrations/input-sources/api-based-integration/custom-product-events-api/aggregated-events.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.
