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

# Get historical orders

> Returns historical orders for the authenticated user, newest first by default, paged via the response cursor. The time range is optional and unbounded; an inverted range (`end_timestamp_ns` <= `start_timestamp_ns`) is rejected with a 400. Optionally narrow the result to specific orders via `order_id` and/or `order_ids`. A page can be partial or empty and still carry a cursor. Iterate until the response has no cursor.



## OpenAPI

````yaml openapi/order-gateway.json GET /orders
openapi: 3.1.0
info:
  title: ax-order-gateway
  description: ''
  license:
    name: ''
  version: 17.9.1
servers:
  - url: https://gateway.ai.exchange/orders
    description: Production
  - url: https://gateway.sandbox.ai.exchange/orders
    description: Sandbox
security: []
tags:
  - name: order-gateway
    description: Order gateway
paths:
  /orders:
    get:
      tags:
        - order-gateway
      description: >-
        Returns historical orders for the authenticated user, newest first by
        default, paged via the response cursor. The time range is optional and
        unbounded; an inverted range (`end_timestamp_ns` <=
        `start_timestamp_ns`) is rejected with a 400. Optionally narrow the
        result to specific orders via `order_id` and/or `order_ids`. A page can
        be partial or empty and still carry a cursor. Iterate until the response
        has no cursor.
      operationId: get_orders
      parameters:
        - name: symbol
          in: query
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: timeseries
          in: query
          required: true
          schema:
            $ref: ddf4eec2-e5d8-42dd-8cbf-0d69d2ba656a
        - name: order_states
          in: query
          description: >-
            Optional comma-separated order state filter, e.g.
            `FILLED,CANCELED,REPLACED`
          required: false
          schema:
            type:
              - array
              - 'null'
            items:
              $ref: '#/components/schemas/OrderState'
          style: form
          explode: false
        - name: order_id
          in: query
          description: >-
            Optional single order ID filter, e.g. `ORD-1234567890`. Convenience
            alias

            for a one-element `order_ids`; combined with `order_ids` if both are
            set.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: order_ids
          in: query
          description: >-
            Optional comma-separated order ID filter, e.g. `ORD-1,ORD-2`.
            Combined

            with `order_id` if both are set.
          required: false
          schema:
            type:
              - array
              - 'null'
            items:
              type: string
          style: form
          explode: false
        - name: account_id
          in: query
          description: >-
            Optional account ID. If omitted, the user's default (primary)
            account is used.
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: List of orders
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetOrdersResponse'
        '400':
          description: Invalid historical order query
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: >-
            Temporarily unable to serve the request; retry after the
            `Retry-After` delay
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - session_token: []
components:
  schemas:
    OrderState:
      type: string
      enum:
        - PENDING
        - ACCEPTED
        - PARTIALLY_FILLED
        - FILLED
        - CANCELED
        - REJECTED
        - EXPIRED
        - REPLACED
        - DONE_FOR_DAY
        - UNKNOWN
    GetOrdersResponse:
      allOf:
        - $ref: '#/components/schemas/CursorPage'
        - type: object
          required:
            - orders
          properties:
            orders:
              type: array
              items:
                $ref: '#/components/schemas/OrderDetails'
    ErrorResponse:
      type: object
      description: Standard error response format
      required:
        - error
      properties:
        error:
          type: string
    CursorPage:
      type: object
      description: |-
        Page metadata for cursor-paged responses.

        This is intended for response bodies (not query params).
      properties:
        limit:
          type:
            - integer
            - 'null'
          format: int32
          minimum: 0
        next_cursor:
          type:
            - string
            - 'null'
        total_count:
          type:
            - integer
            - 'null'
          format: int64
          minimum: 0
    OrderDetails:
      allOf:
        - $ref: '#/components/schemas/Timestamp'
        - type: object
          required:
            - oid
            - u
            - aid
            - s
            - p
            - q
            - xq
            - rq
            - o
            - d
            - tif
          properties:
            aid:
              type: string
              description: >-
                Owning account — whose positions, balance, and risk this order
                moves.
            bid:
              oneOf:
                - $ref: '#/components/schemas/BrokerId'
                - type: 'null'
            cid:
              oneOf:
                - $ref: '#/components/schemas/ClientOrderId'
                - type: 'null'
            d:
              $ref: '#/components/schemas/Side'
            o:
              $ref: '#/components/schemas/OrderState'
            oid:
              $ref: '#/components/schemas/OrderId'
            p:
              type: string
            po:
              type: boolean
            q:
              type: integer
              format: int64
              minimum: 0
            r:
              oneOf:
                - $ref: '#/components/schemas/OrderRejectReason'
                - type: 'null'
            rb:
              oneOf:
                - $ref: '#/components/schemas/RepriceBehavior'
                  description: >-
                    The reprice behavior the client sent with this order's most
                    recent entry

                    into the book. That entry is the place request or, after a
                    replace, the

                    latest replace request.


                    The gateway reports the value as sent, whether or not it
                    applied. It

                    applied only if `po` was `true` on that same request.


                    Unlike `po`, this field does not carry over from one request
                    to the next.

                    A replace that omits `rb` reports the default, `rej`.


                    This field is absent for orders placed before the gateway
                    recorded it.
                - type: 'null'
            rq:
              type: integer
              format: int64
              minimum: 0
            s:
              type: string
            tag:
              type:
                - string
                - 'null'
            tif:
              $ref: '#/components/schemas/TimeInForce'
            txt:
              type:
                - string
                - 'null'
            u:
              type: string
              description: >-
                Actor of record — the authenticated user who *placed* this
                order. This

                is distinct from the owning `account_id`: a user may place
                orders on an

                account they do not own (e.g. a proxy or algo acting for another
                party).
            xq:
              type: integer
              format: int64
              minimum: 0
    Timestamp:
      type: object
      required:
        - ts
        - tn
      properties:
        tn:
          type: integer
          format: int32
          minimum: 0
        ts:
          type: integer
          format: int32
    BrokerId:
      type: string
      description: |-
        ID of the partner software or broker that sent an order, e.g. `HBOT`:
        3 to 10 ASCII letters or digits, stored in uppercase.
    ClientOrderId:
      type: integer
      format: int64
      minimum: 0
    Side:
      type: string
      enum:
        - B
        - S
    OrderId:
      type: string
      description: |-
        Strong type for Order IDs to prevent mixing with other string values

        Order IDs are ULIDs with a prefix:

        - Regular orders: O-<ULID>
        - Liquidation orders: L-<ULID>
    OrderRejectReason:
      type: string
      enum:
        - CLOSE_ONLY
        - INSUFFICIENT_MARGIN
        - MAX_OPEN_ORDERS_EXCEEDED
        - UNKNOWN_SYMBOL
        - EXCHANGE_CLOSED
        - INCORRECT_QUANTITY
        - INVALID_PRICE_INCREMENT
        - INCORRECT_ORDER_TYPE
        - PRICE_OUT_OF_BOUNDS
        - NO_LIQUIDITY
        - INSUFFICIENT_CREDIT_LIMIT
        - ORIGINAL_ORDER_TERMINATED
        - DUPLICATE_CLIENT_ORDER_ID
        - UNKNOWN
    RepriceBehavior:
      type: string
      description: >-
        Reprice behavior for an aggressive post-only order — the wire `rb`
        field,

        meaningful only alongside `po = true`. Defaults to `Reject`.
      enum:
        - rej
        - bo
        - tbl
    TimeInForce:
      type: string
      description: >-
        Order time-in-force: how long an order stays active before it is
        cancelled.
      enum:
        - GTC
        - IOC
        - DAY
  securitySchemes:
    session_token:
      type: http
      scheme: bearer
      description: User session token

````

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