# API Keys

## Create

`client.projects.apiKeys.create(stringprojectID, APIKeyCreateParamsbody, RequestOptionsoptions?): APIKeyCreateResponse`

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

Create an API key for a particular project

### Parameters

- `projectID: string`

- `body: APIKeyCreateParams`

  - `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.

### Returns

- `APIKeyCreateResponse`

  - `id: string`

  - `authorId: string`

  - `createdAt: string`

  - `ownerType: "project" | "team"`

    - `"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`

### Example

```typescript
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);
```

#### Response

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

## Delete

`client.projects.apiKeys.delete(stringkeyID, APIKeyDeleteParamsparams, RequestOptionsoptions?): APIKeyDeleteResponse`

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

Delete a particular api key

### Parameters

- `keyID: string`

- `params: APIKeyDeleteParams`

  - `projectId: string`

    The project Id on which the api key exists

### Returns

- `APIKeyDeleteResponse = unknown`

### Example

```typescript
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.delete('keyId', { projectId: 'projectId' });

console.log(apiKey);
```

#### Response

```json
{}
```

## Domain Types

### API Key Create Response

- `APIKeyCreateResponse`

  - `id: string`

  - `authorId: string`

  - `createdAt: string`

  - `ownerType: "project" | "team"`

    - `"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`

### API Key Delete Response

- `APIKeyDeleteResponse = unknown`
