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

# User events

> User-specific events (requires user-level auth via authenticate action or token query param). Streams order confirmations, balance updates, and a venue-agnostic order lifecycle event (`order_event`) covering DAG steps and terminal fill / failure status across all venues.



## AsyncAPI

````yaml openapi/asyncapi.json userEvents
id: userEvents
title: User events
description: >-
  User-specific events (requires user-level auth via authenticate action or
  token query param). Streams order confirmations, balance updates, and a
  venue-agnostic order lifecycle event (`order_event`) covering DAG steps and
  terminal fill / failure status across all venues.
servers:
  - id: production
    protocol: wss
    host: ws.agg.market
    bindings: []
    variables: []
address: /
parameters: []
bindings: []
operations:
  - &ref_1
    id: receiveOrderSubmitted
    title: Receive order submitted
    description: Order confirmation after trade execution (user-level auth required)
    type: receive
    messages:
      - &ref_4
        id: orderSubmitted
        payload:
          - name: Order submitted
            description: >-
              Order confirmation after trade execution (user-level auth
              required)
            type: object
            properties:
              - name: type
                type: string
                description: order_submitted
                required: true
              - name: venue
                type: string
                required: true
              - name: orderId
                type: string
                required: true
              - name: side
                type: string
                required: true
              - name: price
                type: number
                required: true
              - name: size
                type: number
                required: true
              - name: outcomeId
                type: string
                required: false
              - name: timestamp
                type: number
                required: true
        headers: []
        jsonPayloadSchema:
          title: OrderSubmitted
          type: object
          required:
            - type
            - venue
            - orderId
            - side
            - price
            - size
            - timestamp
          properties:
            type:
              const: order_submitted
              type: string
              x-parser-schema-id: <anonymous-schema-197>
            venue:
              type: string
              x-parser-schema-id: <anonymous-schema-198>
            orderId:
              type: string
              x-parser-schema-id: <anonymous-schema-199>
            side:
              type: string
              x-parser-schema-id: <anonymous-schema-200>
            price:
              type: number
              x-parser-schema-id: <anonymous-schema-201>
            size:
              type: number
              x-parser-schema-id: <anonymous-schema-202>
            outcomeId:
              type: string
              x-parser-schema-id: <anonymous-schema-203>
            timestamp:
              type: number
              x-parser-schema-id: <anonymous-schema-204>
          x-parser-schema-id: <anonymous-schema-196>
        title: Order submitted
        description: Order confirmation after trade execution (user-level auth required)
        example: |-
          {
            "type": "order_submitted",
            "venue": "polymarket",
            "orderId": "ord_abc123",
            "side": "buy",
            "price": 0.55,
            "size": 100,
            "outcomeId": "clv2abc123def456",
            "timestamp": 1710000000000
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderSubmitted
    bindings: []
    extensions: &ref_0
      - id: x-parser-unique-object-id
        value: userEvents
  - &ref_2
    id: receiveBalanceUpdate
    title: Receive balance update
    description: Balance update after trade execution (user-level auth required)
    type: receive
    messages:
      - &ref_5
        id: balanceUpdate
        payload:
          - name: Balance update
            description: Balance update after execution (user-level auth required)
            type: object
            properties:
              - name: type
                type: string
                description: balance_update
                required: true
              - name: venue
                type: string
                required: true
              - name: tradingBalanceCents
                type: number
                required: true
              - name: walletBalanceCents
                type: number
                required: false
              - name: timestamp
                type: number
                required: true
        headers: []
        jsonPayloadSchema:
          title: BalanceUpdate
          type: object
          required:
            - type
            - venue
            - tradingBalanceCents
            - timestamp
          properties:
            type:
              const: balance_update
              type: string
              x-parser-schema-id: <anonymous-schema-206>
            venue:
              type: string
              x-parser-schema-id: <anonymous-schema-207>
            tradingBalanceCents:
              type: number
              x-parser-schema-id: <anonymous-schema-208>
            walletBalanceCents:
              type: number
              x-parser-schema-id: <anonymous-schema-209>
            timestamp:
              type: number
              x-parser-schema-id: <anonymous-schema-210>
          x-parser-schema-id: <anonymous-schema-205>
        title: Balance update
        description: Balance update after execution (user-level auth required)
        example: |-
          {
            "type": "balance_update",
            "venue": "polymarket",
            "tradingBalanceCents": 94500,
            "walletBalanceCents": 100000,
            "timestamp": 1710000000000
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: balanceUpdate
    bindings: []
    extensions: *ref_0
  - &ref_3
    id: receiveOrderEvent
    title: Receive order event
    description: Venue-agnostic order lifecycle event (user-level auth required)
    type: receive
    messages:
      - &ref_6
        id: orderEvent
        payload:
          - name: Order lifecycle event
            description: >-
              Venue-agnostic DAG and order lifecycle stream. Discriminate on the
              `event` field. Emitted for every venue automatically.
            type: object
            properties:
              - name: type
                type: string
                description: order_event
                required: true
              - name: event
                type: string
                required: true
              - name: userId
                type: string
                required: true
              - name: orderId
                type: string
                required: true
              - name: venue
                type: string
                required: false
              - name: filledAmountRaw
                type: string
                required: false
              - name: remainingAmountRaw
                type: string
                required: false
              - name: errorReason
                type: string
                required: false
              - name: dagRunId
                type: string
                required: false
              - name: stepId
                type: string
                required: false
              - name: stepType
                type: string
                required: false
              - name: templateName
                type: string
                required: false
              - name: attempt
                type: number
                required: false
              - name: timestamp
                type: number
                required: true
        headers: []
        jsonPayloadSchema:
          title: OrderEvent
          type: object
          required:
            - type
            - event
            - userId
            - orderId
            - timestamp
          properties:
            type:
              const: order_event
              type: string
              x-parser-schema-id: <anonymous-schema-212>
            event:
              anyOf:
                - const: dag_started
                  type: string
                  x-parser-schema-id: <anonymous-schema-214>
                - const: dag_completed
                  type: string
                  x-parser-schema-id: <anonymous-schema-215>
                - const: dag_failed
                  type: string
                  x-parser-schema-id: <anonymous-schema-216>
                - const: dag_cancelled
                  type: string
                  x-parser-schema-id: <anonymous-schema-217>
                - const: step_started
                  type: string
                  x-parser-schema-id: <anonymous-schema-218>
                - const: step_completed
                  type: string
                  x-parser-schema-id: <anonymous-schema-219>
                - const: step_waiting
                  type: string
                  x-parser-schema-id: <anonymous-schema-220>
                - const: step_failed
                  type: string
                  x-parser-schema-id: <anonymous-schema-221>
                - const: step_retrying
                  type: string
                  x-parser-schema-id: <anonymous-schema-222>
                - const: filled
                  type: string
                  x-parser-schema-id: <anonymous-schema-223>
                - const: partial_fill
                  type: string
                  x-parser-schema-id: <anonymous-schema-224>
                - const: failed
                  type: string
                  x-parser-schema-id: <anonymous-schema-225>
              x-parser-schema-id: <anonymous-schema-213>
            userId:
              type: string
              x-parser-schema-id: <anonymous-schema-226>
            orderId:
              type: string
              x-parser-schema-id: <anonymous-schema-227>
            venue:
              type: string
              x-parser-schema-id: <anonymous-schema-228>
            filledAmountRaw:
              type: string
              x-parser-schema-id: <anonymous-schema-229>
            remainingAmountRaw:
              type: string
              x-parser-schema-id: <anonymous-schema-230>
            errorReason:
              type: string
              x-parser-schema-id: <anonymous-schema-231>
            dagRunId:
              type: string
              x-parser-schema-id: <anonymous-schema-232>
            stepId:
              type: string
              x-parser-schema-id: <anonymous-schema-233>
            stepType:
              type: string
              x-parser-schema-id: <anonymous-schema-234>
            templateName:
              type: string
              x-parser-schema-id: <anonymous-schema-235>
            attempt:
              type: number
              x-parser-schema-id: <anonymous-schema-236>
            timestamp:
              type: number
              x-parser-schema-id: <anonymous-schema-237>
          x-parser-schema-id: <anonymous-schema-211>
        title: Order lifecycle event
        description: >-
          Venue-agnostic DAG and order lifecycle stream. Discriminate on the
          `event` field. Emitted for every venue automatically.
        example: |-
          {
            "type": "order_event",
            "event": "dag_started",
            "userId": "usr_xyz789",
            "orderId": "ord_abc123",
            "venue": "polymarket",
            "filledAmountRaw": "string",
            "remainingAmountRaw": "string",
            "errorReason": "string",
            "dagRunId": "string",
            "stepId": "string",
            "stepType": "string",
            "templateName": "string",
            "attempt": 0,
            "timestamp": 1710000000000
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderEvent
    bindings: []
    extensions: *ref_0
sendOperations:
  - *ref_1
  - *ref_2
  - *ref_3
receiveOperations: []
sendMessages:
  - *ref_4
  - *ref_5
  - *ref_6
receiveMessages: []
extensions:
  - id: x-parser-unique-object-id
    value: userEvents
securitySchemes:
  - id: appId
    name: appId
    type: userPassword
    description: >-
      App-level auth: pass appId as a query parameter on connect. Required for
      all connections. The appId must belong to an active app with matching
      allowed origins.
    extensions: []
  - id: jwt
    name: jwt
    type: http
    description: >-
      User-level auth: pass JWT as token query param on connect, or send {
      action: 'authenticate', token } mid-session. Required for user-specific
      events (orders, balances). Same JWT as the REST API.
    scheme: bearer
    bearerFormat: JWT
    extensions: []

````