# Session export

| From | Do |
| --- | --- |
| CLI | `openprogram sessions export <session-id>` (`--format md\|html`, default `md`) (`--output PATH`, default `./<session-id>.<format>`) |
| Web UI | Right-click a conversation in the sidebar, or its `⋯` button, then **Export** and a format |
| HTTP | `GET /api/sessions/{session_id}/export?format=md\|html`, owner-authenticated, answers with `Content-Disposition: attachment` |

Session ids: `openprogram sessions list` or the Web sidebar.

## What lands in the file

| Part | Rule |
| --- | --- |
| Scope | The active branch only, walked back from its head as in the Web transcript |
| Each turn | Role, local timestamp, text, not truncated |
| Tool calls, under their turn | Name, ok or failed, arguments, result |
| Arguments | Cut at 1,000 characters, marked `… [+N chars truncated]` |
| Tool results | Cut at 4,000 characters, marked the same way |
| HTML | One file: inline styles, no scripts or external requests, follows light or dark through `prefers-color-scheme` |

## Redaction

Title, session id, role label, tool name, turn text, arguments and results all pass through `remove_secret_values` (`openprogram/models/providers/recording/recording.py`), before clipping. The stored conversation is not changed.

| Matches | Becomes |
| --- | --- |
| Secret-named fields: `api_key`, `authorization`, `token`, `password`, … | `[secret removed]` |
| In free text: bearer tokens, `sk-` keys, credentials in URL query or userinfo | `[secret removed]` |
| Arguments nested too deeply to redact safely | `[arguments omitted: nesting too deep]` |

This covers known credential shapes only. Read an export before sending it somewhere public.

[CLI commands](https://fzkuji.github.io/OpenProgram/docs/reference/cli.html) · [API](https://fzkuji.github.io/OpenProgram/docs/reference/API.html)
