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

# Estimate an order

> > ⚠️ This endpoint is in [public preview](/preview/roadmap#feature-states).

Estimate a buy or sell order before placing it.



## OpenAPI

````yaml /openapi.json post /preview/v2/order_preview
openapi: 3.1.0
info:
  title: sfc-api
  description: >-
    SF Compute API. Routes under /v2 are stable; routes under /preview/v2 are
    public preview - subject to change.
  version: 0.1.0
servers:
  - url: https://api.sfcompute.com
security:
  - bearer_auth: []
tags:
  - name: Limits
    description: Account limits and current usage.
  - name: Account
    description: The authenticated account and logged-in user.
  - name: Pools
    description: A bucket of owned compute balance over time.
  - name: Orders
    description: >-
      Place orders targeting a capacity to increase your reserved compute
      balance during some time period.
  - name: Instance Templates
    description: Reusable instance configuration.
  - name: Images
    description: Custom machine images for instances.
  - name: Roles
    description: TOML-based permission role definitions.
  - name: Grants
    description: Bind principals (users or tokens) to roles on a workspace.
  - name: Tokens
    description: Workspace-scoped API tokens.
  - name: Instances
    description: Spin up instances in a capacity to use your available compute.
  - name: Instance SKU Catalog
    description: Browse available instance SKU property definitions.
  - name: VPCs
    description: Isolated networks with routed subnets within one availability zone.
  - name: Subnets
    description: Private networks for instance-to-instance communication within a zone.
  - name: Procurements
    description: Market automations that maintain capacity by placing buy/sell orders.
  - name: Users
    description: Read-only access to users within the caller's organization.
  - name: Workspaces
    description: Resource containers scoped to an account.
  - name: Permissions
    description: Inspect what the caller is allowed to do.
  - name: Billing
    description: Billing profile, contacts, and auto top-up settings.
  - name: Faults
    description: Report problems with your resources.
  - name: InfiniBand Partitions
    description: Isolated InfiniBand networks for groups of instances.
  - name: Orderbook
    description: >-
      Read-only orderbook visibility: bid/ask spread, depth, open and filled
      orders, and historical fills, keyed on hardware requirements + delivery
      window.
  - name: Orders
    description: >-
      Estimate an order before placing it: filled price, fee, and operational
      notices.
paths:
  /preview/v2/order_preview:
    post:
      tags:
        - Orders
      summary: Estimate an order
      description: >-
        > ⚠️ This endpoint is in [public
        preview](/preview/roadmap#feature-states).


        Estimate a buy or sell order before placing it.
      operationId: get_order_preview
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/v2.OrderPreviewRequest'
        required: true
      responses:
        '200':
          description: Estimate result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v2.OrderPreviewResponse'
        '401':
          description: Unauthorized.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '422':
          description: Validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnprocessableEntityError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
components:
  schemas:
    v2.OrderPreviewRequest:
      oneOf:
        - allOf:
            - $ref: '#/components/schemas/v2.BuyOrderPreviewRequest'
            - type: object
              required:
                - side
              properties:
                side:
                  type: string
                  const: buy
                  default: buy
        - allOf:
            - $ref: '#/components/schemas/v2.SellOrderPreviewRequest'
            - type: object
              required:
                - side
              properties:
                side:
                  type: string
                  const: sell
                  default: sell
    v2.OrderPreviewResponse:
      oneOf:
        - type: object
          required:
            - post_order_body
            - fee
            - type
          properties:
            post_order_body:
              $ref: '#/components/schemas/v2.CreateOrderRequestPreview'
              description: >-
                Ready-to-submit body for `POST /v2/orders`, priced at the
                estimated rate. It is an estimate, not a promise to fill: the
                market can move before you post it, and when the match combines
                resting orders at different prices, posting it verbatim can fill
                less than estimated or nothing at all. For an `allow_partial`
                estimate that matched only part of the order, the price is the
                rate over the part that matched.
            matched_node_minutes:
              type:
                - integer
                - 'null'
              format: int64
              description: >-
                Node-minutes the quoted rate was derived over, present only when
                the estimate matched part of the order rather than all of it,
                including a sell that can't fill the start of its window. To
                estimate the execution total, multiply the rate by this area in
                node-hours (`matched_node_minutes / 60`), not by the full
                `allocation_schedule_delta` rectangle.


                When absent, the whole order matched and the rectangle is the
                area to price; an order starting now can't fill the minute
                already under way, so matching all of it after that minute is
                whole. For a buy the product can overstate the execution total:
                its rate is derived over the order's remaining window less one
                minute, so it still clears if placement lands a minute later,
                and is capped at `limit_price_dollars_per_node_hour` when one is
                sent.


                A partial quote's rate is rounded down for a sell and up for a
                buy, which puts the product within $0.000001 per matched
                node-minute of the exact total.


                Treat this area as an estimate rather than a guarantee: when the
                match combines resting orders at different prices, posting the
                quoted rate as a limit may fill less than this.
            matched_allocation_schedule:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/Schedule'
                  description: >-
                    The allocation the estimate actually matched. It can be
                    smaller than the requested schedule: an `allow_partial`
                    estimate may match fewer nodes or less time, an order that
                    starts now cannot fill the minute already under way, and a
                    sell first fills from the first allocation schedule grid
                    time more than 5 minutes after it's placed. Like the rate,
                    it is an estimate, not a promise to fill.
            fee:
              $ref: '#/components/schemas/v2.OrderPreviewFee'
              description: Fee policy for the matched instance SKU.
            notices:
              type: array
              items:
                $ref: '#/components/schemas/v2.OrderPreviewNotice'
              description: >-
                Maintenance windows for the matched instance SKU overlapping the
                order's delivery window.
            type:
              type: string
              const: quoted
              default: quoted
        - type: object
          required:
            - reason
            - type
          properties:
            reason:
              $ref: '#/components/schemas/v2.OrderPreviewUnavailableReason'
              description: >-
                Why there is no estimate. For an `allow_partial` request,
                `no_availability` means no part of the order could be covered.
            fee:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/v2.OrderPreviewFee'
                  description: >-
                    Fee policy for the targeted instance SKU. Absent when no SKU
                    could be resolved.
            notices:
              type: array
              items:
                $ref: '#/components/schemas/v2.OrderPreviewNotice'
              description: >-
                Maintenance windows for the targeted instance SKU overlapping
                the requested order window.
            type:
              type: string
              const: unavailable
              default: unavailable
    UnauthorizedError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: authentication_error
              default: authentication_error
            message:
              type: string
              x-speakeasy-error-message: true
    UnprocessableEntityError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: unprocessable_entity
              default: unprocessable_entity
            message:
              type: string
              x-speakeasy-error-message: true
            details:
              type: array
              items:
                $ref: '#/components/schemas/ErrorDetail'
    InternalServerError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: api_error
              default: api_error
            message:
              type: string
              x-speakeasy-error-message: true
    v2.BuyOrderPreviewRequest:
      type: object
      required:
        - requirements
        - start_at
        - duration_seconds
        - node_count
      properties:
        requirements:
          $ref: '#/components/schemas/Requirements'
        start_at:
          $ref: '#/components/schemas/UnixEpoch'
          description: >-
            Order start: a time on the [allocation schedule
            grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid),
            or the current time.
        duration_seconds:
          type: integer
          format: u-int64
          description: >-
            Order duration in seconds, a multiple of 60. The order must end on
            the [allocation schedule
            grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid).
          minimum: 0
        node_count:
          type: integer
          format: int32
          description: Number of nodes. Must be positive.
        pool:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ResourcePathOrId_PoolId'
              description: >-
                Pool that receives compute when the order fills. Omit to get an
                estimate without pinning to a pool. The response body then
                returns a placeholder you must replace before submitting to
                `/v2/orders`.
        allow_partial:
          type: boolean
          description: >-
            If true, the estimate models an order that may fill partially —
            fewer nodes and/or a subset of the requested time window — instead
            of one that fills completely or not at all. Send the same value you
            will send as `allow_partial` on `POST /v2/orders`, or the estimate
            answers for a different order than the one you place. Absent means
            all-or-nothing.
        _preview_preemption_limit_price_multiple:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/PriceMultiple'
              description: >-
                **Preview.** The `_preview_preemption_limit_price_multiple` you
                will send on `POST /v2/orders`, validated the same way. The
                order doesn't count toward your compute limit.
        limit_price_dollars_per_node_hour:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DollarsPerNodeHour'
              description: >-
                The most you will pay. The estimate models a buy limited to this
                rate instead of one that takes any price, so it answers what an
                order at this limit would fill: the matched part's average rate
                stays at or under it, and when nothing can match within it, the
                response is `unavailable` with reason `no_availability`. The
                quoted rate never exceeds this value. Absent means any price.
    v2.SellOrderPreviewRequest:
      type: object
      required:
        - start_at
        - duration_seconds
        - node_count
        - requirements
      properties:
        pool:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ResourcePathOrId_PoolId'
              description: >-
                Pool the order draws from. Omit to get an estimate without
                pinning to a pool. The response body then returns a placeholder
                you must replace before submitting to `/v2/orders`.
        start_at:
          $ref: '#/components/schemas/UnixEpoch'
          description: >-
            Order start: a time on the [allocation schedule
            grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid),
            or the current time.
        duration_seconds:
          type: integer
          format: u-int64
          description: >-
            Order duration in seconds, a multiple of 60. The order must end on
            the [allocation schedule
            grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid).
          minimum: 0
        node_count:
          type: integer
          format: int32
          description: Number of nodes. Must be positive.
        requirements:
          $ref: '#/components/schemas/Requirements'
        allow_partial:
          type: boolean
          description: >-
            If true, the estimate models an order that may fill partially —
            fewer nodes and/or a subset of the requested time window — instead
            of one that fills completely or not at all. Send the same value you
            will send as `allow_partial` on `POST /v2/orders`, or the estimate
            answers for a different order than the one you place. Absent means
            all-or-nothing.
        limit_price_dollars_per_node_hour:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DollarsPerNodeHour'
              description: >-
                The least you will accept. The estimate models a sell limited to
                this rate instead of one that takes any price, so it answers
                what an order at this limit would fill: the matched part's
                average rate stays at or over it, and when nothing can match
                within it, the response is `unavailable` with reason
                `no_availability`. The quoted rate is never below this value.
                Absent means any price.
    v2.CreateOrderRequestPreview:
      type: object
      required:
        - pool
        - side
        - instance_sku
        - allocation_schedule_delta
        - limit_price_dollars_per_node_hour
      properties:
        pool:
          $ref: '#/components/schemas/ResourcePathOrId_PoolId'
          description: Target pool that receives compute when filled.
        side:
          $ref: '#/components/schemas/Side'
        allow_standing:
          type: boolean
          description: >-
            If true, the order rests on the order book until it fills, is
            cancelled, or its end time passes. If false, the order is cancelled
            immediately if it does not fill.
        allow_partial:
          type: boolean
          description: >-
            If true, the order may fill partially — fewer nodes and/or a subset
            of the requested time window. The filled time may be disjoint.
        instance_sku:
          $ref: '#/components/schemas/InstanceSkuId'
          description: >-
            Instance SKU this order will fill on. Rejected at submission if the
            SKU id is not registered.
        allocation_schedule_delta:
          $ref: '#/components/schemas/Schedule'
          description: >-
            Change in capacity if the order fills (added on `buy`, subtracted on
            `sell`). Must be a single time range: one `node_count` held constant
            from `start_at` to `end_at`, with both set. `start_at` and `end_at`
            are Unix timestamps in seconds on the [allocation schedule
            grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid);
            `start_at` can also be the current time. `node_count` must be
            between 1 and 10000.
        limit_price_dollars_per_node_hour:
          $ref: '#/components/schemas/DollarsPerNodeHour'
    Schedule:
      type: array
      items:
        $ref: '#/components/schemas/ScheduleEntry'
      description: >-
        Node count over time, as a list of `[start_at, end_at)` time ranges.


        Example: 5 nodes from t=0 to t=3600 is `[{"start_at": 0, "end_at": 3600,
        "node_count": 5}]`.


        `start_at` and `end_at` must be 60-second aligned, `node_count` must be
        non-negative. On non-final entries, `end_at` may be omitted (inferred
        from the next entry's `start_at`); gaps fill with `node_count: 0`. Order
        and transfer times must also be on the [allocation schedule
        grid](https://docs.sfcompute.com/api-reference/platform/get-platform-constants#response-allocation-schedule-grid),
        except a start at the current time.


        In responses, a non-empty array always closes with a terminator entry
        whose `end_at` is `null` (the unbounded tail) and, for a bounded
        schedule, `node_count: 0`; an empty schedule is returned as `[]`.
    v2.OrderPreviewFee:
      type: object
      description: >-
        Fee charged on fills for the targeted instance SKU.


        Total fee = `flat_dollars_per_node_hour × node_hours` + `percentage_bps
        / 10000 × execution_total_dollars`, where `node_hours` is `node_count ×
        duration_hours` for a whole-order estimate and `matched_node_minutes /
        60` for a partial one.


        Recomputed against the realized price at fill time.
      required:
        - flat_dollars_per_node_hour
        - percentage_bps
      properties:
        flat_dollars_per_node_hour:
          $ref: '#/components/schemas/DollarsPerNodeHour'
        percentage_bps:
          type: integer
          format: int32
          description: Percentage of execution total, in basis points (10000 = 100%).
    v2.OrderPreviewNotice:
      oneOf:
        - type: object
          required:
            - start_at
            - end_at
            - maintenance_type
            - title
            - description
            - type
          properties:
            start_at:
              $ref: '#/components/schemas/UnixEpoch'
            end_at:
              $ref: '#/components/schemas/UnixEpoch'
            maintenance_type:
              $ref: '#/components/schemas/v2.MaintenanceNoticeType'
            title:
              type: string
            description:
              type: string
            action_message:
              type:
                - string
                - 'null'
            type:
              type: string
              const: maintenance_window
              default: maintenance_window
        - type: object
          description: Placing this order would put the account past a limit.
          required:
            - name
            - scope
            - value
            - projected_usage
            - type
          properties:
            name:
              type: string
              description: The limit that would be broken.
            scope:
              $ref: '#/components/schemas/v2.LimitScope'
              description: What that limit covers. Empty covers the whole account.
            value:
              type: string
              description: The ceiling.
            projected_usage:
              type: string
              description: >-
                What the account would have committed against it with this order
                placed.
            type:
              type: string
              const: limit_exceeded
              default: limit_exceeded
        - type: object
          description: >-
            The sell's `capacity` does not hold the compute it would sell, after
            what that capacity's other open sell orders already offer. The quote
            estimates the order as if it did; placing it as is will be rejected.
          required:
            - type
          properties:
            type:
              type: string
              const: insufficient_free_compute_balance
              default: insufficient_free_compute_balance
    v2.OrderPreviewUnavailableReason:
      type: string
      enum:
        - no_matching_instance_skus
        - no_availability
    ErrorDetail:
      type: object
      required:
        - code
        - message
      properties:
        field:
          type:
            - string
            - 'null'
          description: The field that caused the error (for validation errors)
        code:
          type: string
          description: Specific error code for this detail
        message:
          type: string
          description: Human-readable error message
    Requirements:
      type: object
      description: >-
        Key/value filters on instance SKU properties.


        Keys are the property names instance SKUs carry on `GET
        /v2/instance_skus` (e.g. `accelerator`); values match each property's
        `value` spelling. The reserved `instance_sku` key pins to a single SKU
        by id.


        Empty map = no constraints.
      additionalProperties:
        type: array
        items:
          $ref: '#/components/schemas/Name'
      propertyNames:
        type: string
        examples:
          - my-resource-name
        maxLength: 255
        minLength: 1
        pattern: '[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}'
      example:
        accelerator:
          - H100
    UnixEpoch:
      type: integer
      format: int64
      description: Unix timestamp.
      example: 1738972800
    ResourcePathOrId_PoolId:
      type: string
      description: >-
        A resource path like 'sfc:pool:acme:prod:my-pool' _or_ an ID. Resource
        paths are human-readable but not stable - they change when resources are
        renamed or moved. IDs are stable and permanent.
      examples:
        - pool_k3R-nX9vLm7Qp2Yw5Jd8F
      pattern: >-
        (pool_[0-9a-zA-Z_-]{1,21})|(sfc:pool:[a-zA-Z0-9._-]+(:[a-zA-Z0-9._-]+){2,2})
    PriceMultiple:
      type: string
      description: >-
        A multiple of a price, encoded as a decimal string with at most six
        decimal places, such as `"1.25"`. Inputs must contain a decimal point.
      examples:
        - '1.25'
      pattern: ^\d+\.\d{1,6}$
    DollarsPerNodeHour:
      type: string
      description: >-
        Price in dollars per node-hour, encoded as a decimal string. Prices are
        rounded to the nearest $0.000060/node-hour market tick. This is one
        microdollar per node-minute. Responses contain the rounded value with
        six decimal places. Inputs must contain a decimal point, be
        non-negative, and not exceed $500/node-hour.
      examples:
        - '18.000000'
      pattern: ^\d+\.\d+$
    Side:
      type: string
      enum:
        - sell
        - buy
    InstanceSkuId:
      oneOf:
        - type: string
          examples:
            - isku_k3R-nX9vLm7Qp2Yw5Jd8F
          pattern: isku_[0-9a-zA-Z_-]{1,21}
        - type: string
          description: Legacy alias prefix; accepted on read, never emitted on write.
          pattern: clus_[0-9a-zA-Z_-]{1,21}
      description: >-
        Accepts the canonical prefix below; additional legacy prefixes are
        aliased for read compatibility. Writes always emit the canonical form.
    ScheduleEntry:
      type: object
      description: >-
        A `[start_at, end_at)` time range with a fixed `node_count`. `end_at` is
        `null` only on the final entry, marking an unbounded tail.
      required:
        - start_at
        - node_count
      properties:
        start_at:
          $ref: '#/components/schemas/UnixEpoch'
        end_at:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/UnixEpoch'
        node_count:
          type: integer
          format: int32
    v2.MaintenanceNoticeType:
      type: string
      enum:
        - info
        - degraded_performance
        - marketplace_unavailable
    v2.LimitScope:
      type: object
      description: >-
        Where a limit applies. Each key names one way to narrow the limit; its
        value is the one thing the limit is narrowed to. A key that is absent
        places no restriction, so `{}` applies account-wide. Keys not listed
        here may appear as additional string properties when new ways to narrow
        a limit are added.
      properties:
        sku:
          type: string
          description: >-
            The SKU this limit is narrowed to, as a `sku_...` id. Absent means
            the limit applies account-wide.
      additionalProperties:
        type: string
      examples:
        - {}
        - sku: sku_9fK2mQvT
    Name:
      type: string
      examples:
        - my-resource-name
      maxLength: 255
      minLength: 1
      pattern: '[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}'
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Create an API token using `sf tokens create` or at
        https://sfcompute.com/dashboard/tokens.

````