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

# Preview an order

> Runs an order without placing it. The body is the same as for placing an order;
`client_order_id` is optional and ignored. Nothing is recorded or sent.

The preview checks the request, your key's limits and your balance, sizes the order as
it would be sized now, and estimates the fill from the current order book. It returns
the position and balance you would have afterwards.

A preview answers `200` whenever the body is a JSON object. When the order would be
refused, `valid` is `false` and `errors` lists every reason at once, with the same error
objects placing it would return.




## OpenAPI

````yaml /openapi.yaml post /v1/orders/preview
openapi: 3.1.0
info:
  title: Trading API
  license:
    name: Proprietary
    identifier: LicenseRef-Proprietary
  version: '1'
  summary: Trade perpetual futures on Hyperliquid with plain HTTP requests.
  description: >
    The Trading API places market orders on Hyperliquid perpetual futures and
    reports your

    positions, fills and balance. You never sign anything, manage nonces or look
    up asset

    indexes: send a market, a side and a value in US dollars.


    Every request authenticates with an API key created on the account page:

    `Authorization: Bearer tapi_…`.
servers:
  - url: https://tradingapi.dev
    description: Production. Orders trade real money on Hyperliquid mainnet.
security:
  - apiKey: []
tags:
  - name: Markets
    description: The markets you can trade, with their rules and current prices.
  - name: Orders
    description: Place, preview, list and look up orders.
  - name: Positions
    description: Your open positions, and closing them.
  - name: Account
    description: Your balance, the calling key, fills and withdrawals.
paths:
  /v1/orders/preview:
    post:
      tags:
        - Orders
      summary: Preview an order
      description: >
        Runs an order without placing it. The body is the same as for placing an
        order;

        `client_order_id` is optional and ignored. Nothing is recorded or sent.


        The preview checks the request, your key's limits and your balance,
        sizes the order as

        it would be sized now, and estimates the fill from the current order
        book. It returns

        the position and balance you would have afterwards.


        A preview answers `200` whenever the body is a JSON object. When the
        order would be

        refused, `valid` is `false` and `errors` lists every reason at once,
        with the same error

        objects placing it would return.
      operationId: previewOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PreviewOrderRequest'
            examples:
              market:
                summary: What would $5,000 of BTC do?
                value:
                  market: BTC
                  side: buy
                  type: market
                  value: '5000.00'
      responses:
        '200':
          description: The preview.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderPreview'
              examples:
                valid:
                  summary: An order that would be placed
                  value:
                    object: order_preview
                    valid: true
                    order:
                      market: BTC
                      side: buy
                      type: market
                      requested_value: '5000.00'
                      reduce_only: false
                      size: '0.0592'
                      price: null
                      price_limit: '84430'
                    estimate:
                      average_fill_price: '84018.2'
                      price_impact_bps: '1.0'
                      value: '4973.88'
                      fee: '7.212126'
                    position_after:
                      direction: long
                      size: '0.0692'
                      entry_price: '83938.1'
                      value: '5814.06'
                    account_after:
                      available: '331.27'
                    notes: []
                    errors: []
                invalid:
                  summary: An order that would be refused
                  value:
                    object: order_preview
                    valid: false
                    order: null
                    estimate: null
                    position_after: null
                    account_after: null
                    notes: []
                    errors:
                      - type: permission
                        code: key_order_limit_exceeded
                        message: >-
                          This key may place orders of up to $250.00; this one
                          is $5,000.00.
                        param: value
                        hint: >-
                          Send a value of at most $250.00, or raise the key's
                          limit on the account page.
                        details:
                          max_order_value: '250.00'
                          value: '5000.00'
                        errors: []
                        retryable: false
                        doc_url: >-
                          https://docs.tradingapi.dev/api-reference/errors#key_order_limit_exceeded
        '400':
          description: The body is not a JSON object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  schemas:
    PreviewOrderRequest:
      type: object
      description: >-
        The same body as placing an order. `client_order_id` is optional and
        ignored.
      required:
        - market
        - side
        - type
        - value
      additionalProperties: false
      properties:
        client_order_id: 37e15384-8c6b-496e-b6cf-197fbb071ee8
        market: db6c7361-1d0a-4d67-84ef-57c1fbf4df03
        side: ef2d1918-729a-4c81-b3d7-f4d3b7dc3d05
        type: 898395c4-012c-4af0-8f06-26fa3e7533e5
        value: 6df3eeeb-24bc-46cd-af6d-97de6db57cd8
        price: 7c53e282-3cd4-4edd-b6a7-364f3aab4b03
        reduce_only: 8883b8ab-f5c2-44c5-8dde-53d78bdb2cd3
        metadata: f4cf9425-e26f-4ebf-9fdf-155bf6cf561f
    OrderPreview:
      type: object
      required:
        - object
        - valid
        - order
        - estimate
        - position_after
        - account_after
        - notes
        - errors
      properties:
        object:
          type: string
          const: order_preview
        valid:
          type: boolean
          description: Whether placing this order now would be accepted.
        order:
          type:
            - object
            - 'null'
          description: The order as it would be sized now.
          properties:
            market:
              type: string
            side:
              $ref: '#/components/schemas/Side'
            type:
              $ref: '#/components/schemas/OrderType'
            requested_value:
              type:
                - string
                - 'null'
            reduce_only:
              type: boolean
            size:
              type: string
            price:
              type:
                - string
                - 'null'
            price_limit:
              type: string
        estimate:
          type:
            - object
            - 'null'
          description: The expected fill, from the current order book.
          properties:
            average_fill_price:
              type: string
            price_impact_bps:
              type: string
              description: How far the average fill is from the mid, in basis points.
            value:
              type: string
            fee:
              type: string
        position_after:
          type:
            - object
            - 'null'
          description: >-
            Your position if the order fills as estimated. `null` if it would
            close the position.
          properties:
            direction:
              type: string
              enum:
                - long
                - short
            size:
              type: string
            entry_price:
              type: string
            value:
              type: string
        account_after:
          type:
            - object
            - 'null'
          properties:
            available:
              type: string
        notes:
          type: array
          items:
            $ref: '#/components/schemas/Note'
        errors:
          type: array
          description: Every reason the order would be refused, when `valid` is `false`.
          items:
            $ref: '#/components/schemas/Error'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    Side:
      type: string
      enum:
        - buy
        - sell
    OrderType:
      type: string
      enum:
        - market
        - limit
      description: >
        `market` fills now at the best available prices, within 0.5% of the
        current price.

        `limit` fills now at your `price` or better; whatever cannot fill at
        once is canceled.
    Note:
      type: object
      required:
        - code
        - message
      description: >
        Something worth knowing about a response that did not stop it.
        `available_low`,

        `partial_fill_likely` and `trading_approval_expiring` appear on previews
        only.
      properties:
        code:
          type: string
          enum:
            - size_rounded
            - price_rounded
            - position_flipped
            - position_closed
            - available_low
            - partial_fill_likely
            - trading_approval_expiring
        message:
          type: string
    Error:
      type: object
      required:
        - type
        - code
        - message
        - param
        - hint
        - details
        - errors
        - retryable
        - doc_url
      properties:
        type:
          type: string
          enum:
            - invalid_request
            - authentication
            - permission
            - not_found
            - conflict
            - unprocessable
            - rate_limited
            - unavailable
            - internal
          description: The kind of error. It determines the HTTP status.
        code:
          type: string
          description: >-
            A stable identifier for the error. Branch on this. New codes may be
            added.
        message:
          type: string
          description: What was wrong, with the values involved.
        param:
          type:
            - string
            - 'null'
          description: The request field at fault, as a JSON path, or `null`.
        hint:
          type:
            - string
            - 'null'
          description: One concrete way to fix the request.
        details:
          type: object
          description: The numbers and values the message refers to, as fields.
          additionalProperties: true
        errors:
          type: array
          description: Every field error, when `code` is `invalid_fields`. Empty otherwise.
          items:
            $ref: '#/components/schemas/Error'
        retryable:
          type: boolean
          description: Whether the same request can succeed later, unchanged.
        retry_after:
          $ref: '#/components/schemas/Timestamp'
          description: When a retry can succeed, if known.
        doc_url:
          type: string
          format: uri
    Timestamp:
      type: string
      format: date-time
      description: >-
        RFC 3339 in UTC with milliseconds, for example
        `2026-09-27T14:30:00.123Z`.
  responses:
    Unauthorized:
      description: No valid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            invalid_api_key:
              value:
                error:
                  type: authentication
                  code: invalid_api_key
                  message: This API key is not valid. It may have been revoked.
                  param: null
                  hint: >-
                    Send a current key as Authorization: Bearer tapi_…. Keys are
                    created and revoked on the account page.
                  details: {}
                  errors: []
                  retryable: false
                  doc_url: >-
                    https://docs.tradingapi.dev/api-reference/errors#invalid_api_key
    RateLimited:
      description: >-
        The key made too many requests. Each key may make 10 requests at once,
        then 5 a second. Nothing was done; retry after `Retry-After` seconds.
      headers:
        Retry-After:
          description: The seconds to wait before retrying, always `1`.
          schema:
            type: string
            enum:
              - '1'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            rate_limited:
              value:
                error:
                  type: rate_limited
                  code: rate_limited
                  message: This key made too many requests; retry in 1 s.
                  param: null
                  hint: >-
                    Slow down: each key may make 10 requests at once, then 5 a
                    second.
                  details: {}
                  errors: []
                  retryable: true
                  retry_after: '2026-09-28T14:05:12.000Z'
                  doc_url: >-
                    https://docs.tradingapi.dev/api-reference/errors#rate_limited
    Unavailable:
      description: A service we depend on failed. Retry the same request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            unavailable:
              value:
                error:
                  type: unavailable
                  code: unavailable
                  message: The exchange could not be reached.
                  param: null
                  hint: >-
                    Retry the same request with the same client_order_id; an
                    order may already have been recorded.
                  details: {}
                  errors: []
                  retryable: true
                  doc_url: https://docs.tradingapi.dev/api-reference/errors#unavailable
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: tapi_…
      description: >-
        An API key from the account page, sent as `Authorization: Bearer
        tapi_…`.

````