Api Keys
Create, list, update, and revoke API keys. Uses the v1 API endpoints on the app node.
Create, list, update, and revoke API keys.
Uses the v1 API endpoints on the app node.
cosmicac api-keys <subcommand> [options]
| Subcommand | Description |
|---|
| create | Create an API key |
| get | Get API key details |
| list | List API keys |
| revoke | Revoke an API key |
| update | Update an API key |
| usage | Get API key usage |
Create a new API key. The full key value is only returned once at creation time.
cosmicac api-keys create <name> [options]
| Argument | Required | Description |
|---|
name | Yes | Display name for the API key |
| Option | Description |
|---|
--expiry-at | Unix timestamp when the key expires |
Retrieve details for a single API key by ID.
cosmicac api-keys get <id>
| Argument | Required | Description |
|---|
id | Yes | API key ID |
List API keys owned by the authenticated user.
cosmicac api-keys list [options]
| Option | Description |
|---|
--page | Page number (default 1) |
--page-size | Results per page, 1-100 (default 20) |
--status | Filter by status: active, revoked, or all (default all) |
--sort-by | Sort field: created_at, updated_at, name, or last_used_at |
--sort-order | Sort direction: asc or desc (default desc) |
--include-total | Include total count in response metadata |
Revoke an API key. Revoked keys cannot be used for authentication but usage history is preserved.
cosmicac api-keys revoke <id>
| Argument | Required | Description |
|---|
id | Yes | API key ID |
Rename an active API key.
cosmicac api-keys update <id> [options]
| Argument | Required | Description |
|---|
id | Yes | API key ID |
| Option | Description |
|---|
--name | New display name |
Retrieve token and request usage statistics for one or more API keys.
cosmicac api-keys usage [options]
| Option | Description |
|---|
--api-key-id | Comma-separated API key IDs (defaults to all active keys) |
--ts-start | Start timestamp in milliseconds |
--ts-end | End timestamp in milliseconds |
--granularity | Time bucket size: hour, day, week, or month (default day) |
--page | Page number for snapshot pagination |
--page-size | Results per page (default 50, max 200) |
--sort-by | Sort field: timestamp, tokens_in, tokens_out, or requests |
--sort-order | Sort direction: asc or desc |
--include-total | Include total count in metadata |