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.
List API Keys
Section titled “List API Keys”GET /api/api-keys
Returns a paginated list of API keys for the authenticated user’s organization.
Auth required: Yes
Query parameters
Section titled “Query parameters”| Parameter | Type | Description |
|---|---|---|
cursor | string | Pagination cursor from previous response |
limit | number | Items per page (1–100, default 20) |
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}Create API Key
Section titled “Create API Key”POST /api/api-keys
Creates a new API key. The raw key is returned only once — store it securely.
Auth required: Yes
Request body
Section titled “Request body”| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A human-readable label for the key (e.g. “CLI - MacBook Pro”) |
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 Key
Section titled “Delete API Key”DELETE /api/api-keys/:id
Deletes an API key. Only the owner can delete their own keys.
Auth required: Yes
curl -X DELETE https://codecosts.com/api/api-keys/550e8400-... \ -H "Authorization: Bearer sk_your_api_key"{ "ok": true}