> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blobhub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Put File

Put one file into a draft revision of an app blob, replacing the file at that path if there is one.
`blobhub app push` calls it for each file that changed.

## **POST** `/revisions/:id/data/command` (Command: `put_file`)

> [!NOTE]
>
> This is a binary command: the file bytes are the `application/octet-stream` request body, and the JSON command below
> is serialized onto a single line into the `X-Request-Body` header instead of the body.

A file is at most 4 MiB (`blobhub.package.app.file_bytes`, fixed) and a revision holds at most 500 files
(`blobhub.package.app.files_per_revision`, fixed). An ONNX model above 4 MiB cannot ride in an app.

### Request Body

Serialized into `X-Request-Body`, not into the body itself:

| Parameter | Type | Required | Description |
| :- | :- | :- | :- |
| `command` | string | Yes | Must be `put_file`. |
| `path` | string | Yes | Where the file goes, relative to the app's root, such as `blobs/flows/blob.yaml`. Segments of `A`-`Z`, `a`-`z`, `0`-`9`, `.`, `_`, `-`, joined by `/`; neither `.` nor `..`; at most 256 characters. |

### Response

| Parameter | Type | Description |
| :- | :- | :- |
| `path` | string | The path the file was put at. |
| `size` | integer | The file's size in bytes. |
| `sha256` | string | The hex SHA-256 of the file's bytes. |

### Errors

| Status | Error | Cause |
| :- | :- | :- |
| 400 | `invalid_request_body` | The request carries no bytes, or `path` breaks the path rule. |
| 400 | `file_too_large` | The file is over 4 MiB. The body carries `limit`. |
| 400 | `too_many_files` | The path is new and the revision already holds 500 files. Replacing a file is never refused. |
| 403 | `forbidden` | The caller does not have WRITE on the app blob. |
| 409 | `revision_not_writable` | The revision is committed. A version never changes; put files in a draft. |

### Example

```bash Request theme={null}
curl -X POST https://api.blobhub.io/v1/revisions/rev_001/data/command \
  -H "X-API-Key: $BLOB_API_KEY" \
  -H "Content-Type: application/octet-stream" \
  -H 'X-Request-Body: {"command":"put_file","path":"blobs/flows/blob.yaml"}' \
  --data-binary @build/blobs/flows/blob.yaml
```

```json Response theme={null}
{
  "status": "success",
  "path": "blobs/flows/blob.yaml",
  "size": 34,
  "sha256": "9f2c1f7a0b6d4e83a51c27d9e04b8f66c3a1d5e7b290448f1c6a3d7e5b8209ac"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.