API Tokens REST API
List tokens for a user
⚠️ Breaking Changes: The Bencher API is in beta and under active development. We may introduce breaking changes in future releases. We will announce any breaking changes in the release notes.
List all API tokens for a user. Only the authenticated user themselves and server admins have access to this endpoint. By default, the tokens are sorted in alphabetical order by name. The HTTP response header `X-Total-Count` contains the total number of tokens.
Headers
Content-Type string
Set to application/json.
Authorization string
Set to Bearer BENCHER_API_KEY, where BENCHER_API_KEY is a valid Bencher API key (or a deprecated API token).
Path Parameters
userThe slug or UUID for a user.
Query Parameters
directionstring
The direction to sort by. If not specified, the default sort direction is used.
Default: asc
One of: asc, desc
pageinteger
The page number to return. If not specified, the first page is returned.
Default: 1
per_pageinteger
The number of items to return per page. If not specified, the default number of items per page (8) is used.
Default: 8
sortstring
The field to sort by. If not specified, the default sort field is used.
Default: name
One of: name
namestring
Filter by token name, exact match.
revokedboolean
If set to `true`, only returns revoked tokens. If not set or set to `false`, only returns non-revoked tokens.
searchstring
Search by token name, slug, or UUID.
/v0/users/{user}/tokens | Bencher Cloud | https://api.bencher.dev |
| Bencher Self-Hosted | http://localhost:61016 |
Bencher CLI
bencher token list USER View OpenAPI Spec
Create a token
⚠️ Breaking Changes: The Bencher API is in beta and under active development. We may introduce breaking changes in future releases. We will announce any breaking changes in the release notes.
DEPRECATED: User API tokens have been deprecated in favor of user API keys, so this endpoint always fails with a `403 Forbidden` error. Create a user API key instead: <https://bencher.dev/docs/explanation/bencher-run/#--key-key> Existing API tokens continue to work and can still be viewed, updated, and revoked.
Headers
Content-Type string
Set to application/json.
Authorization string
Set to Bearer BENCHER_API_KEY, where BENCHER_API_KEY is a valid Bencher API key (or a deprecated API token).
Path Parameters
userThe slug or UUID for a user.
Body Parameters
namestring
The name of the token. Maximum length is 64 characters.
ttlinteger
The time-to-live (TTL) for the token in seconds. If not provided, the token will not expire for over 128 years.
/v0/users/{user}/tokens | Bencher Cloud | https://api.bencher.dev |
| Bencher Self-Hosted | http://localhost:61016 |
Bencher CLI
bencher token create USER View OpenAPI Spec
View a token
⚠️ Breaking Changes: The Bencher API is in beta and under active development. We may introduce breaking changes in future releases. We will announce any breaking changes in the release notes.
View an API token for a user. Only the authenticated user themselves and server admins have access to this endpoint.
Headers
Content-Type string
Set to application/json.
Authorization string
Set to Bearer BENCHER_API_KEY, where BENCHER_API_KEY is a valid Bencher API key (or a deprecated API token).
Path Parameters
tokenThe UUID for a token.
userThe slug or UUID for a user.
/v0/users/{user}/tokens/{token} | Bencher Cloud | https://api.bencher.dev |
| Bencher Self-Hosted | http://localhost:61016 |
Bencher CLI
bencher token view USER TOKEN View OpenAPI Spec
Update a token
⚠️ Breaking Changes: The Bencher API is in beta and under active development. We may introduce breaking changes in future releases. We will announce any breaking changes in the release notes.
Update an API token for a user. Only the authenticated user themselves and server admins have access to this endpoint.
Headers
Content-Type string
Set to application/json.
Authorization string
Set to Bearer BENCHER_API_KEY, where BENCHER_API_KEY is a valid Bencher API key (or a deprecated API token).
Path Parameters
tokenThe UUID for a token.
userThe slug or UUID for a user.
Body Parameters
namestring
The new name of the token. Maximum length is 64 characters.
/v0/users/{user}/tokens/{token} | Bencher Cloud | https://api.bencher.dev |
| Bencher Self-Hosted | http://localhost:61016 |
Bencher CLI
bencher token update USER TOKEN View OpenAPI Spec
Revoke a token
⚠️ Breaking Changes: The Bencher API is in beta and under active development. We may introduce breaking changes in future releases. We will announce any breaking changes in the release notes.
Revoke an API token for a user. Revocation is terminal: a revoked token can no longer authenticate any request, and the revocation cannot be undone (for security — a leaked JWT must not become valid again). Only the authenticated user themselves and server admins have access to this endpoint.
Headers
Content-Type string
Set to application/json.
Authorization string
Set to Bearer BENCHER_API_KEY, where BENCHER_API_KEY is a valid Bencher API key (or a deprecated API token).
Path Parameters
tokenThe UUID for a token.
userThe slug or UUID for a user.
/v0/users/{user}/tokens/{token} | Bencher Cloud | https://api.bencher.dev |
| Bencher Self-Hosted | http://localhost:61016 |
Bencher CLI
bencher token revoke USER TOKEN View OpenAPI Spec