> 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.md). Agents can also search and read this documentation through its [MCP server](https://integrations.drivetrain.ai/~gitbook/mcp).

# Drivetrain API

Read your Drivetrain metrics, dimensions, versions, scenarios and lists, and replace list rows, over HTTPS with an API key

The Drivetrain API lets your own systems read data from your Drivetrain workspace: metric values, and the metrics, dimensions, versions, scenarios and lists that describe them. One endpoint writes: [Upload list CSV API](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/upload-list-csv-api.md) replaces a list's rows. Every endpoint returns JSON.

## Endpoints

* [**Get metric list API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metric-list-api.md): Get a list of all metrics in your Drivetrain tenant \[GET method]
* [**Get metrics bulk data API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metrics-bulk-data-api.md): Retrieve data for multiple metrics in a single request, across versions, scenarios, time ranges, granularities, and dimensions \[POST method]
* [**Get dimension list API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-dimension-list-api.md): Get a list of all dimensions in your Drivetrain tenant \[GET method]
* [**Get dimension values API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-dimension-values-api.md): Get all values of a single dimension, along with the attributes attached to each value \[GET method]
* [**Get version list API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-version-list-api.md): Get a list of all versions in your Drivetrain tenant \[GET method]
* [**Get scenario list API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-scenario-list-api.md): Get a list of all scenarios in your Drivetrain tenant \[GET method]
* [**Get list API**](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-list-api.md): Fetch the contents of a single list in your Drivetrain tenant by its list ID \[GET method]
* [**Upload CSV to list API**](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/upload-csv-to-list-api.md): Replace all rows of a list with the contents of a CSV file \[POST method]

## Base URL

Every path above is relative to your workspace's base URL. Use the same host you open Drivetrain on in your browser:

| Where your workspace is hosted | Base URL                                                        |
| ------------------------------ | --------------------------------------------------------------- |
| US                             | `https://{your_subdomain}.drivetrain.ai/drive/api/v1/public`    |
| EU                             | `https://{your_subdomain}.eu.drivetrain.ai/drive/api/v1/public` |

Drivetrain identifies your workspace from the subdomain. An API key only works on the host of the workspace it was created in. On any other host the call returns `401 Unauthorized`.

## Authentication

Send your API key in the `apikey` request header on every call:

```bash
curl 'https://{your_subdomain}.drivetrain.ai/drive/api/v1/public/versions' \
  --header 'apikey: {your_apikey}'
```

Copy your key from **Settings** > **API Key**. Only users with the **Admin** role can use the API, and your subscription must include Drivetrain API access. The key acts as you and has no expiry or scopes. See [Authentication and API keys](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/authentication-and-api-keys.md) for resetting and revoking keys, and which of your permissions each endpoint applies.

## Make your first call

To read metric values, you need the backend names of the metrics, versions and scenarios:

1. Call [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) to see which version and scenario names exist.
2. Call [Get metric list API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metric-list-api.md) to find the metrics you want, and which dimensions and scenarios each one supports in each version. You can request values only for metrics in your live model (`versions[]` includes `Current` or `Actual`).
3. Call [Get metrics bulk data API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metrics-bulk-data-api.md) with those names and a date range.

[Quickstart](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/quickstart.md) walks through these calls with curl and Python.

## Conventions

* **Backend names, not display names.** Every request takes backend names (for example `metrics.ARR`, `Budget_2026`, `Base_Case`, `region`). Each list endpoint returns both `name` (the backend name to send back) and `displayName` (what the Drivetrain UI shows).
* **Built-in version names.** `Actual` is your actuals data and `Current` is your live model. Both are accepted wherever a version name is.
* **Dates** are strings in `YYYY-MM-DD` format.
* **Errors** other than `401` and `415` are JSON with a `message` field, except field-validation errors on [Get metrics bulk data API](https://integrations.drivetrain.ai/extending-drivetrain/drivetrain-api/get-metrics-bulk-data-api.md#errors), which map each field to its message. Most also carry `"status": "failed"` and a `code` such as `"403 FORBIDDEN"`. [Rejected uploads](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/upload-list-csv-api.md#rejected-uploads) carry `"success": false` instead. A `401`, or a `415` from Upload list CSV API, comes back before your request is processed and doesn't use this format, so branch on the status code:

  ```json
  { "message": "You don't seem to have permission", "status": "failed", "code": "403 FORBIDDEN" }
  ```
* **Versioning.** All endpoints are under `/v1`. There's no other API version.

### Status codes used by every endpoint

| Status                      | Meaning                                                                                                                                                            |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `200 OK`                    | Success. An empty result is still `200`, with an empty `data` (or `rows`) array.                                                                                   |
| `401 Unauthorized`          | Missing, empty, reset or unknown `apikey`; a key from another workspace; the key's user was deactivated; or Drivetrain API access isn't part of your subscription. |
| `403 Forbidden`             | The key's user doesn't have the **Admin** role, or doesn't have access to the specific resource.                                                                   |
| `500 Internal Server Error` | Unexpected failure. The body says only `An unexpected error occurred. Please try again.` Retry, then contact Drivetrain support if it persists.                    |

Each endpoint page lists its other status codes. [Errors and troubleshooting](https://github.com/DrivetrainAi/gitbook-integrations/tree/main/en/extending-drivetrain/drivetrain-api/errors-and-troubleshooting.md) collects the error messages with their causes and fixes, and the API's limits.

## Postman collection

This [Postman collection](https://elements.getpostman.com/redirect?entityId=14817076-fd70b52f-8407-4868-ac39-94a10403162d\&entityType=collection) contains saved request and response examples for the APIs.

{% embed url="<https://elements.getpostman.com/redirect?entityId=14817076-fd70b52f-8407-4868-ac39-94a10403162d&entityType=collection>" %}


---

# 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.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.
