Skip to content
Get started

Create

projects.api_keys.create(strproject_id, APIKeyCreateParams**kwargs) -> APIKeyCreateResponse
POST/projects/{projectId}/api-keys

Create an API key for a particular project

ParametersExpand Collapse
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.

ReturnsExpand Collapse
class APIKeyCreateResponse: …
id: str
author_id: str
created_at: str
owner_type: Literal["project", "team"]
One of the following:
"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]

Create

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)
{
  "id": "id",
  "authorId": "authorId",
  "createdAt": "createdAt",
  "ownerType": "project",
  "secret": "secret",
  "userId": "userId",
  "ownerId": "ownerId",
  "teamId": "teamId"
}
Returns Examples
{
  "id": "id",
  "authorId": "authorId",
  "createdAt": "createdAt",
  "ownerType": "project",
  "secret": "secret",
  "userId": "userId",
  "ownerId": "ownerId",
  "teamId": "teamId"
}