# Get transaction metrics

`GET /v1/organizations/{organizationId}/product-classifications/{productClassificationId}/transaction-metrics`

Available as MCP tool `get-org-product-metrics` (Read).

> **Deprecating soon**
>
> This endpoint will be deprecated soon. Talk to your Technical Account Manager about migrating or using new endpoints for this function. 

Transaction usage endpoints allow you to review and export transaction usage data for your current Redox contract. This allows you to easily monitor your usage and limits as you go.   

You can get details for all the Redox product(s) in your contract, retrieve metrics by product type, and export metrics.

### Get transaction metrics

> **Deprecating soon**
>
> This endpoint will be deprecated soon. Talk to your Technical Account Manager about migrating or using new endpoints for this function. 

Retrieve transaction usage metrics of your organization's Redox product(s) for a particular time range or connection. Metrics include counts of total transactions or transactions over time. 

You can modify the query by date range, duration (i.e., day or month), or connection.

## Request parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `organizationId` | path | string | Yes | Identifies the Redox organization that you're operating in. |
| `productClassificationId` | path | string | Yes | Contains the UUID of the product classification that you want to retrieve transaction counts for. |
| `startDate` | query | string | Yes | Contains the date-time in ISO 8601 format to define the beginning of the date range for the transaction metrics you want to review. |
| `endDate` | query | string | Yes | Contains the date-time in ISO 8601 format to define the end of the date range for the transaction metrics you want to review. The end date-time is exclusive, which means results may be returned up to this date-time, but not including it. |
| `aggregateBy` | query | string | Yes | Defines the period of time for transaction counts over time, whether by day or month. |
| `connectionId` | query | number | No | Contains the connection ID for filtering counts and over-time data to a specific connection. |

## Request example

```bash
curl 'https://api.redoxengine.com/platform/v1/organizations/{organizationId}/product-classifications/{productClassificationId}/transaction-metrics' \
--request GET \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'accept: application/json'
```

## Responses

### 200

This endpoint returns a `payload` object containing transaction count data for a given Redox product by the defined request parameters.

Contains the payload and metadata returned for `Get transaction metrics`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `meta` | object | No |  |
| `meta.version` | string | No | Lists the major and minor version number for the format of the returned payload. The payload format or shape may change between minor versions, like including additional or extended fields in later versions. We include the version data in each response so that you have the option to handle the signaled differences. |
| `payload` | object | No |  |
| `payload.salesforceSubscription` | object | No | Contains an object with key details about an organization's Redox product subscription in the CRM (i.e., Salesforce). |
| `payload.salesforceSubscription.productClassificationId` | string | No | Displays a UUID for the Redox ID for the product classification. |
| `payload.salesforceSubscription.productClassificationName` | string | No | Displays the human-readable, internal name in the CRM for the Redox product classification. |
| `payload.salesforceSubscription.limit` | number | No | Defines the number of transactions purchased for the Redox product within the selected limit type. |
| `payload.salesforceSubscription.consumptionPeriod` | string | No | Defines the time window for the transaction limit. `Month` and `Annual` mean that transaction usage limit resets each calendar month or year respectively. `Contract Term` means that the transaction usage doesn't reset; instead, the limit lasts for the duration of the contract. Possible values: Annual, Contract Term, Month |
| `payload.salesforceSubscription.startDate` | string | No | Contains the date-time in ISO 8601 format to define the start of the Redox product contract. |
| `payload.salesforceSubscription.endDate` | string | No | Contains the date-time in ISO 8601 format to define the end of the Redox product contract. |
| `payload.salesforceSubscription.resetDate` | string | No | Contains the date-time in ISO 8601 format to indicate the next time that the transaction limit window resets. |
| `payload.startDate` | string | No | Contains the date-time in ISO 8601 format to define the start of the date range for results. |
| `payload.endDate` | string | No | Contains the date-time in ISO 8601 format to define the end of the date range for results. The end date-time is exclusive, which means results may be returned up to this date-time, but not including it. |
| `payload.totalProductTransactions` | number | No | Lists the total number of transactions for the Redox product within the time range, regardless of any metadata filters or request parameters (e.g., connection ID). |
| `payload.aggregateMetrics` | object | No | Contains the properties for total count and over-time data points for log metrics. |
| `payload.aggregateMetrics.totalCount` | number | No | Displays the total number of transactions over the time range with all filters or request parameters applied (e.g., connection ID). |
| `payload.aggregateMetrics.dataPoints` | Array of object | No | Displays the over-time data points within the specified time range. |
| `payload.aggregateMetrics.dataPoints[].startDateTime` | string | No | Contains the date-time in ISO 8601 format to define the start of the date range for this data point. |
| `payload.aggregateMetrics.dataPoints[].endDateTime` | string | No | Contains the date-time in ISO 8601 format to define the end of the date range for this data point. The end date-time is exclusive, which means results may be returned up to this date-time, but not including it. |
| `payload.aggregateMetrics.dataPoints[].count` | number | No | Defines the total count of logs that occurred within the specified date range of this data point. |
| `payload.aggregateMetrics.dataPoints[].cumulativeSum` | number | No | Defines the total sum of logs that have occurred up to the end of this data point's date range, including all prior data points. |

_Generated from the schema: the values are placeholders, not a real payload._

```json
{
  "meta": {
    "version": "1.0.0"
  },
  "payload": {
    "salesforceSubscription": {
      "productClassificationId": "4d1d5191-7d62-4f29-a26e-3e28d9082a3a",
      "productClassificationName": "cm_access_ceq",
      "limit": "4d1d5191-7d62-4f29-a26e-3e28d9082a3a",
      "consumptionPeriod": "Month",
      "startDate": "2023-01-01",
      "endDate": "2023-12-31",
      "resetDate": "2023-12-31"
    },
    "startDate": "2023-01-01T00:00:00.000Z",
    "endDate": "2024-01-01T00:00:00.000Z",
    "totalProductTransactions": 21478,
    "aggregateMetrics": {
      "totalCount": 21478,
      "dataPoints": [
        {
          "startDateTime": "2023-01-01T00:00:00.000Z",
          "endDateTime": "2023-02-01T00:00:00.000Z",
          "count": 9056,
          "cumulativeSum": 36803
        }
      ]
    }
  }
}
```

### 400

Bad Request

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Bad Request`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Bad Request",
      "code": "validation.error.bad.request",
      "detail": "Error details",
      "status": 400,
      "transient": false
    }
  }
}
```

### 500

Internal Server Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payload` | object | No | Contains the error message. |
| `payload.error` | object | No | Contains the error message details. |
| `payload.error.title` | string | No | Displays the high-level error message, typically something succinct like `Failed in step X`. |
| `payload.error.code` | string | No | Contains an alternative ID for the error type, which can be used to find relevant troubleshooting information. |
| `payload.error.detail` | string | No | Contains the specific error details for this message. |
| `payload.error.status` | number | No | Displays the corresponding HTTP status code for the error. |
| `payload.error.transient` | boolean | No | Describes whether the error will resolve itself. If `true`, no further action needs to be taken. If `false`, you may need to troubleshoot on your end to resolve the issue before the error can be processed. |

```json
{
  "payload": {
    "error": {
      "title": "Internal Server Error",
      "code": "failed.db.lookup",
      "detail": "Error details",
      "status": 500,
      "transient": true
    }
  }
}
```
