---
title: "Create collection"
method: POST
path: "/_fabric/{fabric}/_api/collection"
tags: ["Collections"]
---

# Create collection

`POST /_fabric/{fabric}/_api/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/collection/post.ts> (a function with typed inputs; its response is checked against the schema)

Create collection.

## Path parameters

- `fabric` string, string, required

## Request body

- FabricCollectionValidate
  - `isLocal` boolean: If *true*, create a local collection. For a local collection data is not replicated across regions.
  - `keyOptions` FabricCollectionValidateKeyoption: Additional options for key generation. If specified, *keyOptions* should be a JSON array containing the following attributes:
    - `allowUserKeys` boolean: If set to *true*, you can supply a key value in the *_key* attribute of a document. If set to *false*, the key generator creates keys and an error occurs if you add a *_key* value
    - `increment` integer: Increment value for *autoincrement* key generator. Not used for other key generator types.
    - `offset` integer: Initial offset value for *autoincrement* key generator. Not used for other key generator types.
    - `type` string: Specifies the type of the key generator. - *traditional*: generates numerical keys in ascending order. - *autoincrement:* generates numerical keys in ascending order with configurable initial offset and spacing. - *padded:* generates keys of a fixed length (16 bytes) in ascending lexicographical sort order. - *uuid64*: generates universally unique keys.
  - `name` string, required: The name of the collection.
  - `cacheEnabled` boolean: *True* if collection has cache enabled
  - `waitForSync` boolean: *True* if all data must be synced to storage before operation returns.
  - `enableShards` boolean: If *true*, enable sharding for the collection.
  - `type` integer: The type of the collection to create. - *2*: document collection - *3*: edge collection.
  - `stream` boolean: If *true*, create a local stream for collection.

## Response `200`

Successfully created collection.

- ApiCollectionHttp200Help
  - `id` string: Id of the the collection.
  - `name` string: Name of the collection.
  - `status` number: Status of the collection.
  - `type` number: Type of the collection. - *2*: document collection - *3*: edge collection
  - `collectionModel` string: Type of collection model. - *DOC*: document model - *KV*: key/value model - *DYNAMO*: dynamo model
  - `isSpot` boolean: *True* if collection is a spot collection.
  - `isLocal` boolean: *True* if collection is a local collection, *False* if collection is a global collection
  - `hasStream` boolean: *True* if collection has a stream.
  - `waitForSync` boolean: **True* if all data must be synced to storage before operation returns.
  - `isSystem` boolean: *True* if collection is a system collection.
  - `globallyUniqueId` string: Collection's global unique Id.
  - `searchEnabled` boolean: *True* if collection is searchable.

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `404`: Failed to find specified 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)
