# Count the life events of each slice

`GET /api/v1/vaults/{vault}/life-event-slices` and `QUERY /api/v1/vaults/{vault}/life-event-slices`

Count the life events of a vault in each slice of its timeline: what is upcoming, then each year before today.

Every count comes from one reading of the vault, so the answer costs the same however many years it holds. Deleted life events are left out.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. [How QUERY works](https://my.monicahq.com/docs/api/query-method).

## Parameters

- `vault` (string, required): The vault the life events live in, named either by the readable name it reports as slug or by its id.
- `contact` (string, optional): Count only the life events this contact took part in, named by its slug or its id. A contact of another vault answers 404.
- `life_event_type` (string, optional): Count only the life events of this type, named by its id. A type deleted since still counts the life events recorded as it. A type of another account answers 404.

## Returns

The slices and their counts. A vault of another account answers 404.

- `data` (array): The slices of the timeline: upcoming first, then every year holding a life event before today, the most recent first.
- `data[]` (object): One slice.
- `data[].slice` (string): upcoming, or a year written with four digits. Pass it as slice to the list of life events.
- `data[].count` (integer): How many life events the slice holds under contact and life_event_type.
- `data[].total` (integer): How many life events the slice holds without them, so a year they empty is still listed.
- `meta` (object): What holds for the whole vault.
- `meta.total` (integer): How many life events the vault holds.
- `meta.today` (string): The key owner’s today, written Y-m-d, which separates what is upcoming from the past.

## Status codes

| Code | When | Body |
| --- | --- | --- |
| `422` Unprocessable Content | With QUERY, a parameter was sent both in the address and in the body. | A message, and an errors object naming each parameter sent twice. |

## 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://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices');
```

## Request with QUERY

```sh
curl https://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://my.monicahq.com/api/v1/vaults/dunder-mifflin/life-event-slices');
```

## Response

`200`

```json
{
    "data": [
        {
            "slice": "upcoming",
            "count": 2,
            "total": 2
        },
        {
            "slice": "2025",
            "count": 14,
            "total": 18
        },
        {
            "slice": "2024",
            "count": 0,
            "total": 9
        }
    ],
    "meta": {
        "total": 29,
        "today": "2026-11-22"
    }
}
```
