# Notifications

> The notifications of your account, newest first, with the unread counts the bell shows, and marking them read.

Source: https://docs.b7r.app/notifications

> Ids, names and times in the examples are samples. Read the real values from the API.

> With [updates](https://docs.b7r.app/updates) on, each notification this list shows also sends `inbox.notification_created`, naming it by `notification_id`, so you need not poll the list.

## List notifications

`GET /v1/notifications`

`filter`: `all` (the default), `updates` or `designs`. At most `limit` (1 to 50, 30 by default) a page; pass `next_cursor` as `cursor` for the next one, and follow it until it is `null`: a page can be shorter than `limit`. Each notification comes in both languages. A What’s New post shows while it is published.

Ticket conversations are not in this list; `unread` counts them with the rest, as the bell does.

Key: A key with the `notifications` area.

Query:

- `filter` (string): One of `all`, `updates`, `designs`.
- `limit` (string)
- `cursor` (string): 1 to 200.

Answer:

- `data` (array of object, required)
  - `id` (string (uuid), required)
  - `kind` (string, required)
  - `title` (object, required)
    - `ar` (string, required)
    - `en` (string, required)
  - `message` (object, required)
    - `ar` (string, required)
    - `en` (string, required)
  - `order_id` (string (uuid) or null, required)
  - `post_id` (string (uuid) or null, required)
  - `read` (boolean, required)
  - `created_at` (string, required): UTC, ISO 8601 with milliseconds and Z.
- `next_cursor` (string or null, required)
- `unread` (object, required): What is unread now, as the bell counts it.
  - `total` (integer, required)
  - `tickets` (integer, required)
  - `designs` (integer, required)
  - `updates` (integer, required)

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `invalid_request` (400), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl https://api.b7r.app/v1/notifications \
  -H "Authorization: Bearer $B7R_API_KEY"
```

```javascript
const res = await fetch("https://api.b7r.app/v1/notifications", {
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
  },
});
const data = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.b7r.app/v1/notifications",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK):

```json
{
  "data": [
    {
      "id": "8e9f0a1b-2c3d-4e4f-9a5b-6c7d8e9f0a1b",
      "kind": "order_status_changed",
      "title": {
        "ar": "تغيّرت حالة الطلب",
        "en": "Order status changed"
      },
      "message": {
        "ar": "الطلب B00000001042 قيد الإنتاج.",
        "en": "Order B00000001042 is in production."
      },
      "order_id": "9f0a1b2c-3d4e-4f5a-8b6c-7d8e9f0a1b2c",
      "post_id": null,
      "read": false,
      "created_at": "2026-11-26T10:00:00.000Z"
    }
  ],
  "next_cursor": null,
  "unread": {
    "total": 3,
    "tickets": 1,
    "designs": 0,
    "updates": 2
  }
}
```

## Mark notifications read

`POST /v1/notifications/read`

Send `ids` (at most 50) or `all: true`, one of the two. `marked` is how many were unread and are read now: a second call marks none.

Key: A key with the `notifications` area. Send `Idempotency-Key` and `Content-Type: application/json`.

Body:

- `ids` (array of string (uuid)): 1 to 50 items.
- `all` (constant): Always `true`.

Answer:

- `marked` (integer, required): How many were unread and are read now.

Errors: `unauthorized` (401), `area_forbidden` (403), `account_inactive` (403), `connection_disabled` (403), `https_required` (403), `invalid_request` (400), `idempotency_key_required` (400), `request_too_large` (413), `unsupported_media_type` (415), `rate_limited` (429), `internal_error` (500), `upstream_unavailable` (502), `api_unavailable` (503), `request_expired` (503), `service_unavailable` (503), `upstream_timeout` (504), `idempotency_mismatch` (409), `idempotency_in_flight` (409). See [Errors](https://docs.b7r.app/errors).

Request:

```bash
curl -X POST https://api.b7r.app/v1/notifications/read \
  -H "Authorization: Bearer $B7R_API_KEY" \
  -H "Idempotency-Key: $(uuidgen 2>/dev/null || node -e 'console.log(crypto.randomUUID())')" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "8e9f0a1b-2c3d-4e4f-9a5b-6c7d8e9f0a1b"
    ]
  }'
```

```javascript
const res = await fetch("https://api.b7r.app/v1/notifications/read", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.B7R_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "ids": [
      "8e9f0a1b-2c3d-4e4f-9a5b-6c7d8e9f0a1b"
    ]
  }),
});
const data = await res.json();
```

```python
import os, requests, uuid

res = requests.post(
    "https://api.b7r.app/v1/notifications/read",
    headers={
        "Authorization": f"Bearer {os.environ['B7R_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "ids": [
            "8e9f0a1b-2c3d-4e4f-9a5b-6c7d8e9f0a1b"
        ]
    },
    timeout=30,
)
data = res.json()
```

Answer (200 OK):

```json
{
  "marked": 1
}
```
