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

# Start a disk upload

> Returns a transfer target for a qcow2 disk of up to 64 GiB. Send `display_name` for a new upload
and save the returned disk ID. Send that ID as `disk_id` to resume or replace an upload. Disks
built from base images can't be replaced this way.

For `signed_put`, send raw bytes to `upload_url` using the returned method and headers. Keep
your Ornn key out of that request. For `local_proxy`, use the authenticated disk-bytes endpoint.
Complete the upload after the transfer. Use a read-write key from an approved organization.

Upload a qcow2 file, then complete it before selecting its disk ID for a VM.
The file must include the dependencies described in the [VM disk guide](https://docs.ornn.com/guides/vm-access.md#disks).

```python theme={null}
import os
from pathlib import Path

import requests

api = "https://api.ornn.com"
client = requests.Session()
client.headers["Authorization"] = f"Bearer {os.environ['ORNN_API_KEY']}"

started = client.post(
    f"{api}/v1/orchestrator/disks/uploads",
    json={"display_name": "Training disk"},
    timeout=30,
)
started.raise_for_status()
target = started.json()
disk_id = target["id"]
print(f"Disk ID for retries or deletion: {disk_id}", flush=True)

if target["upload_mode"] != "signed_put":
    raise RuntimeError(f"Use the Upload disk bytes endpoint for disk {disk_id}")

with Path("training.qcow2").open("rb") as disk_file:
    # Use a separate request: never send the Ornn API key to the signed URL.
    transfer = requests.request(
        target["upload_method"],
        target["upload_url"],
        headers=target["upload_headers"],
        data=disk_file,
        timeout=900,
    )
    transfer.raise_for_status()

completed = client.post(
    f"{api}/v1/orchestrator/disks/uploads/{disk_id}/complete",
    json={},
    timeout=900,
)
completed.raise_for_status()
disk = completed.json()
if not disk["sha256"]:
    raise RuntimeError("The uploaded disk is not ready")
print(disk["id"], disk["sha256"])
```

For a `local_proxy` target, use [Upload disk bytes](https://docs.ornn.com/api-reference/disks/upload-bytes.md)
with the returned disk ID, then [complete the upload](https://docs.ornn.com/api-reference/disks/upload-complete.md).
If a transfer expires or fails, request a new target with `{"disk_id": "<saved-disk-id>"}`.
Use [Delete a disk](https://docs.ornn.com/api-reference/disks/delete.md) to discard an unfinished upload.


## OpenAPI

````yaml openapi.yaml POST /v1/orchestrator/disks/uploads
openapi: 3.1.0
info:
  title: Ornn compute API
  version: 1.0.0
  description: >-
    The Ornn REST API manages compute capacity, machines, clusters, storage,
    networking, and billing.

    Each organization API key has read-only or read-write access in one
    organization. Approved

    organizations can browse Reserve and buy fixed windows.


    See the [API overview](https://docs.ornn.com/api-reference/overview) for
    your first request and [API

    keys](https://docs.ornn.com/api-keys) to create a key. Examples use
    fictional IDs and credentials.

    `info.version` identifies the contract revision.
  contact:
    email: support@ornn.com
servers:
  - url: https://api.ornn.com
    description: Production
security:
  - OrnnApiKey: []
tags:
  - name: Authentication
  - name: Reservations
  - name: Nodes
  - name: Clusters
  - name: Workers
  - name: Virtual machines
    description: >-
      Choose a VM disk, launch VM access on a reservation, and read each VM's
      status, launch progress, and SSH connection details.
  - name: Disks
    description: >-
      Discover VM boot disks, create one from a base image and software, upload
      or import qcow2 bytes, and delete unused disks.
  - name: Bare Metal
    description: >-
      Launch Bare Metal access on a reservation, read a host's readiness and SSH
      connection details, and reboot or hard reset it.
  - name: SSH keys
    description: >-
      Register public keys for your organization, choose which keys a VM or Bare
      Metal reservation uses, and queue key delivery to machines. Slurm clusters
      use the saved reservation selections, which can be set at launch.
      Kubernetes API access does not use SSH keys.
  - name: Reserve
    description: >-
      Browse reserved-capacity listings and their terms, and post, cancel, or
      accept offers. Reserve listings are visible to approved organizations.
  - name: Market
    description: >-
      Browse relisted capacity and buy windows at the asking price. Payment
      follows the separately arranged or upfront checkout flow described in Buy
      Market windows. Open to every member of your organization.
  - name: Order books
    description: >-
      Hourly order books for whole nodes, one VM per node: read books, trades,
      and quotes, place and cancel bids, and follow and end fills.
  - name: Relist
    description: >-
      Sell whole nodes from a reservation you hold at your asking price, and
      manage those listings.
  - name: Storage
    description: >-
      Managed volumes, their files, and GitHub repository pulls. Volumes belong
      to the API key's organization; every member can use every volume in it.
  - name: Networks
    description: >-
      Organization private networks and the WireGuard configs you use to reach
      private machines and clusters.
  - name: Monitoring
    description: >-
      Machine telemetry and console logs for capacity your organization holds.
      Reads are limited to your reservation window.
  - name: Billing
    description: >-
      Invoices, billing summary, usage cost, Ornn credits, and account
      statements. Saving a card and paying invoices stay in the console.
externalDocs:
  description: REST integration walkthrough
  url: https://docs.ornn.com/guides/kubernetes-api
paths:
  /v1/orchestrator/disks/uploads:
    post:
      tags:
        - Disks
      summary: Start a disk upload
      description: >-
        Returns a transfer target for a qcow2 disk of up to 64 GiB. Send
        `display_name` for a new upload

        and save the returned disk ID. Send that ID as `disk_id` to resume or
        replace an upload. Disks

        built from base images can't be replaced this way.


        For `signed_put`, send raw bytes to `upload_url` using the returned
        method and headers. Keep

        your Ornn key out of that request. For `local_proxy`, use the
        authenticated disk-bytes endpoint.

        Complete the upload after the transfer. Use a read-write key from an
        approved organization.
      operationId: startVmDiskUpload
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VmDiskUploadRequest'
            example:
              display_name: Training disk
      responses:
        '200':
          description: Start a disk upload.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VmDiskUploadTarget'
              example:
                id: 44444444-4444-4444-8444-444444444444
                upload_mode: signed_put
                upload_url: https://uploads.example.com/disk.qcow2?signature=example
                upload_method: PUT
                upload_headers:
                  Content-Type: application/x-qemu-disk
                expires_in_seconds: 3600
        '400':
          description: >-
            disk_display_name_required when starting a new upload without a
            name.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: >-
            disk_not_found: the requested disk is absent or not owned by your
            organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: 'disk_not_replaceable: this disk was created from a base image.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    VmDiskUploadRequest:
      type: object
      required: []
      properties:
        disk_id:
          type: string
          description: >-
            Reissue an upload for an existing uploaded or imported disk owned by
            your organization. Omit to create a new pending upload. Created
            disks cannot be replaced this way.
          format: uuid
        display_name:
          type: string
          description: >-
            Required and nonblank when disk_id is omitted. To rename an existing
            upload, send display_name when completing it.
    VmDiskUploadTarget:
      type: object
      required:
        - id
        - upload_mode
        - upload_url
        - upload_method
        - upload_headers
        - expires_in_seconds
      properties:
        id:
          type: string
          description: >-
            Keep this disk ID for completion or cleanup, even if the transfer
            fails.
          format: uuid
        upload_mode:
          type: string
          enum:
            - signed_put
            - local_proxy
        upload_url:
          type: string
          description: >-
            Use this URL verbatim. Signed URLs grant temporary upload access;
            keep them private.
          format: uri
        upload_method:
          type: string
          enum:
            - PUT
            - POST
        upload_headers:
          type: object
          additionalProperties:
            type: string
          description: Headers required for the upload transfer.
        expires_in_seconds:
          type: integer
          description: >-
            Signed URL lifetime in seconds. If it expires, request a new target
            for the same disk_id. The local_proxy mode does not enforce this
            expiry.
          example: 3600
    Error:
      type: object
      properties:
        code:
          type: string
        detail:
          oneOf:
            - type: string
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                message:
                  type: string
  responses:
    Unauthorized:
      description: >-
        The credential is missing, invalid, or revoked. Check the HTTP status
        before parsing the body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        The credential lacks access to this operation, or the Reserve operation
        requires approval. An API key does not bypass these checks.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: >-
        Check the HTTP status first. If the response is JSON, read its error
        code and message. See

        [Errors](/api-reference/overview#errors) for response formats and retry
        guidance.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OrnnApiKey:
      type: http
      scheme: bearer
      bearerFormat: ornn_sk_...
      description: Send an [organization API key](/api-keys) as a bearer token.

````

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