---
title: "Notifications & Audit in the SDK"
canonical: https://trickest.com/docs/developer-tools/sdk/notifications-audit
description: "Read notifications, update preferences, and query audit records with @trickest/sdk."
---

# Notifications & Audit in the SDK

Examples use an authenticated `client: TrickestClient` and a string `vaultId`. List methods below return async generators that fetch subsequent pages as you iterate.

## `client.notifications`

| Method                           | Description                    |
| -------------------------------- | ------------------------------ |
| `list(options?)`                 | `AsyncGenerator<Notification>` |
| `markRead(id, options?)`         | Mark one read                  |
| `markReadBulk(ids, options?)`    | Bulk read                      |
| `markAllRead(options?)`          | Mark all read                  |
| `delete(id, options?)`           | Delete one                     |
| `deleteBulk(ids, options?)`      | Bulk delete                    |
| `deleteAll(options?)`            | Clear all                      |
| `getConfig(options?)`            | Notification preferences       |
| `updateConfig(config, options?)` | Update preferences             |

```ts
for await (const n of client.notifications.list()) {
  if (n.read === "no") console.log(n.id, n.created);
}
```

`markAllRead()` changes all notifications in the current scope. To acknowledge only the items your application displayed, pass their IDs to `markReadBulk(ids)`. For preference updates, pass `{ config: ... }` using the shape returned by `getConfig()`; do not send identity fields.

**Types:** `Notification`, `NotificationConfig`

## `client.audit`

| Method                              | Description                |
| ----------------------------------- | -------------------------- |
| `list(vaultId, filters?, options?)` | `AsyncGenerator<AuditLog>` |
| `get(id, options?)`                 | Full entry                 |

<Warning>
  The SDK accepts `AuditFilter` fields `user_id`,
  `action`, `resource_type`, `from_date`, and `to_date`. The current list route
  does not apply those fields. It supports `actor`, `event`, `search`, and
  `ordering`, and resolves the vault from the token rather than the supplied
  `vaultId`.
</Warning>

Use an explicit HTTP query for supported filters. Supply `actorEmail` as a string identifying the actor to find. This example reads one page:

```ts
import type { AuditLog, PaginatedResponse } from "@trickest/sdk";

const params = new URLSearchParams({
  actor: actorEmail,
  event: "space-list",
  ordering: "-timestamp",
  page: "1",
  page_size: "50",
});
const page = await client.http.get<PaginatedResponse<AuditLog>>(
  `/api/audit-logs?${params}`,
);
for (const entry of page.results) {
  console.log(entry.timestamp, entry.actor, entry.event);
}
```

The HTTP generic describes the response; it does not validate it at runtime.
Follow pagination to retrieve more pages. The current route does not support
server-side date-range or resource filters.

<Info>
  **CLI:** [Notifications &
  Audit](/docs/developer-tools/cli/notifications-audit).
</Info>

## Related

<CardGroup cols={2}>
  <Card title="Users" icon="users" href="/docs/developer-tools/sdk/users">
    Inspect the user identities recorded in audit events.
  </Card>
  <Card
    title="Runs"
    icon="play"
    href="/docs/developer-tools/sdk/runs-schedules"
  >
    Run events often generate notifications.
  </Card>
</CardGroup>

---
_Markdown source of https://trickest.com/docs/developer-tools/sdk/notifications-audit._
