# API Keys

## Create

`admin.api_keys.create(APIKeyCreateParams**kwargs)  -> APIKeyCreateResponse`

**post** `/compute/v1/admin/api-keys`

Create a workspace API key

### Parameters

- `name: str`

  API key name

- `allowed_ips: Optional[SequenceNotStr[str]]`

  IP addresses allowed to use this key (IPv4 or IPv6). An empty array (the default) means all IPs are allowed.

- `expires_in_days: Optional[int]`

  Days until the key expires. Omit for a key that does not expire.

- `mode: Optional[Literal["live", "test"]]`

  Key mode. Test keys create test-mode resources with synthetic data.

  - `"live"`

  - `"test"`

- `workspace_id: Optional[str]`

  Workspace ID to scope this key to. Omit for default workspace.

### Returns

- `class APIKeyCreateResponse: …`

  - `key: str`

    The full API key. This is only shown once — store it securely.

  - `key_details: KeyDetails`

    - `id: str`

      API key ID

    - `allowed_ips: List[str]`

      IP addresses allowed to use this key. An empty array means all IPs are allowed.

    - `created_at: datetime`

    - `expires_at: Optional[datetime]`

      When the key expires. Null if the key does not expire.

    - `is_active: bool`

    - `key_prefix: str`

      First 12 characters of the key

    - `key_type: Literal["workspace"]`

      - `"workspace"`

    - `last_used_at: Optional[datetime]`

    - `livemode: bool`

      Whether this is a live API key (false for test keys).

    - `name: str`

      API key name

    - `workspace_id: str`

      Workspace this key is scoped to

### Example

```python
import os
from boltz_api import Boltz

client = Boltz(
    api_key=os.environ.get("BOLTZ_API_KEY"),  # This is the default and can be omitted
)
api_key = client.admin.api_keys.create(
    name="x",
)
print(api_key.key)
```

## List

`admin.api_keys.list(APIKeyListParams**kwargs)  -> SyncCursorPage[APIKeyListResponse]`

**get** `/compute/v1/admin/api-keys`

List API keys

### Parameters

- `after_id: Optional[str]`

  Return results after this ID

- `before_id: Optional[str]`

  Return results before this ID

- `limit: Optional[int]`

  Max items to return

- `workspace_id: Optional[str]`

  Filter by workspace ID. If not provided, returns keys across all workspaces.

### Returns

- `class APIKeyListResponse: …`

  - `id: str`

    API key ID

  - `allowed_ips: List[str]`

    IP addresses allowed to use this key. An empty array means all IPs are allowed.

  - `created_at: datetime`

  - `expires_at: Optional[datetime]`

    When the key expires. Null if the key does not expire.

  - `is_active: bool`

  - `key_prefix: str`

    First 12 characters of the key

  - `key_type: Literal["admin", "workspace"]`

    - `"admin"`

    - `"workspace"`

  - `last_used_at: Optional[datetime]`

  - `livemode: bool`

    Whether this is a live API key (false for test keys).

  - `name: str`

    API key name

  - `workspace_id: Optional[str]`

    Workspace ID if workspace-scoped

### Example

```python
import os
from boltz_api import Boltz

client = Boltz(
    api_key=os.environ.get("BOLTZ_API_KEY"),  # This is the default and can be omitted
)
page = client.admin.api_keys.list()
page = page.data[0]
print(page.id)
```

## Revoke

`admin.api_keys.revoke(strapi_key_id)  -> APIKeyRevokeResponse`

**post** `/compute/v1/admin/api-keys/{api_key_id}/revoke`

Revoke an API key

### Parameters

- `api_key_id: str`

### Returns

- `class APIKeyRevokeResponse: …`

  - `id: str`

    API key ID

  - `allowed_ips: List[str]`

    IP addresses allowed to use this key. An empty array means all IPs are allowed.

  - `created_at: datetime`

  - `expires_at: Optional[datetime]`

    When the key expires. Null if the key does not expire.

  - `is_active: bool`

  - `key_prefix: str`

    First 12 characters of the key

  - `key_type: Literal["admin", "workspace"]`

    - `"admin"`

    - `"workspace"`

  - `last_used_at: Optional[datetime]`

  - `livemode: bool`

    Whether this is a live API key (false for test keys).

  - `name: str`

    API key name

  - `workspace_id: Optional[str]`

    Workspace ID if workspace-scoped

### Example

```python
import os
from boltz_api import Boltz

client = Boltz(
    api_key=os.environ.get("BOLTZ_API_KEY"),  # This is the default and can be omitted
)
response = client.admin.api_keys.revoke(
    "api_key_id",
)
print(response.id)
```
