# selection.encodeWhereDocument

- **Module:** selection
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ts/blob/3fe1ca654b81b8cbf4a13b777a001a3298c87a6f/packages/libtmux/src/selection.ts#L528
- **Page:** https://libtmux.org/en/ts/latest/reference/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" } },
});
```
