ServiceTokens

Create service token

Changed on

Create a new service token.

Authenticate with a service token. A service token whose service account is an organization owner can create tokens for any service account. A service token whose service account holds the Owner role on a project group can create tokens for a service account in the same organization when the target account has a permission grant on a project group it owns. The calling service account must also hold all of the target account's permissions in the organization; otherwise the request returns 403. User API keys cannot be used.

post/v1/service_token

Request

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

Request body

namestring required

Name of the service token. Does not have to be unique

org_namestring nullable

For nearly all users, this parameter should be unnecessary. But in the rare case that your API key belongs to multiple organizations, you may specify the name of the organization the Service token belongs in.

service_account_idstring required

The ID of the service account to which the token should belong. To create a service account, visit Settings > Service tokens in the Braintrust UI or call PATCH /v1/organization/members.

expires_in_secondsinteger nullable

Number of seconds from now after which the service token should expire. If omitted, the token never expires.

Response

Returns an object containing the raw service token. This is the only time the raw API key will be exposed

idstring uuid required

Unique identifier for the service token

createdstring date-time nullable

Date of service token creation

namestring required

Name of the service token

preview_namestring required

Masked preview showing the token prefix and last four characters, e.g. bt-st-…AbCd.

service_account_idstring uuid nullable

Unique identifier for the service token

service_account_emailstring nullable

The service account email (not routable)

service_account_namestring nullable

The service account name

org_idstring uuid nullable

Unique identifier for the organization

expires_atstring date-time nullable

Date and time at which the service token expires. If null, the token never expires.

keystring required

The raw service token. It will only be exposed this one time

Changes

    • breaking

      the request property became not nullable

    • breaking

      the request property became not nullable

    • info

      the request property's exclusiveMinimum was decreased from true to 0.00

    • breaking

      request body became required