This article provides sample API calls to manipulate Reports.
PREREQUISITES:
- Set up API access.
- Verify that you have API access.
- Obtain a token via a get token call since all API calls require a token.
Table of contents:
1. Retrieve a Report
- The GET request to
/api/reportretrieves all Reports. - The GET request to
/api/report/id/<id>retrieves the specified Report.
- Item: report.
- Method: GET.
- ID: Specify Report ID to retrieve data only for that Report.
- Report ID can be obtained from the URL of the Report Editor:
<hostname>/editor/element/report/152753.
- Report ID can be obtained from the URL of the Report Editor:
- Enter API token.
- [Run Request]
Example Response
{
"reports": [
{
"id": 1197,
"keep_history": "Y",
"dataset_id": 147,
"dataset_filter_id": 0,
"measurement_interval": 3,
"dimension": 0,
"name": "CNN Daily News",
"description": "CNN Daily News",
"category": 62,
"max_time_before_expired_period": 1,
"max_time_before_expired_unit": "day",
"can_be_viewed_without_login": "N",
"include_metric_data_table_in_e_mail_digests": "Y",
"e_mail_digests_show_in_digest": "same as viewer",
"show_numeric_null_values_as_zeroes": "blank",
"business_owner_id": 19,
"technical_owner_id": 19
},
{
"id": 1203,
"keep_history": "Y",
"dataset_id": 28,
"dataset_filter_id": 142,
"measurement_interval": 3,
"dimension": 0,
"name": "Active Jira Tickets",
"description": "Active Jira Ticket",
"category": 14,
"max_time_before_expired_period": 1,
"max_time_before_expired_unit": "year",
"can_be_viewed_without_login": "N",
"include_metric_data_table_in_e_mail_digests": "Y",
"e_mail_digests_show_in_digest": "same as viewer",
"show_numeric_null_values_as_zeroes": "blank",
"business_owner_id": 19,
"technical_owner_id": 19
}
]
}
Fields Description
| Parameter Name | Value Type | Description |
|---|---|---|
| id | integer | The ID of the Report. |
| keep_history | string | Whether the Report is sourced from a Snapshot Dataset. |
| dataset_id | integer | The ID of the source Dataset. |
| dataset_filter_id | integer | The ID of the source Dataset View. |
| measurement_interval | integer | The ID of the source Dataset’s measurement interval. |
| dimension | integer | The ID of the Report’s dimension.
|
| name | string | The name of the Report. |
| description | string | The description of the Report. |
| category | integer | The ID of the Report’s category. |
| max_time_before_expired_period | string | The time period after which the Report expires. |
| can_be_viewed_without_login | string | Whether this Dataset Report will be visible to all Users that have access to it or only to you («Y»/«N»). |
| show_numeric_null_values_as_zeroes | string | Whether the NULL values will be shown as a blank space or a zero («blank»/«zero»). |
| business_owner_id | integer | The ID of the Report Business Owner. |
| technical_owner_id | integer | The ID of the Report Technical Owner. |
2. Create a Report
- The POST request to
/api/reportcreates a new Report.
- Item: report.
- Method: POST.
- ID: Specify ID of an already existing Report.
- Select JSON request and enter JSON providing the needed values for your Report:
- Required parameters:
name,category. - All parameters that were not provided manually will be assigned default values.
- See Fields Description for details on Report's optional parameters.
- Required parameters:
- Enter API token.
- [Run Request]
3. Update a Report
Execute the following request to update a Report:
fetch("/api/report/id/<id>", { method: "PUT", headers: { "Authorization": `Bearer <MI API Token>`, "Content-Type": "application/json" }, body: JSON.stringify(<Report data JSON>) });
Replace the following with the actual values:
<id>: The ID of the Report that needs to be updated.-
<MI API Token>: Metric Insights API Token. <Report data JSON>: Report parameters that need to be updated.- See Fields Description for details.
Example request:
const token = "<MI API token>";
const data = {
id: 152753,
keep_history: "Yes",
dataset_id: 21418,
dataset_filter_id: 355,
measurement_interval: 3,
dimension: 0,
name: "Fruit Sales Report 2025",
category: 123,
dataset_source: "21418_355",
max_time_before_expired_period: 2,
can_be_viewed_without_login: "public",
show_numeric_null_values_as_zeroes: "blank",
business_owner_id: 238,
technical_owner_id: 238
};
fetch("/api/report/id/152753", {
method: "PUT",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify(data)
});
4. Delete a Report
The DELETE request to /api/report/id/<id> deletes a selected Report.
- Item: report.
- Method: DELETE.
- ID: Specify ID of the Report that needs to be deleted.
- Enter API token.
- [Run Request]