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

# Buy Market windows

> Buys one or more windows of relisted capacity at the asking price. There is no offer and no seller approval: every leg is bought together or none are. Each leg becomes its own reservation, returned as reservationId.

Read the listing first. Choose a reserved term whose duration bounds allow your window (a shorter window is allowed when it ends exactly at the listing's end) and send its listingTermId and pricePerGpuHourMicroUsd as askPricePerGpuHourMicroUsd. Use whole-second times; windows can start up to five minutes in the past.

Payment is up front. A reservation under $10,000 is charged at once from Ornn credits, then your saved card; if that charge fails, the purchase is cancelled and the window returns to the Market. A reservation of $10,000 or more is invoiced by wire and is held until paid. Poll GET /commerce/reservations/{reservationId}: status moves from awaiting_payment to confirmed, then active when the window starts. The reservation can take a moment to appear.

Requires Idempotency-Key. Available to every member of your organization; approval is not required. You cannot buy your own organization's listings.

Send a new `Idempotency-Key` for each purchase. If the response is lost, retry with the same key and body to get the original result instead of buying twice.

`ornn schedules buy` does not send a term or node count, so it works only on listings without `terms` and always buys every node. Use this endpoint for listings with terms. See [Buy relisted capacity](/guides/secondary-market#use-the-api).


## OpenAPI

````yaml openapi.yaml POST /v1/markets/schedules/purchases
openapi: 3.1.0
info:
  title: Ornn compute API
  version: 1.0.0
  description: >-
    Customer HTTP API for Ornn GPU capacity. It covers reserved capacity and
    nodes, VM and Bare Metal access, Kubernetes and Slurm clusters, SSH keys,
    storage volumes and GitHub repositories, private networks, monitoring,
    buying and selling capacity (Reserve, Market, Spot, and Relist), and
    billing. API keys are scoped to one organization and act with their
    creator's access there; account, team, and API-key management stay in the
    console. Most operations require an approved organization. See
    https://docs.ornn.com/api-keys to create a key and
    https://docs.ornn.com/guides/kubernetes-api for an end-to-end Kubernetes
    integration. Examples use fictional IDs and credentials. The info.version
    field identifies the contract revision, not a shared API path version.
  contact:
    email: support@ornn.com
servers:
  - url: https://api.ornn.com
    description: Production
security:
  - OrnnApiKey: []
tags:
  - name: Authentication
  - name: Reservations
  - name: GPU 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: 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
      take organization key IDs 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, paid up
      front. Open to every member of your organization.
  - name: Spot
    description: >-
      Hourly order books for VMs with 1, 2, 4, or 8 GPUs on one node: read
      books, trades, and quotes, place and cancel bids, and follow 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 creator in the key's organization.
  - 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-access#provision-and-manage-through-rest
paths:
  /v1/markets/schedules/purchases:
    post:
      tags:
        - Market
      summary: Buy Market windows
      description: >-
        Buys one or more windows of relisted capacity at the asking price. There
        is no offer and no seller approval: every leg is bought together or none
        are. Each leg becomes its own reservation, returned as reservationId.


        Read the listing first. Choose a reserved term whose duration bounds
        allow your window (a shorter window is allowed when it ends exactly at
        the listing's end) and send its listingTermId and
        pricePerGpuHourMicroUsd as askPricePerGpuHourMicroUsd. Use whole-second
        times; windows can start up to five minutes in the past.


        Payment is up front. A reservation under $10,000 is charged at once from
        Ornn credits, then your saved card; if that charge fails, the purchase
        is cancelled and the window returns to the Market. A reservation of
        $10,000 or more is invoiced by wire and is held until paid. Poll GET
        /commerce/reservations/{reservationId}: status moves from
        awaiting_payment to confirmed, then active when the window starts. The
        reservation can take a moment to appear.


        Requires Idempotency-Key. Available to every member of your
        organization; approval is not required. You cannot buy your own
        organization's listings.
      operationId: capacityBuyWindows
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          description: >-
            Required. A unique key of 1 to 200 characters for this operation,
            such as a UUID. Retrying with the same key and the same body returns
            the original result with HTTP 200 instead of creating a second one.
            The key is remembered for 24 hours per organization; reusing it for
            a different request returns 409 idempotency_conflict. A missing key
            returns 400 idempotency_key_required.
          schema:
            type: string
            minLength: 1
            maxLength: 200
          example: 3f1c2a9e-6b1d-4c55-9a77-0d2b8f1e4c10
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CapacityPurchaseRequest'
            example:
              legs:
                - listingId: eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee
                  listingTermId: 88888888-8888-4888-8888-888888888888
                  nodeCount: 1
                  startsAt: '2026-10-24T00:00:00Z'
                  endsAt: '2026-10-27T00:00:00Z'
                  askPricePerGpuHourMicroUsd: 4200000
      responses:
        '200':
          description: >-
            A retry with the same Idempotency-Key and body; returns the original
            purchases.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CapacityPurchaseList'
              example:
                purchases:
                  - reservationId: dddddddd-dddd-4ddd-8ddd-dddddddddddd
                    listingId: eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee
                    nodeCount: 1
                    startsAt: '2026-10-24T00:00:00.000Z'
                    endsAt: '2026-10-27T00:00:00.000Z'
                    askPricePerGpuHourMicroUsd: 4200000
        '201':
          description: Windows bought. Each purchase is a reservation awaiting payment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CapacityPurchaseList'
              example:
                purchases:
                  - reservationId: dddddddd-dddd-4ddd-8ddd-dddddddddddd
                    listingId: eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee
                    nodeCount: 1
                    startsAt: '2026-10-24T00:00:00.000Z'
                    endsAt: '2026-10-27T00:00:00.000Z'
                    askPricePerGpuHourMicroUsd: 4200000
        '400':
          description: >-
            Missing Idempotency-Key, no legs, more than 50 legs, or an invalid
            body.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: idempotency_key_required
                  message: Send an Idempotency-Key header with this request.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: The listing belongs to your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: cannot_buy_own_listing
                  message: You cannot buy your own listing.
        '404':
          description: The listing is not tradable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: schedule_not_found
                  message: Ornn could not find that listing.
        '409':
          description: >-
            The price changed, part of the window sold, the listing closed, or
            the key was reused. Nothing was bought; read the listing again
            before retrying with a new key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: ask_changed
                  message: >-
                    The asking price changed. Review the new price and try
                    again.
        '422':
          description: >-
            The window, term, duration, or node count is not valid for the
            listing. Codes include invalid_listing_term, invalid_duration,
            invalid_window, purchase_too_short, purchase_in_past,
            purchase_outside_listing, invalid_node_count, purchase_legs_overlap,
            and primary_sells_by_offer.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                detail:
                  code: invalid_listing_term
                  message: Choose an available listing term.
        default:
          $ref: '#/components/responses/Error'
components:
  schemas:
    CapacityPurchaseRequest:
      type: object
      required:
        - legs
      additionalProperties: false
      properties:
        legs:
          type: array
          minItems: 1
          maxItems: 50
          description: >-
            Windows to buy together. All legs succeed or none do; legs may not
            overlap.
          items:
            $ref: '#/components/schemas/CapacityPurchaseLeg'
    CapacityPurchaseList:
      type: object
      required:
        - purchases
      properties:
        purchases:
          type: array
          items:
            $ref: '#/components/schemas/CapacityPurchase'
    Error:
      type: object
      properties:
        code:
          type: string
        detail:
          oneOf:
            - type: string
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                message:
                  type: string
    CapacityPurchaseLeg:
      type: object
      required:
        - listingId
        - startsAt
        - endsAt
        - askPricePerGpuHourMicroUsd
      additionalProperties: false
      properties:
        listingId:
          type: string
          format: uuid
          description: A Market (secondary) listing.
        listingTermId:
          type: string
          format: uuid
          description: >-
            Required when the listing has terms: a reserved term whose duration
            bounds allow this window.
        nodeCount:
          type: integer
          minimum: 1
          description: Nodes to buy. Omitted buys every node on the listing.
        startsAt:
          type: string
          format: date-time
          description: Whole-second RFC 3339 start inside the listing, now or later.
        endsAt:
          type: string
          format: date-time
          description: >-
            Whole-second RFC 3339 end inside the listing, at least one hour
            after the start.
        askPricePerGpuHourMicroUsd:
          type: integer
          format: int64
          description: >-
            The price you were shown: the selected term's
            pricePerGpuHourMicroUsd from the schedule, or
            askPricePerGpuHourMicroUsd when the listing has no terms. A changed
            price refuses the purchase with ask_changed.
    CapacityPurchase:
      type: object
      required:
        - reservationId
        - listingId
        - startsAt
        - endsAt
      properties:
        reservationId:
          type: string
          format: uuid
          description: The reservation this leg creates.
        listingId:
          type: string
          format: uuid
        nodeCount:
          type:
            - integer
            - 'null'
        startsAt:
          type:
            - string
            - 'null'
          format: date-time
        endsAt:
          type:
            - string
            - 'null'
          format: date-time
        askPricePerGpuHourMicroUsd:
          type:
            - integer
            - 'null'
          format: int64
          description: What you pay per GPU-hour, fees included.
  responses:
    Unauthorized:
      description: >-
        The credential is missing, invalid, revoked, or no longer belongs to a
        current organization member. Check the HTTP status before parsing the
        body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: >-
        Unsuccessful request. Check HTTP status first. Errors may have
        detail.code/detail.message, a string detail and optional top-level code,
        or an empty/non-JSON body. 401: invalid credential; 403: access or
        approval required; 404: not visible or credentials not ready; 409:
        lifecycle conflict; 429: back off; 5xx: service failure. Inspect current
        state before retrying mutations.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OrnnApiKey:
      type: http
      scheme: bearer
      bearerFormat: ornn_sk_...
      description: >-
        Create an organization API key in Account Settings > Developer. Do not
        send this key to the Kubernetes API server.

````

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