# Create a CMS API key

Canonical page: https://docs.ovok.com/api/payload-cms-api-keys/create-a-cms-api-key

`POST /v1/cms/api-keys`

Creates an API key for public CMS delivery (`/v1/public/cms/...`) of your current project's tenant. The answer carries the key itself, once: it is stored only as a hash and cannot be shown again.

**Auth:** bearer token of a project admin. The caller must also be a Practitioner, an admin or hold the System Owner access policy.
**Scope:** the caller's project (from the token).

## Behaviour

- `name` is 1 to 64 characters, trimmed.
- The key starts with `ovok_cms_`. Send it as `x-api-key`, `Authorization: Bearer` or `?apiKey=`, with the tenant it belongs to (`x-ovok-tenant-code`, `?tenant=`, `x-ovok-medplum-project-id` or `?projectId=`). Naming another project's tenant answers 401.
- A project holds at most 20 keys, the default key included: one more returns 409 `CMS_API_KEY_LIMIT`.
- A 409 without a code means the project changed while the server wrote. Retry.
- The answer is 201.

## Example

```bash
curl -X POST 'https://api.sandbox.ovok.com/v1/cms/api-keys' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -H 'Content-Type: application/json' \
  -d '{ "name": "Marketing site" }'
```
