# Create API key

```http
POST /api-keys
```

Create an API key and return its secret once.

## Request body

| Field               | Type   | Required | Description                                                                                                                                                                                               |
| ------------------- | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project_reference` | string |          | Project ID or slug. Creating a project-scoped key requires project.api\_keys.manage. Omit for a user-level key; a project-scoped API-key caller retains its enforced project when this field is omitted.  |
| `name`              | string | Yes      |                                                                                                                                                                                                           |
| `scopes`            | array  |          | Requested permissions. Schema examples list all currently supported values. Omitted or empty scopes default to read-only (read). Project keys remain restricted by their project and creation permission. |
| `expires_at`        | string |          |                                                                                                                                                                                                           |

## Responses

| Status | Description                                                                                                 |
| ------ | ----------------------------------------------------------------------------------------------------------- |
| 201    | API key created successfully                                                                                |
| 400    | Bad request                                                                                                 |
| 401    | Unauthorized                                                                                                |
| 403    | Forbidden                                                                                                   |
| 404    | Not found                                                                                                   |
| 500    | Server error                                                                                                |
| 503    | internal: authentication state is temporarily unavailable and the request was not processed; retry shortly. |
