> For the complete documentation index, see [llms.txt](https://integrations.drivetrain.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metrics-bulk-data-api.md).

# Get metrics bulk data API

Read values for up to 50 metrics in one POST request, across versions, scenarios, granularities and dimensions.

Use this API to read metric values for a date range, for up to 50 metrics in one request, broken down by version, scenario, time period and up to 5 dimensions.

|             |                                                                                                                                                                                                                                                                                       |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Method**  | `POST`                                                                                                                                                                                                                                                                                |
| **URL**     | `https://{your_subdomain}.drivetrain.ai/drive/api/v1/public/metrics-bulk`                                                                                                                                                                                                             |
| **Headers** | <p><code>apikey</code> (required). See <a href="https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/authentication-and-api-keys.md">Authentication and API keys</a>.<br><code>Content-Type: application/json</code> (required).</p> |
| **Role**    | The key's user must have the **Admin** role. Values come back for every dimension value, even values the user's roles hide in Drivetrain.                                                                                                                                             |

### Request body

| Field         | Type             | Required | Default         | Description                                                                                                                                                                                                                                                                                                                                   |
| ------------- | ---------------- | -------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metricNames` | array of strings | Yes      | —               | 1 to 50 metric backend names, from [Get metric list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metric-list-api.md). Only metrics in your live model can be requested: their `versions[]` includes `Current` or `Actual`. The `metrics.` prefix is optional: `ARR` and `metrics.ARR` are the same metric. |
| `startDate`   | string           | Yes      | —               | Start of the range, `YYYY-MM-DD`.                                                                                                                                                                                                                                                                                                             |
| `endDate`     | string           | Yes      | —               | End of the range, `YYYY-MM-DD`. Can't be before `startDate`.                                                                                                                                                                                                                                                                                  |
| `versions`    | array of strings | No       | `["Actual"]`    | Version backend names: `Actual`, `Current` (your live model), or names exactly as returned by [Get version list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-version-list-api.md). Names aren't checked.                                                                                                   |
| `scenarios`   | array of strings | No       | `["Base_Case"]` | Scenario backend names exactly as returned by [Get scenario list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-scenario-list-api.md). Names aren't checked. Ignored when `versions` is only `Actual`.                                                                                                       |
| `granularity` | array of strings | No       | `["MONTHLY"]`   | One or more of the values in the table below, not case-sensitive. Use only these values. Each granularity you list adds its own set of rows.                                                                                                                                                                                                  |
| `dimensions`  | array of strings | No       | `[]`            | Up to 5 dimension backend names to break values down by, from the broadest to the most detailed. Without dimensions, each metric returns one total per period.                                                                                                                                                                                |

| `granularity` | `period` on each row | `t` on each row                                   |
| ------------- | -------------------- | ------------------------------------------------- |
| `DAILY`       | `D`                  | The day                                           |
| `WEEKLY`      | `W`                  | First day of the week                             |
| `MONTHLY`     | Not returned         | First day of the month                            |
| `QUARTERLY`   | `Q1` to `Q4`         | First day of the quarter                          |
| `HALF_YEARLY` | `H1` or `H2`         | First day of the half-year                        |
| `YEARLY`      | `Y`                  | First day of the year                             |
| `RANGE`       | `R`                  | Not returned. One value for the whole date range. |

Quarters, half-years and years follow your fiscal year. If your workspace uses a custom calendar (for example 4-4-5 or 13 periods), `t` for `MONTHLY` is the start of the calendar period instead of the first day of the month.

### Example request

```bash
curl --request POST 'https://{your_subdomain}.drivetrain.ai/drive/api/v1/public/metrics-bulk' \
  --header 'apikey: {your_apikey}' \
  --header 'Content-Type: application/json' \
  --data '{
    "metricNames": ["metrics.Revenue"],
    "versions": ["Current", "Budget_2026"],
    "granularity": ["QUARTERLY"],
    "startDate": "2026-01-01",
    "endDate": "2026-06-30",
    "dimensions": ["region"]
  }'
```

`scenarios` is omitted, so Drivetrain uses `Base_Case`.

### Example response (truncated)

```json
{
  "data": [
    { "Scenario": "Base_Case", "Version": "Current",     "metric": "metrics.Revenue", "period": "Q1",                    "result": 1890000.5, "t": "2026-01-01" },
    { "Scenario": "Base_Case", "Version": "Current",     "metric": "metrics.Revenue", "period": "Q1", "region": "NAMER", "result": 1250000,   "t": "2026-01-01" },
    { "Scenario": "Base_Case", "Version": "Current",     "metric": "metrics.Revenue", "period": "Q1", "region": "EMEA",  "result": 640000.5,  "t": "2026-01-01" },
    { "Scenario": "Base_Case", "Version": "Current",     "metric": "metrics.Revenue", "period": "Q2", "region": "NAMER", "result": 1310000,   "t": "2026-04-01" },
    { "Scenario": "Base_Case", "Version": "Budget_2026", "metric": "metrics.Revenue", "period": "Q1", "region": "NAMER", "result": 1200000,   "t": "2026-01-01" }
  ]
}
```

The first row has no `region` key: it's the roll-up total for all regions (see below). This example assumes a fiscal year that starts in January.

### Response fields

`data` is an array of row objects, one per metric, version, scenario, time period and dimension combination that has a value. Don't rely on the order of rows or keys.

| Field                                           | Type   | Description                                                                                                                    |
| ----------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `metric`                                        | string | Metric backend name, with the `metrics.` prefix.                                                                               |
| `Version`                                       | string | Version backend name. Note the capital `V`.                                                                                    |
| `Scenario`                                      | string | Scenario backend name. Note the capital `S`. Not returned for `MONITORING` metrics or when you request only `Actual`.          |
| `t`                                             | string | Start date of the period, `YYYY-MM-DD`. Not returned for `RANGE`.                                                              |
| `period`                                        | string | Granularity code, as in the table above. Not returned for `MONTHLY`.                                                           |
| `result`                                        | number | The value, rounded to 6 decimal places. A combination with no value has no row at all.                                         |
| *dimension backend name* (for example `region`) | string | One key per requested dimension that applies to the metric. The value is always a string, even for numeric or date dimensions. |
| `__dt__Currency`                                | string | The currency symbol, when Drivetrain attaches one to the value.                                                                |

### Errors

| Status                      | When                                                                                                                                                                                                                                                           | `message`                                                   |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `400 Bad Request`           | `metricNames` is missing or empty                                                                                                                                                                                                                              | `At least one of metricNames or metricIds must be provided` |
| `400 Bad Request`           | `startDate` is after `endDate`                                                                                                                                                                                                                                 | `Start date should be lesser than the End date`             |
| `400 Bad Request`           | A `granularity` value isn't recognized                                                                                                                                                                                                                         | `Invalid granularity: <value>`                              |
| `400 Bad Request`           | The body isn't valid JSON                                                                                                                                                                                                                                      | `Malformed request body`                                    |
| `400 Bad Request`           | More than 50 metrics, more than 5 dimensions, or a missing or badly formatted date                                                                                                                                                                             | See below                                                   |
| `401 Unauthorized`          | Missing or invalid `apikey`, or API access isn't part of your subscription                                                                                                                                                                                     | —                                                           |
| `403 Forbidden`             | The key's user doesn't have the **Admin** role                                                                                                                                                                                                                 | `You don't seem to have permission`                         |
| `500 Internal Server Error` | A metric name without the `metrics.` prefix contains characters other than letters, digits and underscores (for example a display name such as `Total Revenue`); or a date has a month outside `01`–`12` or a day outside `01`–`31` (for example `2026-13-01`) | `An unexpected error occurred. Please try again.`           |
| `500 Internal Server Error` | The body isn't sent as `Content-Type: application/json` (`curl --data` sends form data unless you set the header)                                                                                                                                              | Usually `An unexpected error occurred. Please try again.`   |

For the field checks in the fifth row, the body is an object that maps the field to its message instead of the usual error object, for example:

```json
{ "metricNames": "Cannot fetch more than 50 metrics at once" }
```

The messages are `Cannot fetch more than 50 metrics at once`, `Cannot fetch more than 5 dimensions at once`, `Start date cannot be empty`, `Start date must be in yyyy-MM-dd format`, `End date cannot be empty` and `End date must be in yyyy-MM-dd format`.

A day from 29 to 31 that doesn't exist in that month doesn't fail: `2026-02-30` is read as `2026-02-28`.

### Things to check in your results

* **Roll-up rows are included. Don't sum all rows.** With dimensions, `data` also holds totals at each broader level, in the order you listed the dimensions. For `["region", "product"]` you get rows with no dimension key, rows with only `region`, and rows with `region` and `product`. To keep only the detailed rows, keep the rows that carry every requested dimension that applies to the metric.
* **Missing rows mean no value.** A period or combination with no value is left out of `data`.
* **Unknown names don't fail the call.** A metric name that matches no metric in your live model is skipped. Check that every metric you asked for appears in `data`. Version and scenario names aren't validated, so compare them with [Get version list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-version-list-api.md) and [Get scenario list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-scenario-list-api.md) before calling.
* **Dimensions that don't apply are ignored per metric.** Rows for that metric come back without the dimension's key. Check `versions[].dimensions` in [Get metric list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metric-list-api.md) first.
* **Several granularities mix in one array.** Use `period` (and `t`) to tell the rows apart.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metrics-bulk-data-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
