You can narrow down the report data by adding the filters array to your POST request body.
Supported filters are report-specific
API v2 lets you filter by both dimensions and metrics, but each report can have its own set of supported filters. For example, it can support filtering by dimensions only. Check the report documentation under Available reports to see which filters you can use.
- Run the GET report options operation for more information on available filters. If a dimension or a metric is labeled as
filterable: true, you can filter by it. If a dimension or a filter is labeled asmandatory: true, you have to use it as a filter. The report options also show the filter type,TEXTorENUM, and, in case ofENUMfilters, available filter values. Example:
{
"name": "responseClass",
"type": "STRING",
"filterable": true,
"mandatory": false,
"filterType": "ENUM",
"filterEnumValues": [
"0xx",
"1xx",
"2xx",
"3xx",
"4xx",
"5xx",
"6xx"
],
"authorizable": false
}
-
Add each filter as an object to the
filtersarray in the POST request body.- To filter by a dimension, include:
| Field | Type | Description |
|---|---|---|
dimensionName | String | Name of the dimension for which you want to filter. For example, cpcode. |
operator | String | The filtering logic. One of:
ENUM type, you can only use the IN_LIST and NOT_IN_LIST operators. |
expressions | Array of strings | Filter values. If the filter type is ENUM, the report options show available values you can use. |
- To filter by a metric, include:
| Field | Type | Description |
|---|---|---|
metricName | String | Name of the metric for which you want to filter. For example, edgeHitsSum. |
operator | String | The filtering logic. One of:
|
expression | String or number | Filter value. |
To filter by a metric, you need to include it in the metrics array in the request body.
- Example:
"filters": [ { "dimensionName": "cpcode", "operator": "IN_LIST", "expressions": [ "1849", "2084", "2577", "3004" ] }, { "metricName": "edgeHitsSum", "operator": "GREATER_THAN", "expression": "1" } ]
Some filter values authorize your access to data
Dimensions marked as
authorizable: truein the report options authorize your access to data. When filtering by such dimensions, you can only use objects to which you are authorized. For example, only the CP codes to which you have access in Control Center. If you use any other objects, your API call will result in an error.
