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

> Estimate a buy or sell order before placing it.



## OpenAPI

````yaml /preview/openapi.json post /preview/v2/order_preview
openapi: 3.1.0
info:
  title: sfc-api
  description: >-
    Public preview API - subject to change. See
    https://docs.sfcompute.com/preview/roadmap for details.
  version: 0.1.0
servers:
  - url: https://api.sfcompute.com
security:
  - bearer_auth: []
tags:
  - 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: Procurements
    description: Market automations that maintain capacity by placing buy/sell orders.
  - name: Deployments
    description: Deployment automations that maintain a fleet of instances on a capacity.
  - 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: Orderbook
    description: >-
      Read-only orderbook visibility: bid/ask spread, depth of book, 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: 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
                  readOnly: true
        - allOf:
            - $ref: '#/components/schemas/v2.SellOrderPreviewRequest'
            - type: object
              required:
                - side
              properties:
                side:
                  type: string
                  const: sell
                  default: sell
                  readOnly: true
    v2.OrderPreviewResponse:
      oneOf:
        - type: object
          required:
            - post_order_body
            - fee
            - type
          properties:
            post_order_body:
              $ref: '#/components/schemas/v2.CreateOrderRequest'
              description: >-
                Ready-to-submit body for `POST /v2/orders`. Posting this body
                verbatim will fill at the estimated price.
            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
              readOnly: true
        - type: object
          required:
            - reason
            - type
          properties:
            reason:
              $ref: '#/components/schemas/v2.OrderPreviewUnavailableReason'
            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
              readOnly: true
    UnauthorizedError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - message
          properties:
            type:
              type: string
              const: authentication_error
              default: authentication_error
              readOnly: true
            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
              readOnly: true
            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
              readOnly: true
            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. Must align to a 60-second boundary.
        duration_seconds:
          type: integer
          format: u-int64
          description: Order duration in seconds. Must be a positive multiple of 60.
          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`.
    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. Must align to a 60-second boundary.
        duration_seconds:
          type: integer
          format: u-int64
          description: Order duration in seconds. Must be a positive multiple of 60.
          minimum: 0
        node_count:
          type: integer
          format: int32
          description: Number of nodes. Must be positive.
        requirements:
          $ref: '#/components/schemas/Requirements'
    v2.CreateOrderRequest:
      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 with both `start_at` and
            `end_at`.
        limit_price_dollars_per_node_hour:
          $ref: '#/components/schemas/DollarsPerNodeHour'
          description: >-
            Limit price per node-hour. Decimal string (e.g. `"1.500000"`);
            rounded to per-minute precision on submission.
    v2.OrderPreviewFee:
      type: object
      description: >-
        Fee charged on fills for the targeted instance SKU.


        Total fee = `flat_dollars_per_node_hour × node_count × duration_hours` +
        `percentage_bps / 10000 × execution_total_dollars`.


        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'
          description: Flat fee per node-hour.
        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
              readOnly: true
    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.


        Valid keys and values are published at `GET
        /v2/instance_sku_property_catalog`.


        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})
    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.
    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`.
    DollarsPerNodeHour:
      type: string
      description: Price rate in dollars per node-hour.
      examples:
        - '2.500000'
      pattern: ^\d+\.\d+$
    v2.MaintenanceNoticeType:
      type: string
      enum:
        - info
        - degraded_performance
        - marketplace_unavailable
    Name:
      type: string
      examples:
        - my-resource-name
      maxLength: 255
      minLength: 1
      pattern: '[a-zA-Z0-9][a-zA-Z0-9._-]{0,254}'
    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
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Create an API token using `sf tokens create` or at
        https://sfcompute.com/account/api-keys.

````