# Create a collection

> Source: https://elaichi.ai/docs/api-reference/collections/collection/createcollection/

`POST /collection`

Resource: **Collection** · API: **Collections**

## Request body

- **`name`** _(string)_
- **`description`** _(string)_
- **`fields`** _(array<object>)_
  - **`id`** _(string)_
  - **`key`** _(string)_
  - **`name`** _(string)_
  - **`type`** _(string)_
  - **`required`** _(boolean)_
  - **`indexed`** _(boolean)_
  - **`description`** _(string)_
  - **`options`** _(unknown)_

## Response body

- **`id`** _(string)_
- **`owner_user_id`** _(string)_
- **`name`** _(string)_
- **`description`** _(string)_
- **`schema_version`** _(integer)_
- **`field_count`** _(integer)_
- **`row_scope_field`** _(string,null)_
- **`stats`** _(object,null)_
- **`created_at`** _(string)_
- **`updated_at`** _(string)_
- **`row_visibility`** _(string)_
  Allowed: `all`, `own`
- **`owner_display_name`** _(string,null)_
- **`owner_avatar_url`** _(string,null)_
  The person's picture: their stored profile picture, else a Gravatar URL (`d=404`, 96px) derived from their email (the address itself is not sent), else null. Draw initials when it is null or the image fails to load.
- **`can_use`** _(boolean)_
- **`can_share`** _(boolean)_
- **`can_manage`** _(boolean)_
- **`can_transfer`** _(boolean)_
- **`can_revoke_share`** _(boolean)_
- **`can_see_shares`** _(boolean)_
- **`access_via`** _(string)_
- **`access_summary`** _(unknown)_
- **`schema`** _(object)_
  - **`version`** _(integer)_
  - **`fields`** _(array<object>)_
    - **`id`** _(string)_
    - **`key`** _(string)_
    - **`name`** _(string)_
    - **`type`** _(string)_
    - **`required`** _(boolean)_
    - **`indexed`** _(boolean)_
    - **`description`** _(string)_
    - **`options`** _(unknown)_
  - **`primary_field`** _(string)_
  - **`unique_key`** _(array,null)_
  - **`row_scope`** _(object,null)_
- **`hidden_field_keys`** _(array<string>)_
- **`reference_counts`** _(object)_
  - **`automations`** _(integer)_
  - **`dashboards`** _(integer)_

## Code examples

### curl

```bash
curl -X POST 'https://api.elaichi.ai/collection' \
  -H 'Authorization: Bearer $ELAICHI_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name":"your_name","description":"your_description","fields":[]}'
```

### JavaScript

```javascript
const body = {
  "name": "your_name",
  "description": "your_description",
  "fields": []
};

const response = await fetch('https://api.elaichi.ai/collection', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + process.env.ELAICHI_API_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import os
import requests

url = "https://api.elaichi.ai/collection"
headers = {
    "Authorization": f"Bearer {os.environ['ELAICHI_API_TOKEN']}",
    "Content-Type": "application/json",
}
payload = {
    "name": "your_name",
    "description": "your_description",
    "fields": []
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```
