---
title: "Create key-value collection"
method: POST
path: "/_fabric/{fabric}/_api/kv/{collection}"
tags: ["Key Value"]
---

# Create key-value collection

`POST /_fabric/{fabric}/_api/kv/{collection}`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/kv/:collection/post.ts> (a function with typed inputs; its response is checked against the schema)

Create key-value collection.

## Path parameters

- `fabric` string, string, required
- `collection` string, string, required

## Query parameters

- `expiration` boolean
- `group` boolean

## Request body

- object
  - `stream` boolean: Flag for on-demand stream collection
  - `enableShards` boolean: Enabling sharding for the collection
  - `waitForSync` boolean: *True* if all data must be synced to storage before operation returns.
  - `cacheEnabled` boolean: *True* if collection has cache enabled
  - `blobs` boolean: *True* if collection is a blob-only collection.
  - `shardKeys` string[]

## Response `200`

Successfully created key-value collection.

- KvCollectionExamplesRc200
  - `code` integer: HTTP response code.
  - `error` boolean, required: Flag if there is an error in response. *False* for this response.
  - `name` string: It shows name of the collection.

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `404`: Failed to find specified fabric or collection.
- `409`: Failed because collection already exists.
- `429`: Collection count exceeds the maximum number of collections per fabric.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
