# QueryMessagesUpdateResult

The QueryMessagesUpdateResult type of the TypeScript SDK, which search.updateMatches take or answer.

```ts
type QueryMessagesUpdateResult = {
  archived: number
  examined: number
  expunged: number
  failed: number
  idMax: string
  nextAfter: string | null
  unchanged: number
  updated: number
}
```

## Fields

| Field | Type | Description |
| --- | --- | --- |
| `archived` | `number` | Messages whose last label this patch removed that fell back to the Archive label instead of being expunged. Unlike `expunged`, this is a SUBSET of `updated`, not an alternative to it: an archived message was still updated, so `examined` equals `updated + unchanged + expunged + failed` and adding `archived` to `updated` double counts. Only present when the patch carried `orphans: "archive"`. |
| `examined` | `number` | Messages the query selected in this call |
| `expunged` | `number` | Messages whose last label this patch removed: moved to the Recently-deleted tier, restorable until purge. Counted here rather than in `updated`. |
| `failed` | `number` | Per-message refusals. Not an error: the rest of the call applied. |
| `idMax` | `string` | The ULID ceiling this call worked under. Send it back UNCHANGED on a continuation: it is what keeps the selection the one the search showed, and re-resolving it would let mail that arrived since drift into the gesture. |
| `nextAfter` | `string` \| `null` | Continuation cursor: call again with `after` set to this, the same `idMax`, the same filter and the same patch. `null` means the selection is drained. There is no `remaining` count — counting what is left of a filter is an aggregate over the whole filtered set on every call. Measure progress against the search's own `total`. |
| `unchanged` | `number` | Selected messages the patch provably would not have changed, so they were skipped |
| `updated` | `number` | Messages the patch changed |

## Used by

| Method | What it does |
| --- | --- |
| [`search.updateMatches`](/docs/sdks/typescript/search/update-matches) | Update flags, labels and keywords for every message a search selects |
