---
title: "Create an API Key"
method: POST
path: "/keys"
tags: ["keys"]
---

# Create an API Key

`POST /keys`

Create an API Key with fine-grain access control. You can restrict access on both a per-collection and per-action level. The generated key is returned only during creation. You want to store this key carefully in a secure place.

## Request body

- ApiKeySchema
  - `value` string
  - `description` string, required
  - `actions` string[], required
  - `collections` string[], required
  - `expires_at` integer

## Response `201`

Created API key

- ApiKey
  - `value` string
  - `description` string, required
  - `actions` string[], required
  - `collections` string[], required
  - `expires_at` integer
  - `id` integer
  - `value_prefix` string

## Other responses

- `400` — Bad request, see error message for details
- `409` — API key generation conflict

## Changes

- **2024-02-13** `14b1d3553228` — 4 breaking, 5 info
  - the request property `description` became required
  - the response property `allOf[subschema #2]/id` became optional for the status `201`
  - the response property `allOf[subschema #2]/value_prefix` became optional for the status `201`
  - removed the required property `allOf[subschema #2]/value` from the response with the `201` status
  - …5 more
- **2022-08-04** `6c2fe01b69bc` — 1 breaking, 2 warning, 6 info
  - the response property `allOf[#/components/schemas/ApiKeySchema]/description` became optional for the status `201`
  - removed the request property `value`
  - removed the optional property `allOf[#/components/schemas/ApiKeySchema]/value` from the response with the `201` status
  - the request property `description` became optional
  - …5 more

[Change history](https://skmtc.dev/typesense/apis/typesense-api/changes/keys/post.md)

---

[API](https://skmtc.dev/typesense/apis/typesense-api.md) · [All operations](https://skmtc.dev/typesense/apis/typesense-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/typesense/typesense-api/revisions/1d9b3b61638e/schema)
