# `mix threadline.export`
[🔗](https://github.com/szTheory/threadline/blob/v0.9.0/lib/mix/tasks/threadline.export.ex#L1)

Loads application config, starts the configured Ecto repo, and writes an export file
using `Threadline.Export` — **no** ad-hoc `Ecto.Query` in this task (parity with
`mix threadline.retention.purge`).

## Flags

- **`--output PATH` / `-o`** — required when not using `--dry-run` (destination file).
  Do not paste production secrets into shell history; prefer argv from env files or
  wrappers for `--actor-json` payloads.
- **`--format`** — `csv` or `json` (default **`json`** when writing a file).
- **`--json-format`** — `wrapped` (default) or `ndjson` (passed as `json_format:` to export).
- **`--max-rows`** — forwarded as `:max_rows` (default from `Threadline.Export`).
- **`--dry-run`** — counts matching rows via `Threadline.Export.count_matching/2`; does not write a file.
- **`--table`** — optional table name filter (string), same as `timeline/2` `:table`.
- **`--from` / `--to`** — optional inclusive `captured_at` bounds as ISO-8601 UTC strings.
- **`--actor-json PATH`** — optional UTF-8 file; contents decoded with `Jason.decode!/1` and passed through
  `Threadline.Semantics.ActorRef.from_map/1` as `:actor_ref` in filters.

## Examples

    mix threadline.export --dry-run --table users
    mix threadline.export --format csv --output /tmp/audit.csv --table users
    mix threadline.export --format json --json-format ndjson -o /tmp/lines.ndjson --max-rows 5000

Non-production: always review **`MIX_ENV`**, repo module, and printed counts before writing.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
