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

# Get user order history v2

> Handles `GET /v1/users/{user_pubkey}/orders_v2` via `get.v1.users.by_user_pubkey.orders_v2`.



## OpenAPI

````yaml /openapi/phoenix-public-api.json get /v1/users/{user_pubkey}/orders_v2
openapi: 3.1.0
info:
  title: Phoenix Eternal API
  description: >-
    RESTful API for accessing Phoenix Eternal perpetual trading data. Provides
    real-time orderbook levels, asset information, and market metadata.
  termsOfService: https://www.phoenix.trade/terms-of-service
  contact:
    name: Phoenix Development Team
    url: https://github.com/Ellipsis-Labs/phoenix
  license:
    name: Proprietary
  version: 1.0.0
servers:
  - url: https://perp-api.phoenix.trade
    description: Phoenix Eternal Perp API
security: []
tags:
  - name: Auth
    description: Wallet and session authentication.
  - name: Exchange
    description: Exchange, market, candle, and no-referral register-instruction workflows.
  - name: Invite
    description: Invite validation, referral activation, and wallet allowlist checks.
  - name: Notifications
    description: Trader notification reads and acknowledgement helpers.
  - name: Trader
    description: Trader state, account history, and transaction builders.
externalDocs:
  url: https://docs.phoenix.trade
  description: Phoenix developer documentation
paths:
  /v1/users/{user_pubkey}/orders_v2:
    get:
      tags:
        - Trader
      summary: Get user order history v2
      description: >-
        Handles `GET /v1/users/{user_pubkey}/orders_v2` via
        `get.v1.users.by_user_pubkey.orders_v2`.
      operationId: get.v1.users.by_user_pubkey.orders_v2
      parameters:
        - name: market_symbol
          in: query
          description: Optional market symbol filter
          required: false
          schema:
            type: string
        - name: limit
          in: query
          description: >-
            Top-level page limit (max 1000); nested TWAP children do not count
            toward this limit
          required: true
          schema:
            type: integer
            format: int64
        - name: cursor
          in: query
          description: >-
            Opaque cursor for the requested view. Start without a cursor when
            switching between flat and organized history.
          required: false
          schema:
            type: string
        - name: organize_twap_orders
          in: query
          description: >-
            Default false: flat packets including TWAP children. True: terminal
            TWAP parents with children and standalone orders grouped inside
            data.
          required: false
          schema:
            type: boolean
        - name: user_pubkey
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderHistoryV2ViewResponse'
          description: Successful response
components:
  schemas:
    OrderHistoryV2ViewResponse:
      oneOf:
        - $ref: '#/components/schemas/OrderHistoryV2Response'
        - $ref: '#/components/schemas/OrganizedOrderHistoryV2Response'
    OrderHistoryV2Response:
      type: object
      description: Paginated response for order history V2
      required:
        - data
        - hasMore
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/OrderHistoryV2Item'
        hasMore:
          type: boolean
        nextCursor:
          type:
            - string
            - 'null'
        prevCursor:
          type:
            - string
            - 'null'
    OrganizedOrderHistoryV2Response:
      type: object
      description: Paginated order history with TWAP executions grouped under their parent.
      required:
        - data
        - hasMore
      properties:
        data:
          $ref: '#/components/schemas/OrganizedOrderHistoryV2Data'
        hasMore:
          type: boolean
        nextCursor:
          type:
            - string
            - 'null'
        prevCursor:
          type:
            - string
            - 'null'
    OrderHistoryV2Item:
      type: object
      description: >-
        Order history V2 item showing intended order (from packet), actual
        placed

        order (from event), and current state (from orders table)
      required:
        - userId
        - traderId
        - traderPdaIndex
        - traderSubaccountIndex
        - slot
        - slotIndex
        - instructionIndex
        - eventIndex
        - marketSymbol
        - instructionType
        - orderType
        - createdAt
        - price
        - intended
        - isReduceOnly
        - isStopLoss
        - status
      properties:
        createdAt:
          type: string
          format: date-time
        currentOrderState:
          oneOf:
            - $ref: '#/components/schemas/CurrentOrderState'
              description: >-
                Current order state (from orders table)

                Shows fills, cancellation, etc. None if order wasn't placed or
                not found
            - type: 'null'
        eventIndex:
          type: integer
          format: int32
        fillBeforePlacement:
          oneOf:
            - $ref: '#/components/schemas/AggregatedTrades'
              description: Aggregated trades executed in this instruction
            - type: 'null'
        instructionIndex:
          type: integer
          format: int32
        instructionType:
          type: string
        intended:
          $ref: '#/components/schemas/IntendedOrder'
          description: Intended order (from order_packets)
        isConditionalOrder:
          type: boolean
        isReduceOnly:
          type: boolean
        isStopLoss:
          type: boolean
        isStopLossDirection:
          type: boolean
        marketSymbol:
          type: string
        orderType:
          type: string
          description: '"limit" or "market"'
        parentOrderId:
          type:
            - string
            - 'null'
        parentOrderType:
          type:
            - string
            - 'null'
        placedOrder:
          oneOf:
            - $ref: '#/components/schemas/PlacedOrder'
              description: |-
                Actual placed order (from order_events with event_type='placed')
                None means the order failed to place
            - type: 'null'
        price:
          type: string
        slot:
          type: integer
          format: int64
        slotIndex:
          type: integer
          format: int32
        sortKey:
          type:
            - string
            - 'null'
        status:
          type: string
        traderId:
          type: integer
          format: int64
        traderPdaIndex:
          type: integer
          format: int32
        traderSubaccountIndex:
          type: integer
          format: int32
        userId:
          type: integer
          format: int64
    OrganizedOrderHistoryV2Data:
      type: object
      required:
        - twapOrders
        - singleOrders
      properties:
        singleOrders:
          type: array
          items:
            $ref: '#/components/schemas/OrderHistoryV2Item'
        twapOrders:
          type: array
          items:
            $ref: '#/components/schemas/TwapParentOrderHistoryItem'
    CurrentOrderState:
      type: object
      description: Current order state from orders table
      required:
        - orderSequenceNumber
        - side
        - price
        - baseQty
        - remainingBaseQty
        - filledBaseQty
        - releasedBaseQty
        - orderStatus
      properties:
        baseQty:
          type: string
        cancelledAt:
          type:
            - string
            - 'null'
          format: date-time
        filledBaseQty:
          type: string
        lastFillAt:
          type:
            - string
            - 'null'
          format: date-time
        orderSequenceNumber:
          type: integer
          format: int64
        orderStatus:
          type: string
          description: '"active", "filled", "cancelled"'
        placedAt:
          type:
            - string
            - 'null'
          format: date-time
        price:
          type: string
        releasedBaseQty:
          type: string
          description: base_qty - remaining_base_qty
        remainingBaseQty:
          type: string
        scaleSetId:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Scale-order set id (1-127) shared by every leg of a
            `PlaceMultiLimitOrderV2` scale-order packet; absent for standalone
            orders.
        side:
          type: string
    AggregatedTrades:
      type: object
      description: Aggregated trades summary for an instruction
      required:
        - totalBaseQtyFilled
        - totalQuoteQtyFilled
        - totalTakerFee
        - totalNumFills
        - numTrades
      properties:
        numTrades:
          type: integer
          format: int32
        totalBaseQtyFilled:
          type: string
        totalNumFills:
          type: integer
          format: int32
        totalQuoteQtyFilled:
          type: string
        totalTakerFee:
          type: string
    IntendedOrder:
      type: object
      description: Intended order details from order_packets
      required:
        - orderKind
        - side
        - hasPriceLimit
        - baseLots
        - baseQty
        - orderFlags
        - isReduceOnly
        - isStopLoss
        - isPostOnly
        - isTakeOnly
        - cancelExisting
      properties:
        baseLots:
          type: integer
          format: int64
        baseQty:
          type: string
        cancelExisting:
          type: boolean
        clientOrderId:
          type:
            - string
            - 'null'
        hasPriceLimit:
          type: boolean
        isConditionalOrder:
          type: boolean
        isPostOnly:
          type: boolean
        isReduceOnly:
          type: boolean
        isStopLoss:
          type: boolean
        isStopLossDirection:
          type: boolean
        isTakeOnly:
          type: boolean
        lastValidSlot:
          type:
            - integer
            - 'null'
          format: int64
        matchLimit:
          type:
            - integer
            - 'null'
          format: int64
        orderFlags:
          type: integer
          format: int32
        orderKind:
          type: string
        priceInTicks:
          type:
            - integer
            - 'null'
          format: int64
        priceUsd:
          type:
            - string
            - 'null'
        quoteLotBudget:
          type:
            - integer
            - 'null'
          format: int64
        side:
          type: string
    PlacedOrder:
      type: object
      description: Actual placed order details from order_events
      required:
        - orderSequenceNumber
        - eventIndex
        - side
        - price
        - baseQty
        - transactionTimestamp
      properties:
        baseQty:
          type: string
        eventIndex:
          type: integer
          format: int32
        initialSlot:
          type:
            - integer
            - 'null'
          format: int64
        lastValidSlot:
          type:
            - integer
            - 'null'
          format: int64
        orderFlags:
          type:
            - integer
            - 'null'
          format: int32
        orderSequenceNumber:
          type: integer
          format: int64
        price:
          type: string
        scaleSetId:
          type:
            - integer
            - 'null'
          format: int32
          description: |-
            Scale-order set id (1-127) shared by every leg of a
            `PlaceMultiLimitOrderV2` scale-order packet; absent for standalone
            orders.
        side:
          type: string
        transactionTimestamp:
          type: string
          format: date-time
          description: Formatted datetime string (ISO 8601).
    TwapParentOrderHistoryItem:
      type: object
      required:
        - parentOrderId
        - parentOrderType
        - marketSymbol
        - traderPdaIndex
        - traderSubaccountIndex
        - status
        - terminalAt
        - sortKey
        - children
      properties:
        children:
          type: array
          items:
            $ref: '#/components/schemas/OrderHistoryV2Item'
        cooldownSlots:
          type:
            - integer
            - 'null'
          format: int64
        filledBaseQty:
          type:
            - string
            - 'null'
        filledQuoteQty:
          type:
            - string
            - 'null'
        isReduceOnly:
          type:
            - boolean
            - 'null'
        marketSymbol:
          type: string
        nChildOrders:
          type:
            - integer
            - 'null'
          format: int64
          description: Total scheduled executions, including additional dust executions.
        nDustOrders:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            Additional dust executions; zero also covers legacy final-child
            dust.
        parentOrderId:
          type: string
        parentOrderType:
          type: string
        placedAt:
          type:
            - string
            - 'null'
          format: date-time
        requestedBaseQty:
          type:
            - string
            - 'null'
        side:
          type:
            - string
            - 'null'
        sortKey:
          type: string
        status:
          type: string
        terminalAt:
          type: string
          format: date-time
        traderPdaIndex:
          type: integer
          format: int32
        traderSubaccountIndex:
          type: integer
          format: int32

````

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