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

# User orders and positions

> Authenticated. Sends updates on a user's open orders and current
positions, including all subsequent updates. Expects one connection per
user; product_ids is optional (omit for all products). Open orders are
returned in the snapshot batched by 50.




## AsyncAPI

````yaml api-reference/advanced-trade-api/advanced-trade-asyncapi.json user
id: user
title: User orders and positions
description: |
  Authenticated. Sends updates on a user's open orders and current
  positions, including all subsequent updates. Expects one connection per
  user; product_ids is optional (omit for all products). Open orders are
  returned in the snapshot batched by 50.
servers:
  - id: production
    protocol: wss
    host: advanced-trade-ws.coinbase.com
    bindings: []
    variables: []
address: user
parameters: []
bindings: []
operations:
  - &ref_2
    id: userSubscribe
    title: Subscribe to user updates
    description: >-
      Client sends an authenticated subscribe or unsubscribe request for the
      user channel. A JWT is required.
    type: receive
    messages:
      - &ref_4
        id: subscribe_request
        contentType: application/json
        payload:
          - name: Subscription request
            description: Subscribe to the user channel. A JWT is required to receive data.
            type: object
            properties:
              - name: type
                type: string
                enumValues:
                  - subscribe
                  - unsubscribe
                required: true
              - name: channel
                type: string
                required: true
              - name: product_ids
                type: array
                description: Optional. Omit to receive all products.
                required: false
                properties:
                  - name: item
                    type: string
                    required: false
              - name: jwt
                type: string
                description: CDP JWT. Required to receive data on this channel.
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          additionalProperties: false
          required:
            - type
            - channel
            - jwt
          properties:
            type:
              type: string
              enum:
                - subscribe
                - unsubscribe
              default: subscribe
              x-parser-schema-id: <anonymous-schema-137>
            channel:
              type: string
              default: user
              x-parser-schema-id: <anonymous-schema-138>
            product_ids:
              type: array
              items:
                type: string
                x-parser-schema-id: <anonymous-schema-140>
              description: Optional. Omit to receive all products.
              x-parser-schema-id: <anonymous-schema-139>
            jwt:
              type: string
              description: CDP JWT. Required to receive data on this channel.
              x-parser-schema-id: <anonymous-schema-141>
          x-parser-schema-id: <anonymous-schema-136>
        title: Subscription request
        description: Subscribe to the user channel. A JWT is required to receive data.
        example: |-
          {
            "type": "subscribe",
            "channel": "user",
            "product_ids": [
              "BTC-USD"
            ],
            "jwt": "<JWT>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribe_request
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: user
  - &ref_3
    id: userStream
    title: User stream
    description: >-
      Server streams the user's order and position updates to the subscribed
      client.
    type: send
    messages:
      - &ref_5
        id: user
        contentType: application/json
        payload:
          - allOf: &ref_0
              - type: object
                properties:
                  channel:
                    type: string
                    description: The channel that produced this message.
                    x-parser-schema-id: <anonymous-schema-5>
                  timestamp:
                    type: string
                    format: date-time
                    description: Server time the message was sent (RFC 3339).
                    x-parser-schema-id: <anonymous-schema-6>
                  sequence_num:
                    type: integer
                    description: >-
                      Per-connection message sequence number; use it to detect
                      dropped or out-of-order messages.
                    x-parser-schema-id: <anonymous-schema-7>
                x-parser-schema-id: EnvelopeBase
              - type: object
                properties:
                  channel:
                    const: user
                    x-parser-schema-id: <anonymous-schema-143>
                  events:
                    type: array
                    items:
                      type: object
                      properties:
                        type:
                          type: string
                          enum:
                            - snapshot
                            - update
                          x-parser-schema-id: <anonymous-schema-146>
                        orders:
                          type: array
                          items:
                            type: object
                            properties:
                              avg_price:
                                type: string
                                description: Average filled price of the order so far.
                                x-parser-schema-id: <anonymous-schema-148>
                              cancel_reason:
                                type: string
                                description: Reason for order cancellation.
                                x-parser-schema-id: <anonymous-schema-149>
                              client_order_id:
                                type: string
                                description: >-
                                  Unique identifier of the order specified by
                                  the client.
                                x-parser-schema-id: <anonymous-schema-150>
                              completion_percentage:
                                type: string
                                description: Percentage of order completion.
                                x-parser-schema-id: <anonymous-schema-151>
                              contract_expiry_type:
                                type: string
                                enum:
                                  - UNKNOWN_CONTRACT_EXPIRY
                                  - EXPIRING
                                  - PERPETUAL
                                description: Contract expiry type for the order.
                                x-parser-schema-id: <anonymous-schema-152>
                              cumulative_quantity:
                                type: string
                                description: Amount the order is filled, in base currency.
                                x-parser-schema-id: <anonymous-schema-153>
                              filled_value:
                                type: string
                                description: Value of the filled order.
                                x-parser-schema-id: <anonymous-schema-154>
                              leaves_quantity:
                                type: string
                                description: >-
                                  Amount remaining, in the same currency the
                                  order was placed in (quote or base).
                                x-parser-schema-id: <anonymous-schema-155>
                              limit_price:
                                type: string
                                description: >-
                                  Limit price when the order is a Limit or Stop
                                  Limit type; "0" otherwise.
                                x-parser-schema-id: <anonymous-schema-156>
                              number_of_fills:
                                type: string
                                description: Number of fills for the order.
                                x-parser-schema-id: <anonymous-schema-157>
                              order_id:
                                type: string
                                description: Unique identifier of the order.
                                x-parser-schema-id: <anonymous-schema-158>
                              order_side:
                                type: string
                                enum:
                                  - BUY
                                  - SELL
                                description: Side of the order.
                                x-parser-schema-id: <anonymous-schema-159>
                              order_type:
                                type: string
                                enum:
                                  - LIMIT
                                  - MARKET
                                  - STOP_LIMIT
                                description: Type of the order.
                                x-parser-schema-id: <anonymous-schema-160>
                              outstanding_hold_amount:
                                type: string
                                description: Outstanding hold amount for the order.
                                x-parser-schema-id: <anonymous-schema-161>
                              post_only:
                                type: string
                                enum:
                                  - 'true'
                                  - 'false'
                                description: Whether the order is post-only.
                                x-parser-schema-id: <anonymous-schema-162>
                              product_id:
                                type: string
                                description: The product this order was placed on.
                                x-parser-schema-id: <anonymous-schema-163>
                              product_type:
                                type: string
                                enum:
                                  - UNKNOWN_PRODUCT_TYPE
                                  - SPOT
                                  - FUTURE
                                description: Product type of the order.
                                x-parser-schema-id: <anonymous-schema-164>
                              reject_reason:
                                type: string
                                description: Reason for order rejection.
                                x-parser-schema-id: <anonymous-schema-165>
                              retail_portfolio_id:
                                type: string
                                description: >-
                                  The ID of the portfolio this order is
                                  associated with.
                                x-parser-schema-id: <anonymous-schema-166>
                              risk_managed_by:
                                type: string
                                enum:
                                  - UNKNOWN_RISK_MANAGEMENT_TYPE
                                  - MANAGED_BY_FCM
                                  - MANAGED_BY_VENUE
                                description: Who manages the risk for this order.
                                x-parser-schema-id: <anonymous-schema-167>
                              status:
                                type: string
                                enum:
                                  - PENDING
                                  - OPEN
                                  - FILLED
                                  - CANCEL_QUEUED
                                  - CANCELLED
                                  - EXPIRED
                                  - FAILED
                                description: Order status.
                                x-parser-schema-id: <anonymous-schema-168>
                              stop_price:
                                type: string
                                description: >-
                                  Stop price when the order is a Stop Limit
                                  type; "0" otherwise.
                                x-parser-schema-id: <anonymous-schema-169>
                              time_in_force:
                                type: string
                                enum:
                                  - UNKNOWN_TIME_IN_FORCE
                                  - GOOD_UNTIL_DATE_TIME
                                  - GOOD_UNTIL_CANCELLED
                                  - IMMEDIATE_OR_CANCEL
                                  - FILL_OR_KILL
                                description: Time in force of the order.
                                x-parser-schema-id: <anonymous-schema-170>
                              total_fees:
                                type: string
                                description: Commission paid for the order.
                                x-parser-schema-id: <anonymous-schema-171>
                              total_value_after_fees:
                                type: string
                                description: Total value of the order after fees.
                                x-parser-schema-id: <anonymous-schema-172>
                              trigger_status:
                                type: string
                                enum:
                                  - UNKNOWN_TRIGGER_STATUS
                                  - INVALID_ORDER_TYPE
                                  - STOP_PENDING
                                  - STOP_TRIGGERED
                                description: Trigger status for stop orders.
                                x-parser-schema-id: <anonymous-schema-173>
                              creation_time:
                                type: string
                                format: date-time
                                description: When the order was placed.
                                x-parser-schema-id: <anonymous-schema-174>
                              end_time:
                                type: string
                                format: date-time
                                description: >-
                                  Order end time, or 0001-01-01T00:00:00Z when
                                  not applicable.
                                x-parser-schema-id: <anonymous-schema-175>
                              start_time:
                                type: string
                                format: date-time
                                description: >-
                                  Order start time, or 0001-01-01T00:00:00Z when
                                  not applicable.
                                x-parser-schema-id: <anonymous-schema-176>
                            x-parser-schema-id: Order
                          x-parser-schema-id: <anonymous-schema-147>
                        positions:
                          type: object
                          properties:
                            perpetual_futures_positions:
                              type: array
                              items:
                                type: object
                                properties:
                                  product_id:
                                    type: string
                                    description: >-
                                      Instrument the position is in, e.g.
                                      BTC-PERP-INTX.
                                    x-parser-schema-id: <anonymous-schema-178>
                                  portfolio_uuid:
                                    type: string
                                    description: >-
                                      The uuid of the portfolio this position is
                                      associated with.
                                    x-parser-schema-id: <anonymous-schema-179>
                                  vwap:
                                    type: string
                                    description: >-
                                      Price of the position based on the last
                                      settlement period.
                                    x-parser-schema-id: <anonymous-schema-180>
                                  entry_vwap:
                                    type: string
                                    description: >-
                                      Volume-weighted entry price of the
                                      position (not reset to the last funding
                                      price).
                                    x-parser-schema-id: <anonymous-schema-181>
                                  position_side:
                                    type: string
                                    enum:
                                      - Long
                                      - Short
                                    description: Side of the position.
                                    x-parser-schema-id: <anonymous-schema-182>
                                  margin_type:
                                    type: string
                                    enum:
                                      - Cross
                                      - Isolated
                                    description: Margin type of the position.
                                    x-parser-schema-id: <anonymous-schema-183>
                                  net_size:
                                    type: string
                                    description: >-
                                      Size of the position; positive is long,
                                      negative is short.
                                    x-parser-schema-id: <anonymous-schema-184>
                                  buy_order_size:
                                    type: string
                                    description: Cumulative size of all open buy orders.
                                    x-parser-schema-id: <anonymous-schema-185>
                                  sell_order_size:
                                    type: string
                                    description: Cumulative size of all open sell orders.
                                    x-parser-schema-id: <anonymous-schema-186>
                                  leverage:
                                    type: string
                                    description: Leverage of the position.
                                    x-parser-schema-id: <anonymous-schema-187>
                                  mark_price:
                                    type: string
                                    description: >-
                                      Current mark price for the instrument,
                                      used in risk and margin calculations.
                                    x-parser-schema-id: <anonymous-schema-188>
                                  liquidation_price:
                                    type: string
                                    description: >-
                                      Price at which the position will be
                                      liquidated.
                                    x-parser-schema-id: <anonymous-schema-189>
                                  im_notional:
                                    type: string
                                    description: >-
                                      Amount this position contributes to the
                                      initial margin.
                                    x-parser-schema-id: <anonymous-schema-190>
                                  mm_notional:
                                    type: string
                                    description: >-
                                      Amount this position contributes to the
                                      maintenance margin.
                                    x-parser-schema-id: <anonymous-schema-191>
                                  position_notional:
                                    type: string
                                    description: Notional value of the position.
                                    x-parser-schema-id: <anonymous-schema-192>
                                  unrealized_pnl:
                                    type: string
                                    description: >-
                                      Profit or loss of this position (resets to
                                      0 after settlement).
                                    x-parser-schema-id: <anonymous-schema-193>
                                  aggregated_pnl:
                                    type: string
                                    description: >-
                                      Total profit or loss of this position
                                      since it was opened.
                                    x-parser-schema-id: <anonymous-schema-194>
                                x-parser-schema-id: PerpetualFuturesPosition
                              x-parser-schema-id: <anonymous-schema-177>
                            expiring_futures_positions:
                              type: array
                              items:
                                type: object
                                properties:
                                  product_id:
                                    type: string
                                    description: >-
                                      Instrument the position is in, e.g.
                                      BTC-12Jun24-CDE.
                                    x-parser-schema-id: <anonymous-schema-196>
                                  side:
                                    type: string
                                    enum:
                                      - Long
                                      - Short
                                    description: Side of the position.
                                    x-parser-schema-id: <anonymous-schema-197>
                                  number_of_contracts:
                                    type: string
                                    description: Size of the position in contracts.
                                    x-parser-schema-id: <anonymous-schema-198>
                                  realized_pnl:
                                    type: string
                                    description: Realized PnL for the position.
                                    x-parser-schema-id: <anonymous-schema-199>
                                  unrealized_pnl:
                                    type: string
                                    description: Current unrealized PnL for the position.
                                    x-parser-schema-id: <anonymous-schema-200>
                                  entry_price:
                                    type: string
                                    description: Average entry price of the position.
                                    x-parser-schema-id: <anonymous-schema-201>
                                x-parser-schema-id: ExpiringFuturesPosition
                              x-parser-schema-id: <anonymous-schema-195>
                            prediction_market_positions:
                              type: array
                              items:
                                type: object
                                x-parser-schema-id: <anonymous-schema-203>
                              x-parser-schema-id: <anonymous-schema-202>
                          x-parser-schema-id: Positions
                      x-parser-schema-id: <anonymous-schema-145>
                    x-parser-schema-id: <anonymous-schema-144>
                x-parser-schema-id: <anonymous-schema-142>
            x-parser-schema-id: UserEnvelope
            name: User message
        headers: []
        jsonPayloadSchema:
          allOf: *ref_0
          x-parser-schema-id: UserEnvelope
        title: User message
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: user
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_2
receiveOperations:
  - *ref_3
sendMessages:
  - *ref_4
receiveMessages:
  - *ref_5
extensions:
  - id: x-parser-unique-object-id
    value: user
securitySchemes: []

````