# List notifications

`GET /api/v1/notifications`

List what the application has told you, newest first.

These are yours rather than the account's: the list is scoped to whoever the token belongs to. One record is written per channel, so a reminder that went out both in the application and by email appears twice, once for each.

Notifications are removed automatically once they pass the retention period this instance is set to. That is a stated policy rather than a silent loss, and what a reminder itself records outlives it: the deadline still says somebody was told.

This endpoint also answers QUERY, with the same parameters sent in the request body. [How QUERY works](https://my.monicahq.com/docs/api/query-method).

## Query parameters

- `read` (string, optional, defaults to everything): Narrow the list to what has been read, with true, or to what has not, with false. Anything else is ignored and the whole list comes back.
- `page` (integer, optional, defaults to 1): Which page to answer with.
- `per_page` (integer, optional, defaults to 25): How many notifications one page holds, between 1 and 100. A number outside the range is brought back into it rather than refused.

## Returns

A page of notifications, and how many there are in all. An account that has never been told anything gets an empty list rather than an error.

- `data` (array): The notifications on this page. An empty list rather than an error when there are none.
- `data[]` (object): One notification.
- `data[].type` (string): Always notification. 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.notification_type` (string): What the notification is about, as a key such as reminder_due or digest. The set grows as the product finds new things to say, so match the keys you care about and let an unfamiliar one through rather than treating it as an error.
- `data[].attributes.channel` (string): Which way it went out: in_app, email, slack, telegram or sms. One notification is written per channel, so a reminder that went out two ways is two records here, alike in everything but this field.
- `data[].attributes.title` (string): The one line it leads with, up to 255 characters. For a reminder it is the name of the reminder.
- `data[].attributes.body` (string): What it says under the title, of no fixed length, written in the language the account was set to at the moment it was made rather than the one you are asking in.
- `data[].attributes.scheduled_for` (timestamp): When it was due, as a count of seconds since 1970. Quiet hours can hold a notification back, so this can be earlier than sent_at by hours.
- `data[].attributes.sent_at` (timestamp): When it went out, as a count of seconds since 1970, or null when it has not gone out yet.
- `data[].attributes.read_at` (timestamp): When it was first read, as a count of seconds since 1970, or null when it has not been. Reading something twice keeps the first moment.
- `data[].attributes.failure_reason` (string): What the channel said when it refused, up to 255 characters, or null when nothing refused. A notification that failed keeps its record and its reason rather than disappearing.
- `data[].attributes.created_at` (timestamp): When the record was written, as a count of seconds since 1970.
- `data[].links` (object): Where to find this record.
- `data[].links.self` (string): The absolute address this record is read from.
- `meta` (object): Where you are in the collection.
- `meta.page` (integer): The page this is, counting from 1.
- `meta.per_page` (integer): How many one page holds, which is the size that was asked for once it has been brought into the allowed range.
- `meta.total` (integer): How many notifications there are in all, not how many are on this page.

## 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/notifications \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/notifications', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://my.monicahq.com/api/v1/notifications');
```

## Response

`200`

```json
{
    "data": [
        {
            "type": "notification",
            "id": "9c7f2a1e-4b6d-4f0a-9f2b-1d3c5e7a9b11",
            "attributes": {
                "notification_type": "reminder_due",
                "channel": "in_app",
                "title": "Birthday, Michael Scott",
                "body": "It is in seven days.",
                "scheduled_for": 1756339200,
                "sent_at": 1756339210,
                "read_at": null,
                "failure_reason": null,
                "created_at": 1756339200
            },
            "links": {
                "self": "https://my.monicahq.com/api/v1/notifications/9c7f2a1e-4b6d-4f0a-9f2b-1d3c5e7a9b11"
            }
        },
        {
            "type": "notification",
            "id": "2f8e6c4a-7d1b-4e93-8a05-6c9f1b2d3e44",
            "attributes": {
                "notification_type": "reminder_due",
                "channel": "email",
                "title": "Anniversary, Jim Halpert",
                "body": "It is today.",
                "scheduled_for": 1756339200,
                "sent_at": 1756339210,
                "read_at": 1756342800,
                "failure_reason": null,
                "created_at": 1756339200
            },
            "links": {
                "self": "https://my.monicahq.com/api/v1/notifications/2f8e6c4a-7d1b-4e93-8a05-6c9f1b2d3e44"
            }
        }
    ],
    "meta": {
        "page": 1,
        "per_page": 25,
        "total": 2
    }
}
```
