Skip to content

API Keys

Codecosts API keys (sk_...) authenticate CLI and SDK access to the dashboard API. They are unrelated to your Anthropic API key.

Each key is hashed with SHA-256 before storage — the raw key is only returned once on creation.

GET /api/api-keys

Returns a paginated list of API keys for the authenticated user’s organization.

Auth required: Yes

ParameterTypeDescription
cursorstringPagination cursor from previous response
limitnumberItems per page (1–100, default 20)
Terminal window
curl https://codecosts.com/api/api-keys \
-H "Authorization: Bearer sk_your_api_key"
{
"items": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "CLI - MacBook Pro",
"key_prefix": "sk_abc12...",
"last_used_at": "2026-01-15T10:00:00.000Z",
"created_at": "2026-01-01T00:00:00.000Z"
}
],
"nextCursor": null,
"hasMore": false
}

POST /api/api-keys

Creates a new API key. The raw key is returned only once — store it securely.

Auth required: Yes

FieldTypeRequiredDescription
namestringYesA human-readable label for the key (e.g. “CLI - MacBook Pro”)
Terminal window
curl -X POST https://codecosts.com/api/api-keys \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"name": "CLI - MacBook Pro"}'
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "CLI - MacBook Pro",
"key": "sk_abc123def456ghi789jklmnopqrstuvwxyz12345",
"key_prefix": "sk_abc12...",
"created_at": "2026-01-01T00:00:00.000Z"
}

DELETE /api/api-keys/:id

Deletes an API key. Only the owner can delete their own keys.

Auth required: Yes

Terminal window
curl -X DELETE https://codecosts.com/api/api-keys/550e8400-... \
-H "Authorization: Bearer sk_your_api_key"
{
"ok": true
}