# selection.encodeWhereDocument

- **Module:** selection
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-ts/blob/46cccfef2a546de55ce8b308249b8c76339089a0/packages/libtmux/src/selection.ts#L610
- **Page:** https://libtmux.org/en/ts/latest/reference/selection-encodewheredocument/

```
function 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.

## Examples

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

## Parameters

- `document` (`WhereDocumentV1`)

## Raises

- [`QueryValidationError`](/en/ts/latest/reference/errors-queryvalidationerror/): when the document or its criteria are invalid.

## Guides

Pages that discuss `encodeWhereDocument`.

- [Filtering and queries](/en/ts/latest/concepts/queries/)
