> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Count Unread Notifications

> Get the number of unread app notifications for the authenticated user

Returns the total number of unread app notifications for the currently authenticated user. Use this to populate notification badge counts in your UI.

> [!NOTE]
>
> This endpoint requires an authenticated user. Include a valid `Authorization: Bearer <accessToken>` header, or use a service key and name the user in `actingUserId`.

## Query Parameters

**actingUserId** `string`

Service key only, and required with one: the user this request acts as. Their unread notifications are counted. A user token always acts as its own user and must not send it (`400 app-notification/acting-user-not-allowed`).

## Response

Returns HTTP `200`:

**count** `number`

The number of unread app notifications.

```json theme={null}
{ "count": 7 }
```

## Error Responses

> [accordion] Missing token — 401
>
> No `Authorization` header was sent. The body is `text/plain`, not JSON:
>
> ```text theme={null}
> Unauthorized
> ```

> [accordion] Expired or invalid token — 403
>
> The header was sent but the token failed verification. Refresh the access
> token and retry. The body is `text/plain`, not JSON:
>
> ```text theme={null}
> Forbidden
> ```

> [accordion] Missing User — 400
>
> A service key sent no `actingUserId`.
>
> ```json theme={null}
> {
>   "error": "A service key must send actingUserId: the user this request acts as.",
>   "code": "app-notification/missing-user-id"
> }
> ```

> [accordion] Acting User Not Allowed — 400
>
> A user token sent `actingUserId`, even naming its own user. Only a service key names the user it acts as; a user token always acts as its own user.
>
> ```json theme={null}
> {
>   "error": "actingUserId is only accepted with a service key. A user's own token always acts as that user.",
>   "code": "app-notification/acting-user-not-allowed"
> }
> ```

> [accordion] User Not Found — 404
>
> Returned when a service key names an `actingUserId` that isn't a user in this project.
>
> ```json theme={null}
> { "error": "No user with this actingUserId exists in this project.", "code": "app-notification/user-not-found" }
> ```

> [accordion] Unsupported Parameter — 400
>
> The request sent `userId`. On this route the user a service key acts as is `actingUserId`.
>
> With a service key:
>
> ```json theme={null}
> {
>   "error": "`userId` was renamed to `actingUserId`: send the user this service key acts as in `actingUserId`.",
>   "code": "app-notification/unsupported-param",
>   "param": "userId"
> }
> ```
>
> With a user token, or with no credentials:
>
> ```json theme={null}
> {
>   "error": "`userId` isn't accepted here: a user's own token always acts as that user.",
>   "code": "app-notification/unsupported-param",
>   "param": "userId"
> }
> ```

## See Also

* [`useAppNotifications` hook](https://docs.sublay.io/v8/hooks/app-notifications/use-app-notifications) — exposes `unreadCount` directly
* [Fetch Notifications](https://docs.sublay.io/v8/api-reference/app-notifications/fetch-notifications.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.