EnvVars

Create or replace env var

Changed on

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

put/v1/env_var

Request

  • Base URL
    https://api.braintrust.dev
  • Auth
    • HTTP bearer
    • or none

Request body

object_type'organization' | 'project' | 'function' | 'mcp_server' required

The type of the object the environment variable is scoped for

object_idstring uuid required

The id of the object the environment variable is scoped for

namestring required

The name of the environment variable

valuestring nullable

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

metadataobject nullable

Optional metadata associated with the environment variable when managed via the function secrets API

secret_typestring nullable

Optional classification for the secret (for example, the AI provider name)

Response

Returns the new env var object

idstring uuid required

Unique identifier for the environment variable

object_type'organization' | 'project' | 'function' | 'mcp_server' required

The type of the object the environment variable is scoped for

object_idstring uuid required

The id of the object the environment variable is scoped for

namestring required

The name of the environment variable

createdstring date-time nullable

Date of environment variable creation

secret_updated_atstring date-time nullable

Date of last update to the encrypted secret value itself

secret_updated_by_user_idstring uuid nullable

User id of the last update to the encrypted secret value

usedstring date-time nullable

Date the environment variable was last used

metadataobject nullable

Optional metadata associated with the environment variable when managed via the function secrets API

preview_secretstring nullable

Redacted preview of the stored secret value

secret_typestring nullable

Optional classification for the secret (for example, the AI provider name)

secret_category'env_var' | 'ai_provider' | 'sandbox_provider' | 'automation_integration'

The category of the secret: env_var for regular environment variables, ai_provider for AI provider API keys

Changes

    • breaking

      the request property became not nullable

    • breaking

      the request property / became not nullable

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • warning

      added the new automation_integration enum value to the response property for the response status