Tokens
Service token management for CI/CD
Tokens
Service token management for CI/CD
List service tokens
GET /api/v1/tokensReturns all service tokens created by the user
Operation ID: listTokens · Authentication: Authorization: Bearer <token>
Responses
| Status | Description | Body |
|---|---|---|
200 | List of tokens | object |
401 | Authentication required | Error |
Response body (200)
| Field | Type | Description |
|---|---|---|
tokens | object[] |
Example
curl -X GET "https://api.keyenv.dev/api/v1/tokens" \
-H "Authorization: Bearer $KEYENV_TOKEN"Create service token
POST /api/v1/tokensCreates a new service token for CI/CD or programmatic access.
Important: The token value is only returned once upon creation. Store it securely.
Operation ID: createToken · Authentication: Authorization: Bearer <token>
Request body
application/json (required)
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | |
team_id | string (uuid) | yes | |
scopes | enum (read, write)[] | yes | |
expires_at | string (date-time) | no | Optional expiration date |
Responses
| Status | Description | Body |
|---|---|---|
201 | Token created | object |
400 | Invalid request | Error |
401 | Authentication required | Error |
403 | Insufficient permissions | Error |
Example
curl -X POST "https://api.keyenv.dev/api/v1/tokens" \
-H "Authorization: Bearer $KEYENV_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"string","team_id":"00000000-0000-0000-0000-000000000000","scopes":["read"],"expires_at":"string"}'Delete service token
DELETE /api/v1/tokens/{tokenId}Permanently revokes a service token
Operation ID: deleteToken · Authentication: Authorization: Bearer <token>
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
tokenId | string (uuid) | yes | Service token UUID |
Responses
| Status | Description | Body |
|---|---|---|
204 | Token deleted | |
401 | Authentication required | Error |
403 | Insufficient permissions | Error |
404 | Resource not found | Error |
Example
curl -X DELETE "https://api.keyenv.dev/api/v1/tokens/{tokenId}" \
-H "Authorization: Bearer $KEYENV_TOKEN"Rotate service token
POST /api/v1/tokens/{tokenId}/rotateRotates a service token, creating a new one with an optional grace period during which the old token remains valid. This allows seamless token rotation in CI/CD systems.
Operation ID: rotateToken · Authentication: Authorization: Bearer <token>
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
tokenId | string (uuid) | yes | Service token UUID |
Request body
application/json
| Field | Type | Required | Description |
|---|---|---|---|
grace_period_minutes | integer | no | How long the old token remains valid |
Responses
| Status | Description | Body |
|---|---|---|
200 | Token rotated successfully | RotateTokenResponse |
401 | Authentication required | Error |
403 | Insufficient permissions | Error |
404 | Resource not found | Error |
Response body (200)
| Field | Type | Description |
|---|---|---|
new_token | object | |
old_token_expires_at | string (date-time) |
Example
curl -X POST "https://api.keyenv.dev/api/v1/tokens/{tokenId}/rotate" \
-H "Authorization: Bearer $KEYENV_TOKEN" \
-H "Content-Type: application/json" \
-d '{"grace_period_minutes":5}'