# API Keys

## Create

`projects.api_keys.create(strproject_id, APIKeyCreateParams**kwargs)  -> APIKeyCreateResponse`

**post** `/projects/{projectId}/api-keys`

Create an API key for a particular project

### Parameters

- `project_id: str`

- `max_consumption: Optional[float]`

  Optional spending cap (CU) for this key over the billing period: a value >= 0 to cap, or -1 for unlimited. Omit to inherit the default.

- `name: Optional[str]`

  The API Key name

- `role: Optional[str]`

  Project role: a built-in role (admin | editor | reader) or a custom inline ";"-separated scope list (e.g. "assets.read;workflows.run"). Defaults to editor.

### Returns

- `class APIKeyCreateResponse: …`

  - `id: str`

  - `author_id: str`

  - `created_at: str`

  - `owner_type: Literal["project", "team"]`

    - `"project"`

    - `"team"`

  - `secret: str`

  - `user_id: str`

    The key's member id (`apiu_...`), taken by the member routes; the
    api-keys routes take `id`.

  - `owner_id: Optional[str]`

  - `team_id: Optional[str]`

### Example

```python
import os
from scenario_sdk import Scenario

client = Scenario(
    api_key=os.environ.get("SCENARIO_SDK_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SCENARIO_SDK_API_SECRET"),  # This is the default and can be omitted
)
api_key = client.projects.api_keys.create(
    project_id="projectId",
)
print(api_key.id)
```

#### Response

```json
{
  "id": "id",
  "authorId": "authorId",
  "createdAt": "createdAt",
  "ownerType": "project",
  "secret": "secret",
  "userId": "userId",
  "ownerId": "ownerId",
  "teamId": "teamId"
}
```

## Delete

`projects.api_keys.delete(strkey_id, APIKeyDeleteParams**kwargs)  -> object`

**delete** `/projects/{projectId}/api-keys/{keyId}`

Delete a particular api key

### Parameters

- `project_id: str`

- `key_id: str`

### Returns

- `object`

### Example

```python
import os
from scenario_sdk import Scenario

client = Scenario(
    api_key=os.environ.get("SCENARIO_SDK_API_KEY"),  # This is the default and can be omitted
    api_secret=os.environ.get("SCENARIO_SDK_API_SECRET"),  # This is the default and can be omitted
)
api_key = client.projects.api_keys.delete(
    key_id="keyId",
    project_id="projectId",
)
print(api_key)
```

#### Response

```json
{}
```

## Domain Types

### API Key Create Response

- `class APIKeyCreateResponse: …`

  - `id: str`

  - `author_id: str`

  - `created_at: str`

  - `owner_type: Literal["project", "team"]`

    - `"project"`

    - `"team"`

  - `secret: str`

  - `user_id: str`

    The key's member id (`apiu_...`), taken by the member routes; the
    api-keys routes take `id`.

  - `owner_id: Optional[str]`

  - `team_id: Optional[str]`
