# Retention

The Retention type of the TypeScript SDK, which mailboxes.getRetention and 2 more methods take or answer.

```ts
type Retention = {
  accountRetentionDays: number | null
  minDays: number
  nextRunAt: number | null
  oldestReceivedAt: number | null
  ownRetentionDays: number | null
  previews: RetentionPreview[]
  retentionDays: number | null
  source: ('own' | 'account' | 'none')
}
```

## Fields

| Field | Type | Description |
| --- | --- | --- |
| `accountRetentionDays` | `number` \| `null` | The owning account's default window (null = none) |
| `minDays` | `number` | The platform floor (RETENTION_MIN_DAYS): no window may be shorter |
| `nextRunAt` | `number` \| `null` | Epoch seconds at which the oldest live message becomes due under the window in force — the duty's next scheduled wake; null when no window is in force or nothing is live |
| `oldestReceivedAt` | `number` \| `null` | Arrival time (epoch seconds) of the oldest live message, or null on an empty mailbox |
| `ownRetentionDays` | `number` \| `null` | The mailbox's own window (null = none set; the account default applies if any) |
| `previews` | [`RetentionPreview[]`](/docs/sdks/typescript/types/retention-preview) | What each previewed window would expunge: the windows named by ?days=, else the window in force (one entry), else empty |
| `retentionDays` | `number` \| `null` | The window in force: the mailbox's own, else the account default, else null (off) |
| `source` | `('own' \| 'account' \| 'none')` | Where the window in force came from: the mailbox's own setting, the account default, or none |

## Used by

| Method | What it does |
| --- | --- |
| [`mailboxes.getRetention`](/docs/sdks/typescript/mailboxes/get-retention) | Get retention policy and preview |
| [`mailboxes.setRetention`](/docs/sdks/typescript/mailboxes/set-retention) | Set retention window |
| [`mailboxes.clearRetention`](/docs/sdks/typescript/mailboxes/clear-retention) | Clear retention window |
