Reference/API/Datasets
GET
/v1/dataset

List datasets

List out all datasets. The datasets are sorted by creation date, with the most recently-created datasets coming first

/v1/dataset

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Query Parameters

limitinteger | null

Limit the number of objects to return

Minimum: 0

starting_afterstring

Pagination cursor id.

For example, if the final item in the last page you fetched had an id of foo, pass starting_after=foo to fetch the next page. Note: you may only pass one of starting_after and ending_before

Format: "uuid"

ending_beforestring

Pagination cursor id.

For example, if the initial item in the last page you fetched had an id of foo, pass ending_before=foo to fetch the previous page. Note: you may only pass one of starting_after and ending_before

Format: "uuid"

idsAny properties in string, array<string>

Filter search results to a particular set of object IDs. To specify a list of IDs, include the query param multiple times

dataset_namestring

Name of the dataset to search for

project_namestring

Name of the project to search for

project_idstring

Project id

Format: "uuid"

org_namestring

Filter search results to within a particular organization

Status codeDescription
200Returns a list of dataset objects
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X GET "https://api.braintrust.dev/v1/dataset?limit=0&starting_after=497f6eca-6276-4993-bfeb-53cbbbba6f08&ending_before=497f6eca-6276-4993-bfeb-53cbbbba6f08&ids=497f6eca-6276-4993-bfeb-53cbbbba6f08&dataset_name=string&project_name=string&project_id=497f6eca-6276-4993-bfeb-53cbbbba6f08&org_name=string"

{
  "objects": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "name": "string",
      "description": "string",
      "created": "2019-08-24T14:15:22Z",
      "deleted_at": "2019-08-24T14:15:22Z",
      "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
      "metadata": {
        "property1": null,
        "property2": null
      }
    }
  ]
}

POST
/v1/dataset

Create dataset

Create a new dataset. If there is an existing dataset in the project with the same name as the one specified in the request, will return the existing dataset unmodified

/v1/dataset

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Request Body (Optional)

Any desired information about the new dataset object

project_id
Required
string

Unique identifier for the project that the dataset belongs under

Format: "uuid"

name
Required
string

Name of the dataset. Within a project, dataset names are unique

Minimum length: 1

descriptionstring | null

Textual description of the dataset

Status codeDescription
200Returns the new dataset object
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X POST "https://api.braintrust.dev/v1/dataset" \
  -d '{
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "name": "string",
  "description": "string"
}'

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "name": "string",
  "description": "string",
  "created": "2019-08-24T14:15:22Z",
  "deleted_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "metadata": {
    "property1": null,
    "property2": null
  }
}

GET
/v1/dataset/{dataset_id}

Get dataset

Get a dataset object by its id

/v1/dataset/{dataset_id}

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns the dataset object
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X GET "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08"

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "name": "string",
  "description": "string",
  "created": "2019-08-24T14:15:22Z",
  "deleted_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "metadata": {
    "property1": null,
    "property2": null
  }
}

PATCH
/v1/dataset/{dataset_id}

Partially update dataset

Partially update a dataset object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null.

/v1/dataset/{dataset_id}

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Request Body (Optional)

Fields to update

namestring | null

Name of the dataset. Within a project, dataset names are unique

descriptionstring | null

Textual description of the dataset

metadataobject | null

User-controlled metadata about the dataset

Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns the dataset object
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X PATCH "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08" \
  -d '{
  "name": "string",
  "description": "string",
  "metadata": {
    "property1": null,
    "property2": null
  }
}'

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "name": "string",
  "description": "string",
  "created": "2019-08-24T14:15:22Z",
  "deleted_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "metadata": {
    "property1": null,
    "property2": null
  }
}

DELETE
/v1/dataset/{dataset_id}

Delete dataset

Delete a dataset object by its id

/v1/dataset/{dataset_id}

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns the deleted dataset object
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X DELETE "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08"

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
  "name": "string",
  "description": "string",
  "created": "2019-08-24T14:15:22Z",
  "deleted_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5",
  "metadata": {
    "property1": null,
    "property2": null
  }
}

POST
/v1/dataset/{dataset_id}/insert

Insert dataset events

Insert a set of events into the dataset

/v1/dataset/{dataset_id}/insert

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Request Body (Optional)

An array of dataset events to insert

events
Required
array<Any properties in object, object>

A list of dataset events to insert

Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns the inserted row ids
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X POST "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08/insert" \
  -d '{
  "events": [
    {
      "input": null,
      "expected": null,
      "metadata": {
        "property1": null,
        "property2": null
      },
      "tags": [
        "string"
      ],
      "id": "string",
      "created": "2019-08-24T14:15:22Z",
      "_object_delete": true,
      "_is_merge": false,
      "_parent_id": "string"
    }
  ]
}'

{
  "row_ids": [
    "string"
  ]
}

GET
/v1/dataset/{dataset_id}/fetch

Fetch dataset (GET form)

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

/v1/dataset/{dataset_id}/fetch

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"

Query Parameters

limitinteger | null

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.

Minimum: 0

max_xact_idstring

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_idstring

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.

versionstring

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.

Status codeDescription
200Returns the fetched rows
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X GET "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08/fetch?limit=0&max_xact_id=string&max_root_span_id=string&version=string"

{
  "events": [
    {
      "id": "string",
      "_xact_id": "string",
      "created": "2019-08-24T14:15:22Z",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "dataset_id": "8c4c51f1-f6f3-43bc-b65d-7415e8ef22c0",
      "input": null,
      "expected": null,
      "metadata": {
        "property1": null,
        "property2": null
      },
      "tags": [
        "string"
      ],
      "span_id": "string",
      "root_span_id": "string"
    }
  ],
  "cursor": "string"
}

POST
/v1/dataset/{dataset_id}/fetch

Fetch dataset (POST form)

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

/v1/dataset/{dataset_id}/fetch

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Request Body (Optional)

Filters for the fetch query

limitinteger | null

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.

Minimum: 0

cursorstring | null

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_idstring & null

max_root_span_idstring & null

filtersarray<object> | null

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.

versionstring & null

Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns the fetched rows
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X POST "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08/fetch" \
  -d '{
  "limit": 0,
  "cursor": "string",
  "max_xact_id": "string",
  "max_root_span_id": "string",
  "filters": [
    {
      "type": "path_lookup",
      "path": [
        "string"
      ],
      "value": null
    }
  ],
  "version": "string"
}'

{
  "events": [
    {
      "id": "string",
      "_xact_id": "string",
      "created": "2019-08-24T14:15:22Z",
      "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
      "dataset_id": "8c4c51f1-f6f3-43bc-b65d-7415e8ef22c0",
      "input": null,
      "expected": null,
      "metadata": {
        "property1": null,
        "property2": null
      },
      "tags": [
        "string"
      ],
      "span_id": "string",
      "root_span_id": "string"
    }
  ],
  "cursor": "string"
}

POST
/v1/dataset/{dataset_id}/feedback

Feedback for dataset events

Log feedback for a set of dataset events

/v1/dataset/{dataset_id}/feedback

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header


Request Body (Optional)

An array of feedback objects

feedback
Required
array<object>

A list of dataset feedback items

Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"
Status codeDescription
200Returns a success status
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X POST "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08/feedback" \
  -d '{
  "feedback": [
    {
      "id": "string",
      "comment": "string",
      "metadata": {
        "property1": null,
        "property2": null
      },
      "source": "app"
    }
  ]
}'

{
  "status": "success"
}

GET
/v1/dataset/{dataset_id}/summarize

Summarize dataset

Summarize dataset

/v1/dataset/{dataset_id}/summarize

The Authorization access token

Authorization

Authorization
Required
Bearer <token>

Most Braintrust endpoints are authenticated by providing your API key as a header Authorization: Bearer [api_key] to your HTTP request. You can create an API key in the Braintrust organization settings page.

In: header

Path Parameters

dataset_id
Required
string

Dataset id

Format: "uuid"

Query Parameters

summarize_databoolean | null

Whether to summarize the data. If false (or omitted), only the metadata will be returned.

Status codeDescription
200Dataset summary
400The request was unacceptable, often due to missing a required parameter
401No valid API key provided
403The API key doesn’t have permissions to perform the request
429Too many requests hit the API too quickly. We recommend an exponential backoff of your requests
500Something went wrong on Braintrust's end. (These are rare.)
curl -X GET "https://api.braintrust.dev/v1/dataset/497f6eca-6276-4993-bfeb-53cbbbba6f08/summarize?summarize_data=true"

Summary of a dataset

{
  "project_name": "string",
  "dataset_name": "string",
  "project_url": "http://example.com",
  "dataset_url": "http://example.com",
  "data_summary": {
    "total_records": 0
  }
}