Reference/API/Env Vars
GET
/v1/env_var

List env_vars

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

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

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

env_var_namestring

Name of the env_var to search for

object_typestring

The type of the object the environment variable is scoped for

Value in: "organization" | "project" | "function"

object_idstring

The id of the object the environment variable is scoped for

Format: "uuid"
Status codeDescription
200Returns a list of env_var 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/env_var?limit=0&ids=497f6eca-6276-4993-bfeb-53cbbbba6f08&env_var_name=string&object_type=organization&object_id=497f6eca-6276-4993-bfeb-53cbbbba6f08"

{
  "objects": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "object_type": "organization",
      "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
      "name": "string",
      "created": "2019-08-24T14:15:22Z",
      "used": "2019-08-24T14:15:22Z"
    }
  ]
}

POST
/v1/env_var

Create env_var

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

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 env_var object

object_type
Required
string

The type of the object the environment variable is scoped for

Value in: "organization" | "project" | "function"

object_id
Required
string

The id of the object the environment variable is scoped for

Format: "uuid"

name
Required
string

The name of the environment variable

valuestring | null

The value of the environment variable. Will be encrypted at rest.

Status codeDescription
200Returns the new env_var 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/env_var" \
  -d '{
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "value": "string"
}'

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "created": "2019-08-24T14:15:22Z",
  "used": "2019-08-24T14:15:22Z"
}

PUT
/v1/env_var

Create or replace env_var

Create or replace env_var. If there is an existing env_var with the same name as the one specified in the request, will replace the existing env_var with the provided fields

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 env_var object

object_type
Required
string

The type of the object the environment variable is scoped for

Value in: "organization" | "project" | "function"

object_id
Required
string

The id of the object the environment variable is scoped for

Format: "uuid"

name
Required
string

The name of the environment variable

valuestring | null

The value of the environment variable. Will be encrypted at rest.

Status codeDescription
200Returns the new env_var 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 PUT "https://api.braintrust.dev/v1/env_var" \
  -d '{
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "value": "string"
}'

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "created": "2019-08-24T14:15:22Z",
  "used": "2019-08-24T14:15:22Z"
}

GET
/v1/env_var/{env_var_id}

Get env_var

Get an env_var object by its id

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

env_var_id
Required
string

EnvVar id

Format: "uuid"
Status codeDescription
200Returns the env_var 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/env_var/497f6eca-6276-4993-bfeb-53cbbbba6f08"

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "created": "2019-08-24T14:15:22Z",
  "used": "2019-08-24T14:15:22Z"
}

PATCH
/v1/env_var/{env_var_id}

Partially update env_var

Partially update an env_var 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.

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

name
Required
string

The name of the environment variable

valuestring | null

The value of the environment variable. Will be encrypted at rest.

Path Parameters

env_var_id
Required
string

EnvVar id

Format: "uuid"
Status codeDescription
200Returns the env_var 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/env_var/497f6eca-6276-4993-bfeb-53cbbbba6f08" \
  -d '{
  "name": "string",
  "value": "string"
}'

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "created": "2019-08-24T14:15:22Z",
  "used": "2019-08-24T14:15:22Z"
}

DELETE
/v1/env_var/{env_var_id}

Delete env_var

Delete an env_var object by its id

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

env_var_id
Required
string

EnvVar id

Format: "uuid"
Status codeDescription
200Returns the deleted env_var 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/env_var/497f6eca-6276-4993-bfeb-53cbbbba6f08"

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object_type": "organization",
  "object_id": "463a83d0-a816-4902-abba-2486e0c0a0bb",
  "name": "string",
  "created": "2019-08-24T14:15:22Z",
  "used": "2019-08-24T14:15:22Z"
}