POST
/
api
/
v1
/
tokens
{
  "error": "Cannot create token with requested permissions"
}
Creates a new project API token that can be used for programmatic access to the API. A user can only create tokens with permissions they themselves possess.
Requires User token authentication
Required permissions: create on token resource

Request Body

name
string
required
Descriptive name for the token
permissions
array
required
Array of permissions for the token. Cannot exceed user’s own permissions.
expires_at
string
Optional expiration date in ISO 8601 format

Example

curl -X POST "https://api.garnet.ai/v1/tokens" \
  -H "Authorization: Bearer $USER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "CI/CD Pipeline Token",
    "permissions": ["read", "list"],
    "expires_at": "2025-12-31T23:59:59Z"
  }'

Response

id
string
Unique token identifier
token
string
The actual token value (only shown once)
name
string
Token name
permissions
array
Granted permissions
created_at
string
Creation timestamp
expires_at
string
Expiration timestamp (if set)
The token value is only displayed once. Save it securely.

Error Examples

{
  "error": "Cannot create token with requested permissions"
}