> ## Documentation Index
> Fetch the complete documentation index at: https://developers.clay.com/llms.txt
> Use this file to discover all available pages before exploring further.

# api-keys create

> Create a Public API key and print its secret once.

Create an API key that authenticates the Clay Public API (`api.clay.com/public/v0`). The secret is returned only at creation — store it immediately, because it cannot be retrieved later. List existing keys with [`clay api-keys list`](/cli/reference/api-keys-list).

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay api-keys create --name <name>
```

## Flags

| Flag            | Description                          |
| --------------- | ------------------------------------ |
| `--name <name>` | Human-readable name for the API key. |

## Output

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "ak_abc123",
  "name": "CI key",
  "scopes": ["cli:all"],
  "workspaceId": 12345,
  "createdAt": "2026-01-01T00:00:00.000Z",
  "updatedAt": "2026-01-01T00:00:00.000Z",
  "apiKey": "clay_sk_..."
}
```

| Field         | Type                | Description                                                                                 |
| ------------- | ------------------- | ------------------------------------------------------------------------------------------- |
| `id`          | string              | API key id. Pass it to `update` or `delete`.                                                |
| `name`        | string              | The name you supplied.                                                                      |
| `scopes`      | string\[]           | Scopes granted to the key.                                                                  |
| `workspaceId` | number \| undefined | Workspace the key is scoped to, when set.                                                   |
| `createdAt`   | string              | ISO 8601 creation timestamp.                                                                |
| `updatedAt`   | string              | ISO 8601 last-updated timestamp.                                                            |
| `apiKey`      | string              | The secret. Returned **only once**, at creation — store it now; it cannot be fetched again. |

<Warning>
  The `apiKey` secret is shown only in this response. If you lose it, delete the key with [`clay api-keys
      delete`](/cli/reference/api-keys-delete) and create a new one.
</Warning>

## Errors

| Code               | Exit | Notes                                        |
| ------------------ | ---- | -------------------------------------------- |
| `validation_error` | 2    | `--name` is missing or empty.                |
| `auth_forbidden`   | 3    | The key lacks permission to create API keys. |

## Examples

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
clay api-keys create --name "CI key"
clay api-keys create --name "CI key" | jq -r '.apiKey'
```
