# Collections
URL: /api/collections

Create, list, fetch, and delete collections.



## Create a collection [#create-a-collection]

<Callout type="info">
  Requires the admin key.
</Callout>

```
POST /collections
```

**Request body** — a `CollectionSchema`:

| Field                   | Type                   | Required | Description                                |
| ----------------------- | ---------------------- | -------- | ------------------------------------------ |
| `name`                  | string                 | yes      | Collection name                            |
| `fields`                | array of field schemas | yes      | See field shape below                      |
| `typo_tolerance`        | object                 | no       | See [Typo Tolerance](/docs/typo-tolerance) |
| `default_sorting_field` | string                 | no       | Field used to break ties / default sort    |

Each entry in `fields`:

| Field      | Type                                                                    | Default | Description                         |
| ---------- | ----------------------------------------------------------------------- | ------- | ----------------------------------- |
| `name`     | string                                                                  | —       | Field name                          |
| `type`     | `"text"` \| `"keyword"` \| `"int"` \| `"float"` \| `"bool"` \| `"date"` | —       | Field type                          |
| `facet`    | bool                                                                    | `false` | Usable in the `facet` search param  |
| `filter`   | bool                                                                    | `false` | Usable in a `filter` expression     |
| `sort`     | bool                                                                    | `false` | Usable in the `sort` param          |
| `index`    | bool                                                                    | `true`  | Indexed for full-text search        |
| `optional` | bool                                                                    | `true`  | Documents may omit this field       |
| `boost`    | float                                                                   | —       | Relevance multiplier for this field |

<Tabs items="['cURL', 'TypeScript', 'Python', 'C#']">
  <Tab value="cURL">
    ```bash
    curl -X POST localhost:8108/collections \
      -H 'Content-Type: application/json' \
      -H 'x-tachyon-api-key: your-admin-key' \
      -d '{
        "name": "products",
        "fields": [
          {"name": "title",       "type": "text"},
          {"name": "description", "type": "text"},
          {"name": "brand",       "type": "keyword", "facet": true},
          {"name": "price",       "type": "int",     "filter": true, "sort": true}
        ]
      }'
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    import { Tachyon } from 'tachyon-sdk';

    const client = new Tachyon({ url: 'http://localhost:8108', apiKey: 'your-admin-key' });

    await client.collections.create({
      name: 'products',
      fields: [
        { name: 'title', type: 'text' },
        { name: 'description', type: 'text' },
        { name: 'brand', type: 'keyword', facet: true },
        { name: 'price', type: 'int', filter: true, sort: true },
      ],
    });
    ```
  </Tab>

  <Tab value="Python">
    ```python
    from tachyon_sdk import Tachyon

    client = Tachyon(url="http://localhost:8108", api_key="your-admin-key")

    client.collections.create({
        "name": "products",
        "fields": [
            {"name": "title", "type": "text"},
            {"name": "description", "type": "text"},
            {"name": "brand", "type": "keyword", "facet": True},
            {"name": "price", "type": "int", "filter": True, "sort": True},
        ],
    })
    ```
  </Tab>

  <Tab value="C#">
    ```csharp
    using Tachyon.Sdk;

    var client = new TachyonClient(new TachyonClientOptions { Url = "http://localhost:8108", ApiKey = "your-admin-key" });

    await client.Collections.CreateAsync(new CollectionSchema
    {
        Name = "products",
        Fields =
        [
            new FieldSchema { Name = "title", Type = FieldType.Text },
            new FieldSchema { Name = "description", Type = FieldType.Text },
            new FieldSchema { Name = "brand", Type = FieldType.Keyword, Facet = true },
            new FieldSchema { Name = "price", Type = FieldType.Int, Filter = true, Sort = true },
        ],
    });
    ```
  </Tab>
</Tabs>

**Response** — `201 Created`, a `CollectionView` (the schema, flattened,
plus stats):

```json
{
  "name": "products",
  "fields": [ "..." ],
  "typo_tolerance": { "enabled": true, "one_typo_min_len": 4, "two_typo_min_len": 8, "max_typos": 2 },
  "default_sorting_field": null,
  "created_at": 1750000000000,
  "num_documents": 0,
  "num_segments": 0
}
```

## List collections [#list-collections]

```
GET /collections
```

Requires the admin or search key. Returns an array of `CollectionView`.

## Get a collection [#get-a-collection]

```
GET /collections/{name}
```

Returns a single `CollectionView`, or `404 collection_not_found`.

## Delete a collection [#delete-a-collection]

<Callout type="info">
  Requires the admin key.
</Callout>

```
DELETE /collections/{name}
```

Deletes the collection and all of its documents. Not reversible.
