> For the complete documentation index, see [llms.txt](https://wiki.crosswatch.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.crosswatch.app/crosswatch/advanced-and-api/api-reference/storage-and-operations.md).

# Storage and operations

Files, logs, captures, backups, maintenance, and destructive API operations.

Use these endpoints to manage local CrossWatch storage and operations.

### Files and logs

| Method | Endpoint            | Purpose                                |
| ------ | ------------------- | -------------------------------------- |
| `GET`  | `/api/files`        | List a configured storage path.        |
| `GET`  | `/api/logs/dump`    | Return buffered log lines.             |
| `GET`  | `/api/logs/stream`  | Stream one log channel using SSE.      |
| `GET`  | `/api/logs/watcher` | Stream Watcher log channels using SSE. |

### Captures and backups

| Endpoint group     | Purpose                                                                                                  |
| ------------------ | -------------------------------------------------------------------------------------------------------- |
| `/api/snapshots/*` | Create, compare, restore, delete, and clear captures.                                                    |
| `/api/backups/*`   | Select contents, encrypt backups, manage additional copies, schedule, retain, validate and recover data. |

Validate a backup before restore. Do not restore while synchronization or capture work is active.

[Backup & Restore](https://wiki.crosswatch.app/crosswatch/main-dashboard/tools/backup-and-restore.md) explains content selection, passwords and recovery actions. Replacement restores are applied during restart after a safety copy. Recovering a tracker as a new instance keeps the existing trackers and creates no sync pairs.

### Maintenance

`/api/maintenance/*` manages local caches, state, tracker data, event storage, and process restarts.

These routes can clear local data or trigger a rebuild. They do not directly remove provider data. A later sync can still apply provider changes after rebuilding local state.

{% hint style="warning" %}
Run a dry run after clearing state or caches. Confirm destructive requests before sending them.
{% endhint %}

Examples of destructive endpoints include:

* `POST /api/maintenance/clear-state`
* `POST /api/maintenance/reset-all-default`
* `POST /api/maintenance/restart`
* `POST /api/maintenance/events-rebuild`
* `POST /api/snapshots/clear`
* `POST /api/backups/restore`

Use `POST /api/maintenance/jobs` to start a supported background task, and `GET /api/maintenance/jobs/current` to read its state and result. For example, send this body for a database health check:

```json
{"action":"database-health"}
```

Supported actions are `database-health`, `events-health`, `events-optimize`, `state-file-prune`, `state-file`, `events-rebuild`, `events-purge`, `state`, and `database-rebuild`. The last four destructive actions (`events-rebuild`, `events-purge`, `state`, and `database-rebuild`) require `"confirm": true`.

Poll while `state` is `queued` or `running`. Completion is reported as `completed`, `failed`, or `interrupted`; inspect `result` as well as the state. An idle system with no recorded job returns `state: idle`. Starting a job can return `ok: false` with `sync_running`, `maintenance_busy`, or `database_operation_busy`, even with HTTP `200`.

`GET /api/maintenance/action-status/{action}` returns the local data summary for a task; it is not the running-job status endpoint.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.crosswatch.app/crosswatch/advanced-and-api/api-reference/storage-and-operations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
