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

# WebSocket Connection

> Main WebSocket connection endpoint. All communication happens through this single connection.
Authentication is required to establish the connection; include API key headers during the WebSocket handshake.
Some channels carry only public market data, but the connection itself still requires authentication.
Use the subscribe command to subscribe to specific data channels. For more information, see the [Getting Started](https://docs.kalshi.com/getting_started/quick_start_websockets) guide.




## AsyncAPI

````yaml asyncapi.yaml root
id: root
title: WebSocket Connection
description: >
  Main WebSocket connection endpoint. All communication happens through this
  single connection.

  Authentication is required to establish the connection; include API key
  headers during the WebSocket handshake.

  Some channels carry only public market data, but the connection itself still
  requires authentication.

  Use the subscribe command to subscribe to specific data channels. For more
  information, see the [Getting
  Started](https://docs.kalshi.com/getting_started/quick_start_websockets)
  guide.
servers:
  - id: production
    protocol: wss
    host: external-api-ws.kalshi.com
    bindings: []
    variables: []
address: /
parameters: []
bindings:
  - protocol: ws
    version: latest
    value:
      method: GET
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
operations:
  - &ref_8
    id: sendSubscribe
    title: Subscribe to Channels
    description: Subscribe to one or more market data channels
    type: receive
    messages:
      - &ref_21
        id: subscribeCommand
        contentType: application/json
        payload:
          - name: Subscribe Command
            description: Subscribe to one or more channels
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: subscribe
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: channels
                    type: array
                    description: List of channels to subscribe to
                    required: true
                    properties:
                      - name: item
                        type: string
                        enumValues:
                          - orderbook_delta
                          - ticker
                          - trade
                          - fill
                          - market_positions
                          - market_lifecycle_v2
                          - multivariate_market_lifecycle
                          - multivariate
                          - communications
                          - order_group_updates
                          - user_orders
                          - cfbenchmarks_value
                          - pyth_value
                        required: false
                  - name: market_ticker
                    type: string
                    description: >-
                      Subscribe to a single market. Type: string. Example:
                      "KXBTCD-25AUG0517-T114999.99" (mutually exclusive with
                      market_tickers)
                    required: false
                  - name: market_tickers
                    type: array
                    description: >-
                      Subscribe to multiple markets. Type: array of strings.
                      Example: ["KXBTCD-25AUG0517-T114999.99",
                      "KXETHD-25AUG0517-T3749.99"] (mutually exclusive with
                      market_ticker)
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        examples: &ref_0
                          - FED-23DEC-T3.00
                          - HIGHNY-22DEC23-B53.5
                        required: false
                  - name: market_id
                    type: string
                    description: >-
                      Subscribe to a single market by UUID (ticker only;
                      mutually exclusive with market_ids and market_ticker(s))
                    required: false
                  - name: market_ids
                    type: array
                    description: >-
                      Subscribe to multiple markets by UUID (ticker only;
                      mutually exclusive with market_id and market_ticker(s))
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market UUID
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      If true, receive an initial snapshot for requested market
                      tickers on the ticker channel
                    required: false
                  - name: skip_ticker_ack
                    type: boolean
                    description: >-
                      If true, OK responses omit the market_tickers/market_ids
                      lists for this subscription
                    required: false
                  - name: use_yes_price
                    type: boolean
                    description: >
                      Orderbook channel only. When true, no-side
                      `orderbook_delta` and `orderbook_snapshot` updates

                      are reported in yes-leg pricing instead of no-leg pricing
                      — so a single `price_dollars` scale

                      applies to both sides. Default false (no-side reported in
                      no-leg pricing, the existing

                      long-standing behavior). See [Order
                      direction](/getting_started/order_direction).


                      **Migration plan.** The default will be flipped to `true`
                      in a future release, and the flag

                      will then be removed entirely in a subsequent release — at
                      which point unified yes-leg

                      pricing becomes the only supported behavior and
                      `use_yes_price: false` will no longer toggle

                      the legacy no-leg pricing. Integrations relying on the
                      legacy behavior should migrate before

                      the default flip; concrete dates will be announced before
                      each step.
                    required: false
                  - name: shard_factor
                    type: integer
                    description: >-
                      Number of shards for communications channel fanout
                      (optional)
                    required: false
                  - name: shard_key
                    type: integer
                    description: >-
                      Shard key for communications channel fanout (requires
                      shard_factor)
                    required: false
                  - name: index_ids
                    type: array
                    description: >-
                      cfbenchmarks_value channel only. CF Benchmarks index IDs
                      to seed on the initial subscribe (omit to subscribe with
                      no indices and add them later via update_subscription; use
                      ["all"] to track every available index).
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
                  - name: underlying_tickers
                    type: array
                    description: >-
                      pyth_value channel only. Underlying tickers to seed on the
                      initial subscribe (omit to subscribe with no underlyings
                      and add them later; use ["all"] to track every available
                      underlying).
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: &ref_1
              type: integer
              description: >
                Unique ID of the command request. Generated by the client and
                should be unique within a WS session.

                The simplest way to use it would be to start from 1 and then
                increment the value for every new command sent to the server.

                If the id is set to 0, the server treats it the same way as if
                there was no id.
              minimum: 0
              x-parser-schema-id: commandId
            cmd:
              type: string
              const: subscribe
              x-parser-schema-id: <anonymous-schema-1>
            params:
              type: object
              required:
                - channels
              properties:
                channels:
                  type: array
                  description: List of channels to subscribe to
                  items:
                    type: string
                    enum:
                      - orderbook_delta
                      - ticker
                      - trade
                      - fill
                      - market_positions
                      - market_lifecycle_v2
                      - multivariate_market_lifecycle
                      - multivariate
                      - communications
                      - order_group_updates
                      - user_orders
                      - cfbenchmarks_value
                      - pyth_value
                    x-parser-schema-id: <anonymous-schema-4>
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-3>
                market_ticker:
                  description: >-
                    Subscribe to a single market. Type: string. Example:
                    "KXBTCD-25AUG0517-T114999.99" (mutually exclusive with
                    market_tickers)
                  type: string
                  x-parser-schema-id: <anonymous-schema-5>
                market_tickers:
                  type: array
                  description: >-
                    Subscribe to multiple markets. Type: array of strings.
                    Example: ["KXBTCD-25AUG0517-T114999.99",
                    "KXETHD-25AUG0517-T3749.99"] (mutually exclusive with
                    market_ticker)
                  items: &ref_4
                    type: string
                    description: Unique market identifier
                    pattern: ^[A-Z0-9-]+$
                    examples: *ref_0
                    x-parser-schema-id: marketTicker
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-6>
                market_id:
                  type: string
                  format: uuid
                  description: >-
                    Subscribe to a single market by UUID (ticker only; mutually
                    exclusive with market_ids and market_ticker(s))
                  x-parser-schema-id: <anonymous-schema-7>
                market_ids:
                  type: array
                  description: >-
                    Subscribe to multiple markets by UUID (ticker only; mutually
                    exclusive with market_id and market_ticker(s))
                  items: &ref_5
                    type: string
                    description: Unique market UUID
                    format: uuid
                    x-parser-schema-id: marketId
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-8>
                send_initial_snapshot:
                  type: boolean
                  description: >-
                    If true, receive an initial snapshot for requested market
                    tickers on the ticker channel
                  default: false
                  x-parser-schema-id: <anonymous-schema-9>
                skip_ticker_ack:
                  type: boolean
                  description: >-
                    If true, OK responses omit the market_tickers/market_ids
                    lists for this subscription
                  default: false
                  x-parser-schema-id: <anonymous-schema-10>
                use_yes_price:
                  type: boolean
                  description: >
                    Orderbook channel only. When true, no-side `orderbook_delta`
                    and `orderbook_snapshot` updates

                    are reported in yes-leg pricing instead of no-leg pricing —
                    so a single `price_dollars` scale

                    applies to both sides. Default false (no-side reported in
                    no-leg pricing, the existing

                    long-standing behavior). See [Order
                    direction](/getting_started/order_direction).


                    **Migration plan.** The default will be flipped to `true` in
                    a future release, and the flag

                    will then be removed entirely in a subsequent release — at
                    which point unified yes-leg

                    pricing becomes the only supported behavior and
                    `use_yes_price: false` will no longer toggle

                    the legacy no-leg pricing. Integrations relying on the
                    legacy behavior should migrate before

                    the default flip; concrete dates will be announced before
                    each step.
                  default: false
                  x-parser-schema-id: <anonymous-schema-11>
                shard_factor:
                  type: integer
                  description: >-
                    Number of shards for communications channel fanout
                    (optional)
                  minimum: 1
                  x-parser-schema-id: <anonymous-schema-12>
                shard_key:
                  type: integer
                  description: >-
                    Shard key for communications channel fanout (requires
                    shard_factor)
                  minimum: 0
                  x-parser-schema-id: <anonymous-schema-13>
                index_ids:
                  type: array
                  description: >-
                    cfbenchmarks_value channel only. CF Benchmarks index IDs to
                    seed on the initial subscribe (omit to subscribe with no
                    indices and add them later via update_subscription; use
                    ["all"] to track every available index).
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-15>
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-14>
                underlying_tickers:
                  type: array
                  description: >-
                    pyth_value channel only. Underlying tickers to seed on the
                    initial subscribe (omit to subscribe with no underlyings and
                    add them later; use ["all"] to track every available
                    underlying).
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-17>
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-16>
              x-parser-schema-id: <anonymous-schema-2>
          x-parser-schema-id: subscribeCommandPayload
        title: Subscribe Command
        description: Subscribe to one or more channels
        example: |-
          {
            "id": 1,
            "cmd": "subscribe",
            "params": {
              "channels": [
                "orderbook_delta"
              ],
              "market_ticker": "CPI-22DEC-TN0.1"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeCommand
    bindings: []
    extensions: &ref_2
      - id: x-parser-unique-object-id
        value: root
  - &ref_9
    id: sendUnsubscribe
    title: Unsubscribe from Channels
    description: Cancel one or more active subscriptions
    type: receive
    messages:
      - &ref_22
        id: unsubscribeCommand
        contentType: application/json
        payload:
          - name: Unsubscribe Command
            description: Cancel one or more subscriptions
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: unsubscribe
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sids
                    type: array
                    description: List of subscription IDs to cancel
                    required: true
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: *ref_1
            cmd:
              type: string
              const: unsubscribe
              x-parser-schema-id: <anonymous-schema-18>
            params:
              type: object
              required:
                - sids
              properties:
                sids:
                  type: array
                  description: List of subscription IDs to cancel
                  items: &ref_3
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    minimum: 1
                    x-parser-schema-id: subscriptionId
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-20>
              x-parser-schema-id: <anonymous-schema-19>
          x-parser-schema-id: unsubscribeCommandPayload
        title: Unsubscribe Command
        description: Cancel one or more subscriptions
        example: |-
          {
            "id": 124,
            "cmd": "unsubscribe",
            "params": {
              "sids": [
                1,
                2
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeCommand
    bindings: []
    extensions: *ref_2
  - &ref_10
    id: sendListSubscriptions
    title: List Subscriptions
    description: List all active subscriptions
    type: receive
    messages:
      - &ref_23
        id: listSubscriptionsCommand
        contentType: application/json
        payload:
          - name: List Subscriptions Command
            description: List all active subscriptions
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: list_subscriptions
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
          properties:
            id: *ref_1
            cmd:
              type: string
              const: list_subscriptions
              x-parser-schema-id: <anonymous-schema-42>
          x-parser-schema-id: listSubscriptionsCommandPayload
        title: List Subscriptions Command
        description: List all active subscriptions
        example: |-
          {
            "id": 3,
            "cmd": "list_subscriptions"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: listSubscriptionsCommand
    bindings: []
    extensions: *ref_2
  - &ref_11
    id: sendUpdateSubscription
    title: Update Subscription - Add Markets
    description: Add markets to an existing subscription
    type: receive
    messages:
      - &ref_24
        id: updateSubscriptionCommand
        contentType: application/json
        payload:
          - name: Update Subscription - Add Markets
            description: Add markets to an existing subscription
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: update_subscription
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: false
                  - name: sids
                    type: array
                    description: >-
                      Array containing exactly one subscription ID (alternative
                      to sid). Either sid or sids must be provided, not both.
                    required: false
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
                  - name: market_ticker
                    type: string
                    description: 'Add/remove a single market. Type: string'
                    required: false
                  - name: market_tickers
                    type: array
                    description: 'Add/remove multiple markets. Type: array of strings'
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        examples: *ref_0
                        required: false
                  - name: market_id
                    type: string
                    description: Add/remove a single market by UUID (ticker only)
                    required: false
                  - name: market_ids
                    type: array
                    description: Add/remove multiple markets by UUID (ticker only)
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market UUID
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      If true, receive an initial snapshot for newly added
                      market tickers on the ticker channel
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: &ref_6
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: *ref_1
            cmd:
              type: string
              const: update_subscription
              x-parser-schema-id: <anonymous-schema-21>
            params:
              type: object
              required:
                - action
              properties:
                sid: *ref_3
                sids:
                  type: array
                  description: >-
                    Array containing exactly one subscription ID (alternative to
                    sid). Either sid or sids must be provided, not both.
                  items: *ref_3
                  minItems: 1
                  maxItems: 1
                  x-parser-schema-id: <anonymous-schema-23>
                market_ticker:
                  description: 'Add/remove a single market. Type: string'
                  type: string
                  x-parser-schema-id: <anonymous-schema-24>
                market_tickers:
                  type: array
                  description: 'Add/remove multiple markets. Type: array of strings'
                  items: *ref_4
                  x-parser-schema-id: <anonymous-schema-25>
                market_id:
                  type: string
                  format: uuid
                  description: Add/remove a single market by UUID (ticker only)
                  x-parser-schema-id: <anonymous-schema-26>
                market_ids:
                  type: array
                  description: Add/remove multiple markets by UUID (ticker only)
                  items: *ref_5
                  x-parser-schema-id: <anonymous-schema-27>
                send_initial_snapshot:
                  type: boolean
                  description: >-
                    If true, receive an initial snapshot for newly added market
                    tickers on the ticker channel
                  default: false
                  x-parser-schema-id: <anonymous-schema-28>
                action:
                  type: string
                  enum:
                    - add_markets
                    - delete_markets
                    - get_snapshot
                  x-parser-schema-id: <anonymous-schema-29>
              x-parser-schema-id: <anonymous-schema-22>
          x-parser-schema-id: updateSubscriptionCommandPayload
        title: Update Subscription - Add Markets
        description: Add markets to an existing subscription
        example: |-
          {
            "id": 124,
            "cmd": "update_subscription",
            "params": {
              "sids": [
                456
              ],
              "market_tickers": [
                "NEW-MARKET-1",
                "NEW-MARKET-2"
              ],
              "action": "add_markets"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionCommand
    bindings: []
    extensions: *ref_2
  - &ref_12
    id: sendUpdateSubscriptionDelete
    title: Update Subscription - Delete Markets
    description: Remove markets from an existing subscription
    type: receive
    messages:
      - &ref_25
        id: updateSubscriptionDeleteCommand
        contentType: application/json
        payload:
          - name: Update Subscription - Delete Markets
            description: Remove markets from an existing subscription
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: update_subscription
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: false
                  - name: sids
                    type: array
                    description: >-
                      Array containing exactly one subscription ID (alternative
                      to sid). Either sid or sids must be provided, not both.
                    required: false
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
                  - name: market_ticker
                    type: string
                    description: 'Add/remove a single market. Type: string'
                    required: false
                  - name: market_tickers
                    type: array
                    description: 'Add/remove multiple markets. Type: array of strings'
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        examples: *ref_0
                        required: false
                  - name: market_id
                    type: string
                    description: Add/remove a single market by UUID (ticker only)
                    required: false
                  - name: market_ids
                    type: array
                    description: Add/remove multiple markets by UUID (ticker only)
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market UUID
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      If true, receive an initial snapshot for newly added
                      market tickers on the ticker channel
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: *ref_6
        title: Update Subscription - Delete Markets
        description: Remove markets from an existing subscription
        example: |-
          {
            "id": 125,
            "cmd": "update_subscription",
            "params": {
              "sids": [
                456
              ],
              "market_tickers": [
                "MARKET-TO-REMOVE-1",
                "MARKET-TO-REMOVE-2"
              ],
              "action": "delete_markets"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionDeleteCommand
    bindings: []
    extensions: *ref_2
  - &ref_13
    id: sendUpdateSubscriptionSingleSid
    title: Update Subscription - Single SID
    description: Update subscription using single sid parameter
    type: receive
    messages:
      - &ref_26
        id: updateSubscriptionSingleSidCommand
        contentType: application/json
        payload:
          - name: Update Subscription - Single SID Format
            description: Update subscription using sid parameter instead of sids array
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: update_subscription
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: false
                  - name: sids
                    type: array
                    description: >-
                      Array containing exactly one subscription ID (alternative
                      to sid). Either sid or sids must be provided, not both.
                    required: false
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
                  - name: market_ticker
                    type: string
                    description: 'Add/remove a single market. Type: string'
                    required: false
                  - name: market_tickers
                    type: array
                    description: 'Add/remove multiple markets. Type: array of strings'
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        examples: *ref_0
                        required: false
                  - name: market_id
                    type: string
                    description: Add/remove a single market by UUID (ticker only)
                    required: false
                  - name: market_ids
                    type: array
                    description: Add/remove multiple markets by UUID (ticker only)
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market UUID
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      If true, receive an initial snapshot for newly added
                      market tickers on the ticker channel
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: *ref_6
        title: Update Subscription - Single SID Format
        description: Update subscription using sid parameter instead of sids array
        example: |-
          {
            "id": 126,
            "cmd": "update_subscription",
            "params": {
              "sid": 456,
              "market_tickers": [
                "NEW-MARKET-3",
                "NEW-MARKET-4"
              ],
              "action": "add_markets"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionSingleSidCommand
    bindings: []
    extensions: *ref_2
  - &ref_14
    id: sendCFBenchmarksUpdateSubscription
    title: Update Subscription - CF Benchmarks Indices
    description: >-
      Add or remove tracked index IDs, or list available indices, on a
      cfbenchmarks_value subscription
    type: receive
    messages:
      - &ref_27
        id: cfbenchmarksUpdateSubscriptionCommand
        contentType: application/json
        payload:
          - name: Update Subscription - CF Benchmarks Indices
            description: >-
              Add or remove tracked index IDs, or list available indices, on a
              cfbenchmarks_value subscription
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: update_subscription
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: false
                  - name: sids
                    type: array
                    description: >-
                      Array containing exactly one subscription ID (alternative
                      to sid). Either sid or sids must be provided, not both.
                    required: false
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
                  - name: action
                    type: string
                    description: >
                      - `subscribe_indices`: add the supplied `index_ids` to the
                      subscription (requires `index_ids`)

                      - `unsubscribe_indices`: remove the supplied `index_ids`
                      from the subscription (requires `index_ids`)

                      - `indexlist`: respond with the available index IDs
                      without modifying the subscription
                    enumValues:
                      - subscribe_indices
                      - unsubscribe_indices
                      - indexlist
                    required: true
                  - name: index_ids
                    type: array
                    description: >-
                      CF Benchmarks index IDs to add or remove. Use ["all"] to
                      track every available index. Required for
                      subscribe_indices and unsubscribe_indices.
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: *ref_1
            cmd:
              type: string
              const: update_subscription
              x-parser-schema-id: <anonymous-schema-30>
            params:
              type: object
              required:
                - action
              properties:
                sid: *ref_3
                sids:
                  type: array
                  description: >-
                    Array containing exactly one subscription ID (alternative to
                    sid). Either sid or sids must be provided, not both.
                  items: *ref_3
                  minItems: 1
                  maxItems: 1
                  x-parser-schema-id: <anonymous-schema-32>
                action:
                  type: string
                  description: >
                    - `subscribe_indices`: add the supplied `index_ids` to the
                    subscription (requires `index_ids`)

                    - `unsubscribe_indices`: remove the supplied `index_ids`
                    from the subscription (requires `index_ids`)

                    - `indexlist`: respond with the available index IDs without
                    modifying the subscription
                  enum:
                    - subscribe_indices
                    - unsubscribe_indices
                    - indexlist
                  x-parser-schema-id: <anonymous-schema-33>
                index_ids:
                  type: array
                  description: >-
                    CF Benchmarks index IDs to add or remove. Use ["all"] to
                    track every available index. Required for subscribe_indices
                    and unsubscribe_indices.
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-35>
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-34>
              x-parser-schema-id: <anonymous-schema-31>
          x-parser-schema-id: cfbenchmarksUpdateSubscriptionCommandPayload
        title: Update Subscription - CF Benchmarks Indices
        description: >-
          Add or remove tracked index IDs, or list available indices, on a
          cfbenchmarks_value subscription
        example: |-
          {
            "id": 2,
            "cmd": "update_subscription",
            "params": {
              "sid": 1,
              "action": "indexlist"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: cfbenchmarksUpdateSubscriptionCommand
    bindings: []
    extensions: *ref_2
  - &ref_15
    id: sendPythUpdateSubscription
    title: Update Subscription - Pyth Underlyings
    description: >-
      Add or remove underlying tickers, or list available underlyings, on a
      pyth_value subscription
    type: receive
    messages:
      - &ref_28
        id: pythUpdateSubscriptionCommand
        contentType: application/json
        payload:
          - name: Update Subscription - Pyth Underlyings
            description: >-
              Add or remove underlying tickers, or list available underlyings,
              on a pyth_value subscription
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: cmd
                type: string
                description: update_subscription
                required: true
              - name: params
                type: object
                required: true
                properties:
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: false
                  - name: sids
                    type: array
                    description: >-
                      Array containing exactly one subscription ID (alternative
                      to sid)
                    required: false
                    properties:
                      - name: item
                        type: integer
                        description: >-
                          Server-generated subscription identifier (sid) used to
                          identify the channel
                        required: false
                  - name: action
                    type: string
                    description: >
                      - `subscribe_underlyings`: add the supplied
                      `underlying_tickers`

                      - `unsubscribe_underlyings`: remove the supplied
                      `underlying_tickers`

                      - `underlying_list`: return recently streamed underlying
                      tickers
                    enumValues:
                      - subscribe_underlyings
                      - unsubscribe_underlyings
                      - underlying_list
                    required: true
                  - name: underlying_tickers
                    type: array
                    description: >-
                      Pyth underlyings to add or remove. Use ["all"] to track
                      every available underlying.
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: *ref_1
            cmd:
              type: string
              const: update_subscription
              x-parser-schema-id: <anonymous-schema-36>
            params:
              type: object
              required:
                - action
              properties:
                sid: *ref_3
                sids:
                  type: array
                  description: >-
                    Array containing exactly one subscription ID (alternative to
                    sid)
                  items: *ref_3
                  minItems: 1
                  maxItems: 1
                  x-parser-schema-id: <anonymous-schema-38>
                action:
                  type: string
                  description: >
                    - `subscribe_underlyings`: add the supplied
                    `underlying_tickers`

                    - `unsubscribe_underlyings`: remove the supplied
                    `underlying_tickers`

                    - `underlying_list`: return recently streamed underlying
                    tickers
                  enum:
                    - subscribe_underlyings
                    - unsubscribe_underlyings
                    - underlying_list
                  x-parser-schema-id: <anonymous-schema-39>
                underlying_tickers:
                  type: array
                  description: >-
                    Pyth underlyings to add or remove. Use ["all"] to track
                    every available underlying.
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-41>
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-40>
              x-parser-schema-id: <anonymous-schema-37>
          x-parser-schema-id: pythUpdateSubscriptionCommandPayload
        title: Update Subscription - Pyth Underlyings
        description: >-
          Add or remove underlying tickers, or list available underlyings, on a
          pyth_value subscription
        example: |-
          {
            "id": 2,
            "cmd": "update_subscription",
            "params": {
              "sid": 1,
              "action": "underlying_list"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: pythUpdateSubscriptionCommand
    bindings: []
    extensions: *ref_2
  - &ref_16
    id: receiveSubscribed
    title: Subscription Confirmed
    description: Receive confirmation that subscription was successful
    type: send
    messages:
      - &ref_29
        id: subscribedResponse
        contentType: application/json
        payload:
          - name: Subscribed Response
            description: Confirmation that subscription was successful
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: false
              - name: type
                type: string
                description: subscribed
                required: true
              - name: msg
                type: object
                required: true
                properties:
                  - name: channel
                    type: string
                    required: true
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - msg
          properties:
            id: *ref_1
            type:
              type: string
              const: subscribed
              x-parser-schema-id: <anonymous-schema-43>
            msg:
              type: object
              required:
                - channel
                - sid
              properties:
                channel:
                  type: string
                  x-parser-schema-id: <anonymous-schema-45>
                sid: *ref_3
              x-parser-schema-id: <anonymous-schema-44>
          x-parser-schema-id: subscribedResponsePayload
        title: Subscribed Response
        description: Confirmation that subscription was successful
        example: |-
          {
            "id": 1,
            "type": "subscribed",
            "msg": {
              "channel": "orderbook_delta",
              "sid": 1
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribedResponse
    bindings: []
    extensions: *ref_2
  - &ref_17
    id: receiveUnsubscribed
    title: Unsubscription Confirmed
    description: Receive confirmation that unsubscription was successful
    type: send
    messages:
      - &ref_30
        id: unsubscribedResponse
        contentType: application/json
        payload:
          - name: Unsubscribed Response
            description: Confirmation that unsubscription was successful
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: false
              - name: sid
                type: integer
                description: >-
                  Server-generated subscription identifier (sid) used to
                  identify the channel
                required: true
              - name: seq
                type: integer
                description: >-
                  Sequential number that should be checked if you want to
                  guarantee you received all the messages. Used for
                  snapshot/delta consistency
                required: true
              - name: type
                type: string
                description: unsubscribed
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - sid
            - seq
            - type
          properties:
            id: *ref_1
            sid: *ref_3
            seq: &ref_7
              type: integer
              description: >-
                Sequential number that should be checked if you want to
                guarantee you received all the messages. Used for snapshot/delta
                consistency
              minimum: 1
              x-parser-schema-id: sequenceNumber
            type:
              type: string
              const: unsubscribed
              x-parser-schema-id: <anonymous-schema-50>
          x-parser-schema-id: unsubscribedResponsePayload
        title: Unsubscribed Response
        description: Confirmation that unsubscription was successful
        example: |-
          {
            "id": 102,
            "sid": 2,
            "seq": 7,
            "type": "unsubscribed"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribedResponse
    bindings: []
    extensions: *ref_2
  - &ref_18
    id: receiveOk
    title: Update Confirmed
    description: Receive confirmation that subscription update was successful
    type: send
    messages:
      - &ref_31
        id: okResponse
        contentType: application/json
        payload:
          - name: OK Response
            description: Successful update operation response
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: false
              - name: sid
                type: integer
                description: >-
                  Server-generated subscription identifier (sid) used to
                  identify the channel
                required: false
              - name: seq
                type: integer
                description: >-
                  Sequential number that should be checked if you want to
                  guarantee you received all the messages. Used for
                  snapshot/delta consistency
                required: false
              - name: type
                type: string
                description: ok
                required: true
              - name: msg
                type: object
                required: false
                properties:
                  - name: market_tickers
                    type: array
                    description: Full list of market tickers after update
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        examples: *ref_0
                        required: false
                  - name: market_ids
                    type: array
                    description: Full list of market IDs after update
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market UUID
                        required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            id: *ref_1
            sid: *ref_3
            seq: *ref_7
            type:
              type: string
              const: ok
              x-parser-schema-id: <anonymous-schema-51>
            msg:
              type: object
              properties:
                market_tickers:
                  type: array
                  description: Full list of market tickers after update
                  items: *ref_4
                  x-parser-schema-id: <anonymous-schema-53>
                market_ids:
                  type: array
                  description: Full list of market IDs after update
                  items: *ref_5
                  x-parser-schema-id: <anonymous-schema-54>
              x-parser-schema-id: <anonymous-schema-52>
          x-parser-schema-id: okResponsePayload
        title: OK Response
        description: Successful update operation response
        example: |-
          {
            "id": 123,
            "sid": 456,
            "seq": 222,
            "type": "ok",
            "msg": {
              "market_tickers": [
                "MARKET-1",
                "MARKET-2",
                "MARKET-3"
              ]
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: okResponse
    bindings: []
    extensions: *ref_2
  - &ref_19
    id: receiveListSubscriptions
    title: List Subscriptions Response
    description: Receive list of all active subscriptions
    type: send
    messages:
      - &ref_32
        id: listSubscriptionsResponse
        contentType: application/json
        payload:
          - name: List Subscriptions Response
            description: Response containing all active subscriptions
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: true
              - name: type
                type: string
                description: ok
                required: true
              - name: msg
                type: array
                description: List of active subscriptions
                required: true
                properties:
                  - name: channel
                    type: string
                    description: Name of the subscribed channel
                    required: true
                  - name: sid
                    type: integer
                    description: >-
                      Server-generated subscription identifier (sid) used to
                      identify the channel
                    required: true
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - type
            - msg
          properties:
            id: *ref_1
            type:
              type: string
              const: ok
              x-parser-schema-id: <anonymous-schema-46>
            msg:
              type: array
              description: List of active subscriptions
              items:
                type: object
                required:
                  - channel
                  - sid
                properties:
                  channel:
                    type: string
                    description: Name of the subscribed channel
                    x-parser-schema-id: <anonymous-schema-49>
                  sid: *ref_3
                x-parser-schema-id: <anonymous-schema-48>
              x-parser-schema-id: <anonymous-schema-47>
          x-parser-schema-id: listSubscriptionsResponsePayload
        title: List Subscriptions Response
        description: Response containing all active subscriptions
        example: |-
          {
            "id": 3,
            "type": "ok",
            "msg": [
              {
                "channel": "orderbook_delta",
                "sid": 1
              },
              {
                "channel": "ticker",
                "sid": 2
              },
              {
                "channel": "fill",
                "sid": 3
              }
            ]
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: listSubscriptionsResponse
    bindings: []
    extensions: *ref_2
  - &ref_20
    id: receiveError
    title: Error Response
    description: Receive error message when a command fails
    type: send
    messages:
      - &ref_33
        id: errorResponse
        contentType: application/json
        payload:
          - name: Error Response
            description: Error response for failed operations
            type: object
            properties:
              - name: id
                type: integer
                description: >
                  Unique ID of the command request. Generated by the client and
                  should be unique within a WS session.

                  The simplest way to use it would be to start from 1 and then
                  increment the value for every new command sent to the server.

                  If the id is set to 0, the server treats it the same way as if
                  there was no id.
                required: false
              - name: type
                type: string
                description: error
                required: true
              - name: msg
                type: object
                required: true
                properties:
                  - name: code
                    type: integer
                    description: >
                      Error code identifying the type of error:

                      - 1: Unable to process message - General processing error

                      - 2: Params required - Missing params object in command

                      - 3: Channels required - Missing channels array in
                      subscribe

                      - 4: Subscription IDs required - Missing sids in
                      unsubscribe

                      - 5: Unknown command - Invalid command name

                      - 6: Already subscribed - Duplicate subscription attempt

                      - 7: Unknown subscription ID - Subscription ID not found

                      - 8: Unknown channel name - Invalid channel in subscribe

                      - 9: Authentication required - Channel requires
                      authenticated connection

                      - 10: Channel error - Channel-specific error

                      - 11: Invalid parameter - Malformed parameter value

                      - 12: Exactly one subscription ID is required - For
                      update_subscription

                      - 13: Unsupported action - Invalid action for
                      update_subscription

                      - 14: Market Ticker required - Missing market
                      specification (market_ticker or market_id)

                      - 15: Action required - Missing action in
                      update_subscription

                      - 16: Market not found - Invalid market_ticker or
                      market_id

                      - 17: Internal error - Server-side processing error

                      - 18: Command timeout - Server timed out while processing
                      command

                      - 19: shard_factor must be > 0 - Invalid shard_factor

                      - 20: shard_factor is required when shard_key is set -
                      Missing shard_factor when shard_key is set

                      - 21: shard_key must be >= 0 and < shard_factor - Invalid
                      shard_key

                      - 22: shard_factor must be <= 100 - shard_factor too large

                      - 23: Match IDs required - Missing match_ids for the
                      channel/action

                      - 24: Index IDs required - Missing index_ids for
                      subscribe_indices/unsubscribe_indices on
                      cfbenchmarks_value

                      - 25: Subscription buffer overflow - The subscription's
                      outbound buffer was exceeded

                      - 26: Subscription market limit exceeded - Adding markets
                      would exceed the per-subscription market limit

                      - 27: Too many requests - The subscription exceeded its
                      command rate limit

                      - 28: Underlying tickers required - Missing
                      underlying_tickers for
                      subscribe_underlyings/unsubscribe_underlyings on
                      pyth_value
                    required: true
                  - name: msg
                    type: string
                    description: Human-readable error message
                    required: true
                  - name: market_id
                    type: string
                    description: Market UUID if error is market-specific (optional)
                    required: false
                  - name: market_ticker
                    type: string
                    description: Market ticker if error is market-specific (optional)
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - msg
          properties:
            id: *ref_1
            type:
              type: string
              const: error
              x-parser-schema-id: <anonymous-schema-55>
            msg:
              type: object
              required:
                - code
                - msg
              properties:
                code:
                  type: integer
                  description: >
                    Error code identifying the type of error:

                    - 1: Unable to process message - General processing error

                    - 2: Params required - Missing params object in command

                    - 3: Channels required - Missing channels array in subscribe

                    - 4: Subscription IDs required - Missing sids in unsubscribe

                    - 5: Unknown command - Invalid command name

                    - 6: Already subscribed - Duplicate subscription attempt

                    - 7: Unknown subscription ID - Subscription ID not found

                    - 8: Unknown channel name - Invalid channel in subscribe

                    - 9: Authentication required - Channel requires
                    authenticated connection

                    - 10: Channel error - Channel-specific error

                    - 11: Invalid parameter - Malformed parameter value

                    - 12: Exactly one subscription ID is required - For
                    update_subscription

                    - 13: Unsupported action - Invalid action for
                    update_subscription

                    - 14: Market Ticker required - Missing market specification
                    (market_ticker or market_id)

                    - 15: Action required - Missing action in
                    update_subscription

                    - 16: Market not found - Invalid market_ticker or market_id

                    - 17: Internal error - Server-side processing error

                    - 18: Command timeout - Server timed out while processing
                    command

                    - 19: shard_factor must be > 0 - Invalid shard_factor

                    - 20: shard_factor is required when shard_key is set -
                    Missing shard_factor when shard_key is set

                    - 21: shard_key must be >= 0 and < shard_factor - Invalid
                    shard_key

                    - 22: shard_factor must be <= 100 - shard_factor too large

                    - 23: Match IDs required - Missing match_ids for the
                    channel/action

                    - 24: Index IDs required - Missing index_ids for
                    subscribe_indices/unsubscribe_indices on cfbenchmarks_value

                    - 25: Subscription buffer overflow - The subscription's
                    outbound buffer was exceeded

                    - 26: Subscription market limit exceeded - Adding markets
                    would exceed the per-subscription market limit

                    - 27: Too many requests - The subscription exceeded its
                    command rate limit

                    - 28: Underlying tickers required - Missing
                    underlying_tickers for
                    subscribe_underlyings/unsubscribe_underlyings on pyth_value
                  minimum: 1
                  maximum: 28
                  x-parser-schema-id: <anonymous-schema-57>
                msg:
                  type: string
                  description: Human-readable error message
                  x-parser-schema-id: <anonymous-schema-58>
                market_id:
                  type: string
                  description: Market UUID if error is market-specific (optional)
                  x-parser-schema-id: <anonymous-schema-59>
                market_ticker:
                  type: string
                  description: Market ticker if error is market-specific (optional)
                  x-parser-schema-id: <anonymous-schema-60>
              x-parser-schema-id: <anonymous-schema-56>
          x-parser-schema-id: errorResponsePayload
        title: Error Response
        description: Error response for failed operations
        example: |-
          {
            "id": 123,
            "type": "error",
            "msg": {
              "code": 6,
              "msg": "Already subscribed"
            }
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: errorResponse
    bindings: []
    extensions: *ref_2
sendOperations:
  - *ref_8
  - *ref_9
  - *ref_10
  - *ref_11
  - *ref_12
  - *ref_13
  - *ref_14
  - *ref_15
receiveOperations:
  - *ref_16
  - *ref_17
  - *ref_18
  - *ref_19
  - *ref_20
sendMessages:
  - *ref_21
  - *ref_22
  - *ref_23
  - *ref_24
  - *ref_25
  - *ref_26
  - *ref_27
  - *ref_28
receiveMessages:
  - *ref_29
  - *ref_30
  - *ref_31
  - *ref_32
  - *ref_33
extensions:
  - id: x-parser-unique-object-id
    value: root
securitySchemes:
  - id: apiKey
    name: apiKey
    type: apiKey
    description: |
      API key authentication required for WebSocket connections.
      The API key should be provided during the WebSocket handshake.
    in: user
    extensions: []

````