# Uploads

> Store a large table once, by content hash, and refer to it from any tabular call.

| Method and path | What it does |
|---|---|
| `POST /v1/uploads` | asks for an upload slot for a file, by its SHA-256 |
| `PUT /v1/uploads/{id}` | sends the file, when no signed URL is given |
| `GET /v1/uploads/{id}` | reads an upload's record |
| `DELETE /v1/uploads/{id}` | deletes a stored table |

Tables too large to send inline (the Python library uploads any table over 8 MB as parquet; for your own client, anything over
about 4 MB) are stored once and referred to by id.
The same file is never sent twice: its id comes from its SHA-256, and asking for a slot for a stored file answers `exists: true`.

## Ask for a slot

`POST /v1/uploads`

It takes:

<!-- generated by scripts/build_api_tables.py from the OpenAPI spec; do not edit -->

| Field | Type | Required / default | Description |
|---|---|---|---|
| `sha256` | string | **required** | The file's SHA-256, lowercase hex; the table's id is derived from it. |
| `size_bytes` | integer | **required** | The file's size, at most 1 GB. |
| `format` | `"parquet"` | `"parquet"` |  |

It returns:

<!-- generated by scripts/build_api_tables.py from the OpenAPI spec; do not edit -->

| Field | Type | Description |
|---|---|---|
| `id` | string | tbl_..., for &#123;format: table, id&#125; in any tabular call. |
| `exists` | boolean | true: already stored, nothing to send. |
| `upload` | object | Where to PUT the file: a signed storage URL (auth false), or a path on this API to send with your key (auth true). |

PUT the file to `upload.url`: a signed storage URL needs no key; a path on this API (`auth: true`) is sent with your key.

## Use it

Any tabular field that takes a table (`train`, `test`, `data`) takes `{"format": "table", "id": "tbl_..."}`, optionally with
`rows` (row positions to use) and `drop` (columns to leave out). One upload can then serve every fold of a cross-validation:
each call names its rows, and the test rows drop the target.

A table is checked the first time a call uses it: its bytes must match the hash it was uploaded under and be a parquet file;
one that fails is deleted and the call gets a clear error.

## Limits and housekeeping

| | |
|---|---|
| One file | 1 GB; at most 1,000,000 rows, 100,000,000 cells and 4 GB once decompressed |
| Per key | 10 GB and 200 tables in total; over either, `413 storage_full`: delete tables first |
| `GET /v1/uploads/{id}` | the table's size and upload time |
| `DELETE /v1/uploads/{id}` | deletes it; a fit made from it can no longer be rebuilt |

Uploaded tables are private to the key that uploaded them: nothing can download them except the model, for that key's calls.
