# --history

Source: https://zshot-cli.com/reference/flags/common/history/
Markdown: https://zshot-cli.com/reference/flags/common/history/index.md
Section: [Reference](https://zshot-cli.com/reference/) › [Flags](https://zshot-cli.com/reference/flags/) › [Common](https://zshot-cli.com/reference/flags/common/)
CLI: `--history` · REST: CLI only
Value: `PATH` · Default: `history.sqlite in the user's state directory`

Records each CLI run, authenticated [server](/reference/flags/server/server) request, and MCP tool call as a row in a SQLite ledger. Pass a custom path with `=`, as `--history=PATH`. Without a path, ZShot writes to `$XDG_STATE_HOME/zshot/history.sqlite`, defaulting to `~/.local/state/zshot/history.sqlite` on Linux and `~/Library/Application Support/zshot/history.sqlite` on macOS.

| Column | Description |
| ------ | ----------- |
| `started_at` | Start timestamp in UTC |
| `zshot_version` | ZShot version |
| `source` | `cli`, `http`, or `mcp` |
| `command` | Sanitized CLI command with secrets replaced by `[FILTERED]` |
| `request` | Sanitized HTTP or MCP request JSON with secrets replaced by `[FILTERED]` |
| `url` | First requested URL |
| `elapsed_ms` | Duration in milliseconds |
| `exit_code` | Process exit code for CLI runs |
| `status` | HTTP response status code |
| `outcome` | Outcome label such as `successful`, `timeout`, or `cache_hit` |
| `input_tokens`, `output_tokens`, `cache_read_tokens`, `cache_write_tokens` | Total tokens across all model calls |
| `llm_usage` | Per-provider and per-model token breakdown as JSON, tagged with `source: "zshot"` for API counts or `source: "agent"` for counts appended by a `stdio` agent |
| `outputs` | Files a CLI run wrote, as a JSON array of `{role, path, type, url}`. `role` is `output` for a render, which carries its output type and page URL; any other role is the flag that asked for the file, such as `har`. Paths are absolute |

The annotated [schema](/schemas/history/latest.sql) ships with each release; schema updates only add nullable columns so existing queries remain compatible.

Each CLI invocation writes one row regardless of URL count, including runs rejected by argument or license validation. Servers record authenticated requests including cache hits, and configure history at startup only.

For [`stdio`](/reference/llm_connections/stdio) runs, ZShot cannot observe the driving agent's tokens and prints `History: row N in PATH` to stderr so the agent can append its own counts using the ZShot skill.

Multiple ZShot processes can share one ledger on a local filesystem. ZShot only appends rows; prune old entries with SQL. Write failures log an error without failing the run.

Enable history globally in the [configuration file](/reference/configuration/#history).

## Example

Record a run to `runs.sqlite`:

```sh
zshot --history=runs.sqlite -f page.png https://zshot-cli.com/
```

Summarize token usage by URL:

```sh
sqlite3 runs.sqlite \
  "SELECT url, count(*), sum(input_tokens), sum(output_tokens) FROM history GROUP BY url"
```

## Related

Flags:

- [`--config`](https://zshot-cli.com/reference/flags/common/config/)
- [`--llm-usage`](https://zshot-cli.com/reference/flags/diagnostics/llm-usage/)

Topics:

- [Configuration](https://zshot-cli.com/reference/configuration/)

## Navigation

- [Examples](https://zshot-cli.com/examples/)
- [Download](https://zshot-cli.com/download/)
- [Purchase](https://zshot-cli.com/purchase/)
- [Reference](https://zshot-cli.com/reference/)
  - [Formats](https://zshot-cli.com/reference/formats/)
  - [Flags](https://zshot-cli.com/reference/flags/)
    - [Common](https://zshot-cli.com/reference/flags/common/)
      - [--completions](https://zshot-cli.com/reference/flags/common/completions/)
      - [--config](https://zshot-cli.com/reference/flags/common/config/)
      - [--diagnostics](https://zshot-cli.com/reference/flags/common/diagnostics/)
      - [--file-name](https://zshot-cli.com/reference/flags/common/file-name/)
      - [--formats](https://zshot-cli.com/reference/flags/common/formats/)
      - **--history**
      - [--input-mimetype](https://zshot-cli.com/reference/flags/common/input-mimetype/)
      - [--license-info](https://zshot-cli.com/reference/flags/common/license-info/)
      - [--license-key](https://zshot-cli.com/reference/flags/common/license-key/)
      - [--license-lease](https://zshot-cli.com/reference/flags/common/license-lease/)
      - [--license-lease-accept](https://zshot-cli.com/reference/flags/common/license-lease-accept/)
      - [--license-lease-close](https://zshot-cli.com/reference/flags/common/license-lease-close/)
      - [--license-lease-confirm](https://zshot-cli.com/reference/flags/common/license-lease-confirm/)
      - [--license-lease-export](https://zshot-cli.com/reference/flags/common/license-lease-export/)
      - [--log-chrome-to-stderr](https://zshot-cli.com/reference/flags/common/log-chrome-to-stderr/)
      - [--log-level](https://zshot-cli.com/reference/flags/common/log-level/)
      - [--no-fail](https://zshot-cli.com/reference/flags/common/no-fail/)
      - [--no-preview](https://zshot-cli.com/reference/flags/common/no-preview/)
      - [--no-timeout](https://zshot-cli.com/reference/flags/common/no-timeout/)
      - [--open-source-licenses](https://zshot-cli.com/reference/flags/common/open-source-licenses/)
      - [--output-type](https://zshot-cli.com/reference/flags/common/output-type/)
      - [--quiet](https://zshot-cli.com/reference/flags/common/quiet/)
      - [--refresh-license](https://zshot-cli.com/reference/flags/common/refresh-license/)
      - [--software-rendering](https://zshot-cli.com/reference/flags/common/software-rendering/)
      - [--timeout](https://zshot-cli.com/reference/flags/common/timeout/)
      - [--trial](https://zshot-cli.com/reference/flags/common/trial/)
      - [--wait-for](https://zshot-cli.com/reference/flags/common/wait-for/)
    - [Agents](https://zshot-cli.com/reference/flags/agents/)
    - [Archive](https://zshot-cli.com/reference/flags/archive/)
    - [Browser](https://zshot-cli.com/reference/flags/browser/)
    - [Diagnostics](https://zshot-cli.com/reference/flags/diagnostics/)
    - [Document](https://zshot-cli.com/reference/flags/document/)
    - [Image](https://zshot-cli.com/reference/flags/image/)
    - [Navigator](https://zshot-cli.com/reference/flags/navigator/)
    - [Security](https://zshot-cli.com/reference/flags/security/)
    - [Server](https://zshot-cli.com/reference/flags/server/)
    - [Video](https://zshot-cli.com/reference/flags/video/)
  - [Agents](https://zshot-cli.com/reference/agents/)
  - [Configuration](https://zshot-cli.com/reference/configuration/)
  - [Crawling](https://zshot-cli.com/reference/crawling/)
  - [Devices](https://zshot-cli.com/reference/devices/)
  - [Docker](https://zshot-cli.com/reference/docker/)
  - [Exit Codes](https://zshot-cli.com/reference/exit_codes/)
  - [Linux](https://zshot-cli.com/reference/linux/)
  - [LLM Connections](https://zshot-cli.com/reference/llm_connections/)
  - [npm](https://zshot-cli.com/reference/npm/)
  - [LLM Formatting](https://zshot-cli.com/reference/llm_formatting/)
  - [Local Inputs](https://zshot-cli.com/reference/inputs/)
  - [Navigator](https://zshot-cli.com/reference/navigator/)
  - [Security](https://zshot-cli.com/reference/security/)
  - [Server](https://zshot-cli.com/reference/server/)
  - [Shell completions](https://zshot-cli.com/reference/shell_completions/)
  - [Storage](https://zshot-cli.com/reference/storage/)
  - [Timeouts](https://zshot-cli.com/reference/timeouts/)
  - [Web Bot Auth](https://zshot-cli.com/reference/web_bot_auth/)
- [Support](https://zshot-cli.com/support/)
- [Changelog](https://zshot-cli.com/changelog/)

Site index: https://zshot-cli.com/llms.txt

