---
title: "Fetch dataset (POST form)"
method: POST
path: "/v1/dataset/{dataset_id}/fetch"
tags: ["Datasets"]
---

# Fetch dataset (POST form)

`POST /v1/dataset/{dataset_id}/fetch`

Fetch the events in a dataset. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query

## Path parameters

- `dataset_id` string, uuid, required — Dataset id

## Request body

- FetchEventsRequest
  - `limit` integer, nullable — limit the number of traces fetched Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest `_xact_id`. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier `_xact_id`. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by `id`) from your combined result set. The `limit` parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.
  - `cursor` string, nullable — An opaque string to be used as a cursor for the next page of results, in order from latest to earliest. The string can be obtained directly from the `cursor` property of the previous fetch query
  - `max_xact_id` string, nullable — DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards. Together, `max_xact_id` and `max_root_span_id` form a pagination cursor Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating fetch queries.
  - `max_root_span_id` string, nullable — DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards. Together, `max_xact_id` and `max_root_span_id` form a pagination cursor Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple `(_xact_id, root_span_id)`. See the documentation of `limit` for an overview of paginating fetch queries.
  - `filters` PathLookupFilter[], nullable — NOTE: This parameter is deprecated and will be removed in a future revision. Consider using the `/btql` endpoint (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering. A list of filters on the events to fetch. Currently, only path-lookup type filters are supported.
    - `type` 'path_lookup', required — Denotes the type of filter as a path-lookup filter
    - `path` string[], required — List of fields describing the path to the value to be checked against. For instance, if you wish to filter on the value of `c` in `{"input": {"a": {"b": {"c": "hello"}}}}`, pass `path=["input", "a", "b", "c"]`
    - `value` unknown
  - `version` string, nullable — Retrieve a snapshot of events from a past time The version id is essentially a filter on the latest event transaction id. You can use the `max_xact_id` returned by a past fetch as the version to reproduce that exact fetch.

## Response `200`

Returns the fetched rows

- FetchDatasetEventsResponse
  - `events` DatasetEvent[], required — A list of fetched events
    - `id` string, required — A unique identifier for the dataset event. If you don't provide one, BrainTrust will generate one for you
    - `_xact_id` string, required — The transaction id of an event is unique to the network operation that processed the event insertion. Transaction ids are monotonically increasing over time and can be used to retrieve a versioned snapshot of the dataset (see the `version` parameter)
    - `created` string, date-time, required — The timestamp the dataset event was created
    - `project_id` string, uuid, required — Unique identifier for the project that the dataset belongs under
    - `dataset_id` string, uuid, required — Unique identifier for the dataset
    - `input` unknown
    - `expected` unknown
    - `metadata` object, nullable — A dictionary with additional data about the test example, model outputs, or just about anything else that's relevant, that you can use to help find and analyze examples later. For example, you could log the `prompt`, example's `id`, or anything else that would be useful to slice/dice later. The values in `metadata` can be any JSON-serializable type, but its keys must be strings
    - `tags` string[], nullable — A list of tags to log
    - `span_id` string, required — A unique identifier used to link different dataset events together as part of a full trace. See the [tracing guide](https://www.braintrust.dev/docs/guides/tracing) for full details on tracing
    - `root_span_id` string, required — The `span_id` of the root of the trace this dataset event belongs to
  - `cursor` string, nullable — Pagination cursor Pass this string directly as the `cursor` param to your next fetch request to get the next page of results. Not provided if the returned result set is empty.

## Other responses

- `400` — The request was unacceptable, often due to missing a required parameter
- `401` — No valid API key provided
- `403` — The API key doesn’t have permissions to perform the request
- `429` — Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
- `500` — Something went wrong on Braintrust's end. (These are rare.)

---

[API](https://skmtc.net/braintrustdata/apis/braintrust-api.md) · [All operations](https://skmtc.net/braintrustdata/apis/braintrust-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/braintrustdata/braintrust-api/revisions/9d216c8243fe/schema)
