# Export

<!-- docs-test setup: owner -->

Everything UsherStats keeps for a site, on every plan; what each part holds is in
[Exporting your data](../data-export.md). An export needs the `export:read` scope.

| Route | Scope |
|---|---|
| `POST /v1/sites/{id}/export` | `export:read` |
| `GET /v1/downloads/{token}` | none: the link is the credential |

```sh
curl https://api.usherstats.com/v1/sites \
  -H "Authorization: Bearer $US_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Shop", "hostnames": ["shop.example"]}'
```
<!-- expect 201; SITE_ID=.site.id -->

## Export a site

The answer lists five files, each with a download link that works for an hour:

- `settings.json`: the site as configured, with its hostnames, goals, experiments and bot protection rules;
- `site-store.ndjson`: the daily totals, journeys, search weeks and settings UsherStats keeps per site, one JSON
  object per line, in the form a site can be loaded back from. Credentials (search keys, server secrets) are never
  exported: connect them again after a move;
- `rollups.ndjson`: the daily totals alone;
- `archive.json`: the site's raw records, one gzipped NDJSON object per site, kind and hour, each with its own link;
- `manifest.json`: what is where, with counts.

`from` and `to` (YYYY-MM-DD) limit the raw records listed; without them, all of them are.

```sh
curl https://api.usherstats.com/v1/sites/$SITE_ID/export \
  -H "Authorization: Bearer $US_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"from": "2026-09-01", "to": "2026-09-30"}'
```
<!-- expect 201; DOWNLOAD_URL=.export.files[0].url -->

## Download

A link needs no token: it names one file and cannot be changed into another. After an hour it answers `410`; export
again for new links.

```sh
curl "$DOWNLOAD_URL"
```
<!-- expect 200 -->

A link that was not made by an export is `404`:

```sh
curl https://api.usherstats.com/v1/downloads/not-a-link
```
<!-- expect 404 -->
