---
search:
  tags:
    - Access
    - POST
seo:
  description: >-
    Create an API key. Reference for the POST /api-keys endpoint in the
    piecemeal API.
sidebar:
  label: Create an API key
  badge: POST
title: Create an API key
type: openapi-operation
---
`POST /api-keys`

**Request body** (`application/json`, required)

- `name` (string, required)
- `scope` (string, required)

Request body example:

```json
{
  "name": "string",
  "scope": "full"
}
```

**Responses**

- `201` — Created
- `401` — Unauthorized
- `403` — Forbidden
- `422` — Unprocessable Entity
- `500` — Internal Server Error

Response example, 201:

```json
{
  "createdAt": "2019-08-24T14:15:22Z",
  "id": 0,
  "key": "string",
  "lastUsedAt": "2019-08-24T14:15:22Z",
  "name": "string",
  "prefix": "string",
  "scope": "full",
  "userId": 0,
  "username": "string"
}
```
