---
url: >-
  https://game-engine-io.github.io/enginex-frontend-sdk/reference/api/@getenginex/sdk/interfaces/NotificationsApi.md
---
[Reference](../../../index.md) / [@getenginex/sdk](../index.md) / NotificationsApi

# NotificationsApi

The player's notifications (history over REST) and channel preferences. All methods require
login. The real-time notice is another channel (realtime's `coreTopics.notification()`): show the toast with it and call
[NotificationsApi.list](#list) to refresh the list.

## Methods

### getPreferences()

> **getPreferences**(`params?`, `options?`): `Promise`<[`NotificationPreferences`](NotificationPreferences.md)>

The player's channel preferences.

#### Parameters

##### params?

[`NoParams`](../type-aliases/NoParams.md)

##### options?

[`CallOptions`](CallOptions.md)

#### Returns

`Promise`<[`NotificationPreferences`](NotificationPreferences.md)>

#### Example

```ts
const { email, push } = await enginex.notifications.getPreferences()
```

#### Throws

`UNAUTHENTICATED` without a session; `VALIDATION_ERROR` in `strict` with an
unexpected format.

***

### list()

> **list**(`input?`, `options?`): `Promise`<[`NotificationsPage`](../type-aliases/NotificationsPage.md)>

Lists the notifications, newest to oldest (gateway order), with the unread
counter. The gateway only reports the total: the SDK computes `totalPages` (`0` when there is nothing) and
returns `items: []` for a page beyond the end.

#### Parameters

##### input?

[`ListNotificationsInput`](ListNotificationsInput.md)

##### options?

[`CallOptions`](CallOptions.md)

#### Returns

`Promise`<[`NotificationsPage`](../type-aliases/NotificationsPage.md)>

#### Example

```ts
const { items, unreadCount, totalPages } = await enginex.notifications.list({ perPage: 20 })
```

#### Throws

`CONFIGURATION_ERROR` (without a request) for a `page` that is not an integer ≥ 1,
a `perPage` outside 1–100 or not an integer, or an `unreadOnly` that is not a boolean; `UNAUTHENTICATED`
without a session; `VALIDATION_ERROR` with `validation: 'strict'` if a notification type is
unknown or a date is not a date.

***

### markAsRead()

> **markAsRead**(`input`, `options?`): `Promise`<`void`>

Marks a notification as read.

#### Parameters

##### input

###### notificationId

`string`

##### options?

[`CallOptions`](CallOptions.md)

#### Returns

`Promise`<`void`>

#### Example

```ts
await enginex.notifications.markAsRead({ notificationId: notification.id })
```

#### Throws

`CONFIGURATION_ERROR` (without a request) for an empty `notificationId` or one that is not
text; `INVALID_ARGUMENT` (without a request) for `.`/`..`; `UNAUTHENTICATED` without a session; `NOT_FOUND`
if the notification does not exist, according to the service.

***

### updatePreferences()

> **updatePreferences**(`input`, `options?`): `Promise`<[`NotificationPreferences`](NotificationPreferences.md)>

Updates preferences. Only the fields present are sent; returns the complete preferences
as the gateway stored them.

#### Parameters

##### input

`Partial`<[`NotificationPreferences`](NotificationPreferences.md)>

##### options?

[`CallOptions`](CallOptions.md)

#### Returns

`Promise`<[`NotificationPreferences`](NotificationPreferences.md)>

#### Example

```ts
const prefs = await enginex.notifications.updatePreferences({ marketing: false })
```

#### Throws

`CONFIGURATION_ERROR` (without a request) if the input is not an object, carries
no field or a field is not a boolean; `UNAUTHENTICATED` without a session.
