> ## 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.

# Upload Model

Upload an ONNX model file (`model.tar.gz`) to a revision.

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

### Request Format

The model bytes travel in the request body, so the JSON command cannot. This endpoint reads a **binary
request**: the file as the body, and the command as a header.

| Header           | Value                                                  |
| :--------------- | :----------------------------------------------------- |
| `Content-Type`   | `application/octet-stream`                             |
| `X-Request-Body` | The JSON command below, serialized onto a single line. |

`X-Request-Body` is named in the API's `Access-Control-Allow-Headers`, so a browser client can send it.

Posting the command as a plain JSON body instead — `Content-Type: application/json`, no `X-Request-Body` —
parses, but delivers no bytes. Nothing is stored and the call answers `500`.

### Request Body

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

| Parameter | Type    | Required | Description                              |
| :-------- | :------ | :------- | :--------------------------------------- |
| `engine`  | string  | Yes      | Must be `onnx`.                          |
| `command` | string  | Yes      | Must be `upload`.                        |
| `path`    | string  | Yes      | File name, must be `model.tar.gz`.       |
| `size`    | integer | Yes      | Size of the file in bytes. At least `1`. |

### Response

| Parameter      | Type   | Description                            |
| :------------- | :----- | :------------------------------------- |
| `operation_id` | string | ID of the background upload operation. |

The file bytes travel in this request, so no upload URL comes back — the model is already stored by the
time the command answers. Poll [Get Operation](/rest-api/operations/get-operation) with `operation_id`
to follow the post-processing that unpacks it.

### Example

<CodeGroup>
  ```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: {"engine":"onnx","command":"upload","path":"model.tar.gz","size":154829}' \
    --data-binary @model.tar.gz
  ```

  ```json Response theme={null}
  {
    "status": "success",
    "operation_id": "op_upload_123"
  }
  ```
</CodeGroup>
