# LabelMessagesUpdateResult

The LabelMessagesUpdateResult type of the TypeScript SDK, which labels.updateMessages and labels.updateMessagesById take or answer.

```ts
type LabelMessagesUpdateResult = {
  archived: number
  examined: number
  expunged: number
  failed: number
  nextAfter: number | null
  remaining: number
  uidMax: number
  uidValidity: number
  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` | Memberships this call looked at, filtered-out ones included |
| `expunged` | `number` | Messages whose last label this patch removed: they moved to the Recently-deleted tier, restorable until purge. Counted here rather than in `updated`. |
| `failed` | `number` | Per-message refusals — a keyword cap, or a row that left the label between this call's scan and its write. Not an error: the rest of the call applied. |
| `nextAfter` | `number` \| `null` | Continuation cursor: call again with `after` set to this, the same `uidMax`, and the same patch. `null` means the range is drained. Repeating a call is harmless — a patch that changes nothing writes nothing, and a filing patch's earlier pages have already left the range. |
| `remaining` | `number` | Memberships left in the range this call did not reach, 0 when it finished. This counts what is UNEXAMINED, not what would match a flag filter — it is the figure a progress bar needs, and it is exact. |
| `uidMax` | `number` | The resolved ceiling this call worked under. Send it back UNCHANGED on a continuation: it is what keeps the selection the one the user saw, and re-resolving it would let mail that arrived since drift into the gesture. |
| `uidValidity` | `number` | UIDVALIDITY epoch of the label the patch ran against |
| `unchanged` | `number` | Messages in the selection the patch provably would not have changed, so they were skipped |
| `updated` | `number` | Messages the patch changed |

## Used by

| Method | What it does |
| --- | --- |
| [`labels.updateMessages`](/docs/sdks/typescript/labels/update-messages) | Update flags, labels and keywords for every message in a folder |
| [`labels.updateMessagesById`](/docs/sdks/typescript/labels/update-messages-by-id) | Update flags, labels and keywords for every message in a folder, by label id |
