> ## Documentation Index
> Fetch the complete documentation index at: https://weights.fyi/run/llms.txt

# PUT /v1/datasets/{dataset_id}/content

```text
PUT https://weights.fyi/run/v1/datasets/<dataset_id>/content
Authorization: Bearer <token>                    scope: submit
Content-Type: application/x-ndjson

<the file: one labelled page per line>
```

**Available since:** 2026-10-08, with fine-tuning. Implemented 2026-10-09: credit needed, bounded uploads, clean retries. the whole dataset checked at upload.

**Answer time:** synchronous: the answer comes when the last byte of the file has been read, checked and stored. The customer journey uploaded its dataset at 3.72 MiB/s on the live service on 2026-10-08, so the time is mostly the time your connection takes to carry the file.

Uploads the NDJSON file of a dataset made with [POST /v1/datasets](/run/docs/reference/datasets-create.md): one labelled page per line, the fields and rules on [Fine-tune a model](/run/docs/fine-tune.md#the-dataset). The file streams to storage in parts of 64 MiB, hashed on the way; each line is read in memory for its keys only and never logged. The upload checks each row and the whole dataset, including identifiers, split overlap, provenance, state digests and label support, and refuses blank lines. The local check below catches the same issues before uploading.

The upload is all or nothing: a refused line, a file past its limit or a line longer than one part discards what was stored and leaves the dataset `failed`; send the corrected file to the same address, and the service first removes what the failed attempt left. Since the merge of 2026-10-09 an upload needs available credit, your account runs 1 at a time and the service 2, and an upload is cut after 30 s without data or 900 s in all; the 161 MB dataset of the live drill took 41 s on 2026-10-08. Fine-tuning is switched on for this service.

## Request

| Name | Where | Required | Meaning |
|---|---|---|---|
| `Authorization` | header | yes | `Bearer` and a token with `submit`; counts against its request rate. |
| `Content-Type` | header | no | `application/x-ndjson` (also `application/ndjson`, `application/jsonl`, `application/x-jsonlines`, `application/octet-stream`, `text/plain`, or none); others `415`. |
| `Content-Length` | header | no | When given and over the limit, refused before a byte is read; a chunked upload is read until it passes the limit. |
| `dataset_id` | path | yes | A dataset in status `uploading` or `failed`. |
| the body | body | yes | The file, at most 440 MiB and, since the merge of 2026-10-09, at most what the dataset reserved. |

## Return value

**200 OK** when the whole file is stored; the dataset is `ready`.

| Field | Meaning |
|---|---|
| `dataset_id` | The dataset's identifier, as in the path. |
| `status` | `ready`: the file is accepted and a training job may use the dataset. |
| `rows` | How many accepted rows the file holds; blank lines are refused. |
| `train_rows` | How many rows have `split` `train`. |
| `validation_rows` | How many rows have `split` `validation`. |
| `other_rows` | How many rows have any other split; they are kept in the file and left out of training. This count appears only in this answer, not in the dataset's view. |
| `bytes` | The file's size in bytes, exactly as received. |
| `sha256` | The SHA-256 of the file exactly as received. Compare it with the digest of your own copy, for example with `shasum -a 256`, to know that what arrived is what you sent. |

## Errors

| Status | Code | When it happens | What to do |
|---|---|---|---|
| `400` | `invalid_json_line`, `invalid_line` | A line is not JSON, or not a JSON object; `line` gives its number. | Fix that line and upload again. |
| `400` | `missing_field` | A line lacks `id`, `split`, `label` or `state`; `field` names it and `line` gives the line. | Add the field. |
| `400` | `unknown_label` | A line's label is not one of the dataset's; `allowed` lists them. | Use one of the five labels. |
| `400` | `invalid_split` | A line's `split` is not a non-empty string. | Use `train` or `validation`. |
| `400` | `no_rows` | The file holds no row at all; `expected` describes a line. | Send the file with its rows. |
| `401` | `unauthorized`, `invalid_token`, `token_revoked`, `token_expired` | No token, or one that does not work (any more). | Use a valid token. |
| `403` | `scope_required`, `account_suspended` | The token lacks `submit`, or the account is suspended. | Use a token with `submit`. |
| `404` | `dataset_not_found` | There is no such dataset, it is another account's, or it was deleted. | Check the id; make a new dataset if it was deleted. |
| `404` | `not_configured` | Fine-tuning is not switched on for this service (`feature` is `training`). | See [Fine-tune a model](/run/docs/fine-tune.md). |
| `409` | `dataset_already_uploaded` | The dataset is already `ready`; a file cannot be replaced. | Make a new dataset for the new file. |
| `413` | `dataset_too_large` | The file is larger than `max_bytes`. | Split the pages over more than one dataset, or leave some out. |
| `413` | `line_too_large` | One line is longer than one upload part; `line` and `limit_bytes` say which and how much. | Shorten the page in that line. |
| `415` | `unsupported_media_type` | The `Content-Type` is not one of those above. | Send `application/x-ndjson`. |
| `429` | `rate_limited` | The token sends work faster than its request rate. | Wait the `Retry-After` seconds and send again. |
| `400` | `invalid_identifier`, `duplicate_example_id`, `group_split_overlap`, `invalid_provenance`, `invalid_example_weight`, `invalid_state`, `state_digest_mismatch`, `multiple_labels`, `field_targets_not_trainable`, `train_and_validation_required`, `missing_label_support` | The dataset check at upload; `line` says where, `train_rows` and `validation_rows` count the splits, `split` and `missing_labels` name the missing support. | Fix the rows named. |
| `402` | `no_credit` | Your available credit is zero or less (merged 2026-10-09). | Add credit. |
| `408` | `upload_timed_out` | No data arrived for 30 s (merged 2026-10-09). | Send the file again. |
| `409` | `dataset_busy` | Another upload or a delete of this dataset is running (merged 2026-10-09). | Wait for it to end. |
| `429` | `upload_concurrency_limit` | Your account's or the service's uploads are all in use (merged 2026-10-09). | Wait the `Retry-After` seconds. |
| `502` | `storage_unavailable` | Our storage refused a part; `storage_status` and `storage_code` give its own status and code, never more. | Send the file again; the dataset is `failed` and takes a new upload. |

## Examples

```sh
curl -s -T dataset.ndjson https://weights.fyi/run/v1/datasets/DATASET_ID/content \
  -H "Authorization: Bearer $WEIGHTS_API_KEY" -H "Content-Type: application/x-ndjson"
```

```json
{
  "dataset_id": "ds_12be8b8818ceaf13696e7ff9",
  "status": "ready",
  "rows": 50,
  "train_rows": 40,
  "validation_rows": 10,
  "other_rows": 0,
  "bytes": 8935,
  "sha256": "96c0db13101fe3bbdf7aa2fa278fe54799434ae60fc1ecbe52e66f9fb972f506"
}
```

## Patterns

### Checking a dataset before you upload

This script applies the training's own rules, in its order, and prints the first one a file breaks with the code a failed job would show:

```python
import hashlib, json, math, sys

LABELS = ["detail", "listing", "landing", "not_vacancy", "unresolved"]
ids, groups, support = set(), {}, {"train": set(), "validation": set()}
with open(sys.argv[1], encoding="utf-8") as file:
    for number, line in enumerate(file, 1):
        if not line.strip():
            sys.exit(f"line {number}: blank; the training reads every line as JSON")
        row = json.loads(line)
        key, split, group = str(row["id"]), row["split"], row.get("group_id")
        if key in ids:
            sys.exit(f"line {number}: duplicate_example_id")
        ids.add(key)
        if not group:
            sys.exit(f"line {number}: missing_group_id")
        if groups.setdefault(group, split) != split:
            sys.exit(f"line {number}: group_split_overlap")
        if split not in support:
            continue  # counted in other_rows, left out of training
        if row["label"] not in LABELS or type(row.get("provenance")) is not dict:
            sys.exit(f"line {number}: invalid_label_or_provenance")
        weight = float(row.get("weight", 1.0))
        if not math.isfinite(weight) or weight <= 0:
            sys.exit(f"line {number}: invalid_example_weight")
        state = row["state"]
        text = state if type(state) is str else json.dumps(state, ensure_ascii=False, separators=(",", ":"))
        if row.get("state_sha256") is not None and hashlib.sha256(text.encode()).hexdigest() != row["state_sha256"]:
            sys.exit(f"line {number}: state_digest_mismatch")
        support[split].add(row["label"])
if not support["train"] or not support["validation"]:
    sys.exit("train_and_validation_required")
for split, seen in support.items():
    if set(LABELS) - seen:
        sys.exit(f"missing_label_support:{split}")
print("ok:", len(ids), "rows")
```

## History

- 2026-10-08: live with fine-tuning: streamed uploads, the per-line check, the digest in the answer. The live drill's dataset uploaded at 3.72 MiB/s.
- 2026-10-09 (merged): credit needed; uploads limited and cut when idle or too long; 64 MiB parts, also the longest line; a retry cleans up first.
- 2026-10-10 implementation review: the whole contract checked at upload, blank lines refused.

## See also

[POST /v1/datasets](/run/docs/reference/datasets-create.md), [POST /v1/jobs (finetune)](/run/docs/reference/jobs-create-finetune.md), [Fine-tune a model](/run/docs/fine-tune.md).
