# API reference: files

Repo files: presigned multipart upload/download against object storage, and tree listing

## GET /v1/repos/{owner}/{repo}/tree

`getRepoTree` · scope `none` · List repo files

Flat file listing with sizes, etags and sha256 digests (paths are `/`-separated keys; there are no directory objects). Filter with `prefix`; paginate for large repos.

Parameters:

- `owner` (path, required): Repo owner handle (username or org slug).
- `repo` (path, required): Repo slug. A renamed repo's former slug also finds it, and the answer names its current address.
- `prefix` (query): Only paths starting with this prefix.
- `limit` (query): Page size (tree listings allow larger pages).
- `cursor` (query): Opaque cursor from the previous page's `next_cursor`.

Responses:

- `200`: Page of file entries.
- `404`: Resource not found (or hidden from the caller).

## POST /v1/repos/{owner}/{repo}/files/presign-upload

`presignUpload` · scope `key:write` · Presign a batch multipart upload

Requests presigned multipart upload URLs for up to 100 files. The client supplies each file's `path`, `size` and `sha256`. The `sha256` is the content address and also the dedupe precheck. The server returns, per file, an `upload_id` and part URLs. Each part is `part_size` bytes, and the last part may be short. Upload the parts with HTTP PUT, collect the returned ETags, then call `complete`. Limits (v0): single file ≤ 50 GiB, part size 100 MiB. A file comes back with no parts when the hub already holds those bytes and the caller can already read them. That means a file of a public repo, or of a repo the caller may read. Bytes held only by a private repo the caller cannot read are uploaded like any other. Uploads that are still in progress count toward the storage quota. A file Lucen certified keeps its bytes. New bytes at its path are `409`, so upload them under a new name. Only a certifier may upload to the repo that holds Lucen's certification list (`403`). That repo refuses a list older than the newest one the hub accepted (`409`). It also refuses a list the hub cannot read (`409`). A list upload is `503` when the hub cannot read the serial floor or the uploaded bytes. In a dataset repo, new bytes at a path that holds episodes are `409` unless `replace_episodes` is true. Those paths are `data/`, `videos/` and `meta/episodes/`, plus `meta/episodes.jsonl` and `meta/episodes_stats.jsonl`. The batch is checked whole, before anything is linked. A second recording pushed under the same name would otherwise replace the first one's episodes.

Parameters:

- `owner` (path, required): Repo owner handle (username or org slug).
- `repo` (path, required): Repo slug. A renamed repo's former slug also finds it, and the answer names its current address.

Request body: `application/json`, required.

Responses:

- `200`: Presigned upload targets, one per requested file.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `413`: A file exceeds the size limit or the account is over quota.
- `422`: Request failed validation.
- `503`: The hub cannot read Lucen's certification list right now, or the newest serial it accepted. Nothing was changed. Try again in a minute.

## POST /v1/repos/{owner}/{repo}/files/complete

`completeUpload` · scope `key:write` · Complete a batch multipart upload

Finalizes multipart uploads previously presigned. The server completes the uploads in object storage, verifies etags, and upserts the RepoFile rows. Existing paths are overwritten, because repos have no revisions in v0. A file Lucen certified is never overwritten (`409`). The repo that holds Lucen's certification list follows the rules of `presignUpload`. So do a dataset's episode files: new bytes there are `409` unless `replace_episodes` is true, checked for the whole batch first. Only the account that presigned an upload completes it (`409` otherwise). The storage quota is checked again here (`413`).

Parameters:

- `owner` (path, required): Repo owner handle (username or org slug).
- `repo` (path, required): Repo slug. A renamed repo's former slug also finds it, and the answer names its current address.

Request body: `application/json`, required.

Responses:

- `200`: Files recorded.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `413`: These files would put the account over its storage quota.
- `422`: Request failed validation.
- `503`: The hub cannot read Lucen's certification list right now, or the newest serial it accepted. Nothing was changed. Try again in a minute.

## POST /v1/repos/{owner}/{repo}/files/presign-download

`presignDownload` · scope `none` · Presign downloads

Returns short-lived (1 h) presigned GET URLs for up to 100 repo file paths. All-or-nothing: any unknown path fails the whole request with 404 (missing paths listed in the problem detail). Anonymous works for public repos. A request that names the repo's main file counts one download, once a day per viewer (`Repo.downloads_30d`). Counting is best effort and never fails or delays the answer.

Parameters:

- `owner` (path, required): Repo owner handle (username or org slug).
- `repo` (path, required): Repo slug. A renamed repo's former slug also finds it, and the answer names its current address.

Request body: `application/json`, required.

Responses:

- `200`: Presigned download URLs.
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## POST /v1/repos/{owner}/{repo}/files/delete

`deleteFiles` · scope `key:write` · Delete files (batch unlink)

Unlinks up to 100 file rows from the repo. Content-addressed blobs are garbage-collected asynchronously once unreferenced. Unknown paths are ignored and reported back. A file Lucen certified stays until Lucen revokes it (`409`). While the hub cannot read Lucen's certification list, nothing is deleted (`503`). Only a certifier may delete from the repo that holds the list (`403`).

Parameters:

- `owner` (path, required): Repo owner handle (username or org slug).
- `repo` (path, required): Repo slug. A renamed repo's former slug also finds it, and the answer names its current address.

Request body: `application/json`, required.

Responses:

- `200`: Deletion summary.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.
- `503`: The hub cannot read Lucen's certification list right now, or the newest serial it accepted. Nothing was changed. Try again in a minute.
