--- title: "Custom Report" slug: "custom-report" updated: 2022-12-20T16:10:57Z published: 2022-12-20T16:10:57Z canonical: "developer.comm100.com/custom-report" --- > ## Documentation Index > Fetch the complete documentation index at: https://developer.comm100.com/llms.txt > Use this file to discover all available pages before exploring further. # Query ## Query - `Query` - Report queries - `POST /reporting/query` - [Query report data](/docs/custom-report#query-report-data) ### Query Report Data `POST /reporting/query` - #### Request Parameters: | Name | Type | In | Required | Description | | --- | --- | --- | --- | --- | | `datasetId` | string | body | yes | Id of the dataset which need to query report. | | `filters` | [Filter](/docs/custom-report#query-filter-json-format)[] | body | yes | Which filter conditions should be applied to the dataset when calculating the results of the metric. When there are multiple filters, the relationship between multiple filters is `AND`. | | `groupBys` | [GroupBy](/docs/custom-report#query-groupby-json-format)[] | body | yes | Which groups should be applied to the dataset. | | `metrics` | [Metric](/docs/custom-report#query-metric-json-format)[] | body | yes | Which metrics should be calculated and displayed in the results. | | `timeZone` | string | body | yes | When time-related fields are needed to calculate report results, which time zone is used to calculate time. Available items includes all [Time Zone Option](/server-api-introduction#time-zone-options). | - #### Query Filter JSON Format Filter is represented as simple flat JSON objects with the following keys: | Name | Type | Description | | --- | --- | --- | | `attributeId` | string | The id of the attribute which should be applied to the dataset. | | `filterValues` | string[] | Values of the attribute which should be applied to the dataset. When there are multiple values, the relationship between the multiple values is `OR`. When attribute type is `datetime`, the first value is the start time, and the second value is the end time. | - #### Query GroupBy JSON Format GroupBy is represented as simple flat JSON objects with the following keys: | Name | Type | Description | | --- | --- | --- | | `attributeId` | string | The id of the dataset attribute which used to group in the report. | | `name` | string | The name of the GroupBy. This will be used as the field name of the result. | | `timeDisplayType` | string | Available when attribute is the type of `datetime` only. Available items are: `day`, `week`, `month`, `quarter`, `year`, `hourOfDay`, `dayOfWeek`, `dayOfMonth`, `monthOfYear`, `quarterOfYear`. The result set will have different values for this field. | - #### Query Metric JSON Format Metric is represented as simple flat JSON objects with the following keys: | Name | Type | Description | | --- | --- | --- | | `metricId` | string | The id of the dataset metric which needs to be queried in the report. | | `name` | string | Name of the metric. This will be used as the key field in the result set. | | `aggregator` | enum | Must be one of metric's `availableAggregators`. | - #### Response: A list of query results grouped by the specified groups. The fields determined based on the `groupBys` and `metrics` in the query request body. - #### Example When you want to get the number of chats of a specific agent and present the results by day, you only need to simply configure the query request and configure it in the corresponding field. - Request ``` curl https://api11.comm100.io/reporting/query?siteid=10000 \ -X 'GET' \ -H 'Authorization: Bearer {access_token}' \ -H 'Content-Type: application/json' \ -D '{ "dataSetId": "Chat", "metrics": [ { "metricId": "Chats", "aggregator": "count", "name": "chats_count" } ], "groupBys": [ { "attributeId": "ChatRequestedTime", "timeDisplayType": "day", "name": "chatrequestedtime_day" } ], "filters": [ { "attributeId": "ChatAgent", "filterValues": [ "67f44eb6-34f3-46d9-afe5-310ee7607368" ] } ], "timeZone": "Iran Standard Time" }' ``` - Response `HTTP/1.1 200 OK` ``` [ { "chats_count": 1, "chatrequestedtime_day": "2022-09-30" }, { "chats_count": 0, "chatrequestedtime_day": "2022-10-01" }, ... ] ```