# tmux_server:snapshot/2

- **Package:** libtmux_erlang
- **Language:** Erlang
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-erlang/blob/d1b6308440cf9eb8f6647e7ae434bce60e849368/apps/libtmux_erlang/src/tmux_server.erl#L325
- **Page:** https://libtmux.org/en/erlang/latest/reference/tmux_server-snapshot-2/

```
snapshot(Server, Options)
-spec snapshot(t(), capture_options()) ->
                  {ok, tmux_snapshot:t()} | {error, map()}.
```

Capture the server's sessions, physical windows, window links and panes.

This performs explicit I/O and records each command's observation interval.
Identity scans bracket field reads; detected topology or value disagreements
return inconsistent_capture. Changes between reads can remain undetected,
including changes followed by a reversal. Atomic capture is unsupported.

Options are consistency (observed only), deadline_ms (default 2500, maximum
600000), max_rows (4096, maximum 65536 raw observations per scan and aggregate
spine) and max_bytes (8 MiB, maximum 64 MiB total stdout across capture
commands). Repeated memberships count before deduplication. The
`t:hydration/0` strategy defaults to batched. Each command is limited to 1 MiB;
isolated hydration distributes larger entity output across individual fields.
These are data limits, not a VM heap limit. Capturing performs no retry. Local
reads of the resulting value do no I/O. `tmux_snapshot:metadata/1` records the
strategy and actual source calls.

Unsupported consistency is rejected before contacting a server:

## Examples

```erlang
1> tmux_server:snapshot(invalid_server, #{consistency => atomic}).
{error,#{code => unsupported_consistency}}
```

## Parameters

- `Server` (`t()`)
- `Options` (`capture_options()`)

## tmux command

The tmux commands behind `snapshot/2`.

- [`list-panes`](/en/tmux/latest/manual/list-panes/) `-a` server scope, [`cmd_list_panes_server`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_server/) (the server has a session) (source: `apps/libtmux_erlang/src/tmux_observe.erl:129`)
- [`list-sessions`](/en/tmux/latest/manual/list-sessions/)
- [`list-windows`](/en/tmux/latest/manual/list-windows/) `-a` server scope, [`cmd_list_windows_exec`](/en/tmux/latest/reference/c-function-cmd-list-windows-c-cmd_list_windows_exec/) (the server has a session) (source: `apps/libtmux_erlang/src/tmux_observe.erl:129`)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_list_panes_entry`](/en/tmux/latest/reference/c-variable-cmd_list_panes_entry/) (attribute)
- [`cmd_list_panes_server`](/en/tmux/latest/reference/c-function-cmd-list-panes-c-cmd_list_panes_server/) (function)
- [`cmd_list_sessions_entry`](/en/tmux/latest/reference/c-variable-cmd_list_sessions_entry/) (attribute)
- [`cmd_list_sessions_exec`](/en/tmux/latest/reference/c-function-cmd-list-sessions-c-cmd_list_sessions_exec/) (function)
- [`cmd_list_windows_entry`](/en/tmux/latest/reference/c-variable-cmd_list_windows_entry/) (attribute)
- [`cmd_list_windows_exec`](/en/tmux/latest/reference/c-function-cmd-list-windows-c-cmd_list_windows_exec/) (function)
