Skip to content
Get started

Create

client.projects.apiKeys.create(stringprojectID, APIKeyCreateParams { maxConsumption, name, role } body, RequestOptionsoptions?): APIKeyCreateResponse { id, authorId, createdAt, 5 more }
POST/projects/{projectId}/api-keys

Create an API key for a particular project

ParametersExpand Collapse
projectID: string
body: APIKeyCreateParams { maxConsumption, name, role }
maxConsumption?: number

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?: string

The API Key name

role?: string

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
APIKeyCreateResponse { id, authorId, createdAt, 5 more }
id: string
authorId: string
createdAt: string
ownerType: "project" | "team"
One of the following:
"project"
"team"
secret: string
userId: string

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

ownerId?: string
teamId?: string

Create

import Scenario from '@scenario-labs/sdk';

const client = new Scenario({
  apiKey: process.env['SCENARIO_SDK_API_KEY'], // This is the default and can be omitted
  apiSecret: process.env['SCENARIO_SDK_API_SECRET'], // This is the default and can be omitted
});

const apiKey = await client.projects.apiKeys.create('projectId');

console.log(apiKey.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"
}