# selection.encodeWhereDocument

- **Module:** selection
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/selection.ts#L522
- **Page:** https://libtmux.org/reference/ts/selection-encodewheredocument/

```
selection.encodeWhereDocument(document: : WhereDocumentV1) -> string
```

Serialize a WHERE document as canonical JSON.

Field names and values use tmux's stable wire spellings. The input is
validated without invoking accessors or conversion hooks.

## Raises

- `QueryValidationError` — when the document or its criteria are invalid.

## Example

```ts
import { encodeWhereDocument } from "libtmux";
const encoded = encodeWhereDocument({
  model: "pane",
  version: 1,
  where: { title: { contains: "log" } },
});
```
