# Create a group

`POST /api/v1/vaults/{vault}/groups`

Create a group in a vault. It starts with nobody in it.

A date sent without its precision is taken as known to the day. A precision sent without its date is ignored.

Groups are not yet available to every account. Until they are available to yours, every endpoint here answers 404.

## Parameters

- `vault` (string, required): The vault the groups live in, named either by the readable name it reports as slug or by its id.
- `name` (string, required): What the group is called, up to 255 characters.
- `description` (string, optional): What the group is, up to 65,535 characters.
- `started_on` (string, optional): When it started, written as a year, a month and a day.
- `started_precision` (string, optional): How much of started_on is known: day, month, year, decade or unknown.
- `ended_on` (string, optional): When it ended, written as a year, a month and a day.
- `ended_precision` (string, optional): How much of ended_on is known: day, month, year, decade or unknown.

## Returns

The group object that was created.

- `data` (object): The group.
- `data.type` (string): Always group. It names the kind of record, so a caller holding several kinds can tell them apart without looking at where they came from.
- `data.id` (string): The id of this record, as a string even when it reads as a number. It is what every endpoint naming this record takes.
- `data.attributes` (object): Everything the record holds.
- `data.attributes.name` (string): What the group is called.
- `data.attributes.description` (string): What was written about it, or null.
- `data.attributes.started_on` (string): When it started, written as a year, a month and a day, or null.
- `data.attributes.started_precision` (string): How much of the date is known: day, month, year or decade. Always unknown when there is no date.
- `data.attributes.ended_on` (string): When it ended, written as a year, a month and a day, or null while it still exists.
- `data.attributes.ended_precision` (string): How much of the date is known: day, month, year or decade. Always unknown when there is no date.
- `data.attributes.current_member_count` (integer): How many people are in it today. Those who left are not counted.
- `data.attributes.created_at` (timestamp): When it was created, as a count of seconds since 1970.
- `data.attributes.updated_at` (timestamp): When it last changed, as a count of seconds since 1970, or null.
- `data.attributes.deleted_at` (timestamp): When it was deleted, as a count of seconds since 1970, or null.
- `data.links` (object): Where to find this record.
- `data.links.self` (string): The absolute address this record is read from.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin/groups \
  -X POST \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "name": "Party planning committee",
      "description": "Plans every birthday, retirement and holiday party of the Scranton branch.",
      "started_on": "2005-01-01",
      "started_precision": "year"
  }'
```

```javascript
const response = await fetch('https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin/groups', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    name: 'Party planning committee',
    description: 'Plans every birthday, retirement and holiday party of the Scranton branch.',
    started_on: '2005-01-01',
    started_precision: 'year',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->post('https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin/groups', [
    'name' => 'Party planning committee',
    'description' => 'Plans every birthday, retirement and holiday party of the Scranton branch.',
    'started_on' => '2005-01-01',
    'started_precision' => 'year',
]);
```

## Response

`201`

```json
{
    "data": {
        "type": "group",
        "id": "5d2a7c91-3e48-4b06-9f1d-a83c60e2b4f7",
        "attributes": {
            "name": "Party planning committee",
            "description": "Plans every birthday, retirement and holiday party of the Scranton branch.",
            "started_on": "2005-01-01",
            "started_precision": "year",
            "ended_on": null,
            "ended_precision": "unknown",
            "current_member_count": 3,
            "created_at": 1791547200,
            "updated_at": 1791547200,
            "deleted_at": null
        },
        "links": {
            "self": "https://people.hansyeoh.com/api/v1/vaults/dunder-mifflin/groups/5d2a7c91-3e48-4b06-9f1d-a83c60e2b4f7"
        }
    }
}
```
