> ## 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.
Authentication is required during the WebSocket handshake.




## AsyncAPI

````yaml perps_asyncapi.yaml root
id: root
title: WebSocket Connection
description: |
  Main WebSocket connection endpoint.
  Authentication is required during the WebSocket handshake.
servers:
  - id: production
    protocol: wss
    host: external-api-margin-ws.kalshi.com
    bindings: []
    variables: []
  - id: demo
    protocol: wss
    host: external-api-margin-ws.demo.kalshi.co
    bindings: []
    variables: []
address: /
parameters: []
bindings:
  - protocol: ws
    version: latest
    value:
      method: GET
    schemaProperties:
      - name: method
        type: string
        description: GET
        required: false
operations:
  - &ref_7
    id: sendSubscribe
    title: Subscribe to Channels
    type: receive
    messages:
      - &ref_18
        id: subscribeCommand
        contentType: application/json
        payload:
          - name: Subscribe Command
            description: Subscribe to one or more margin 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
                    required: true
                    properties:
                      - name: item
                        type: string
                        enumValues:
                          - orderbook_delta
                          - ticker
                          - trade
                          - fill
                          - user_orders
                          - order_group_updates
                          - corporate_actions
                        required: false
                  - name: market_ticker
                    type: string
                    required: false
                  - name: market_tickers
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: Sends an initial snapshot for ticker subscriptions.
                    required: false
                  - name: skip_ticker_ack
                    type: boolean
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: &ref_0
              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
                  minItems: 1
                  items:
                    type: string
                    enum:
                      - orderbook_delta
                      - ticker
                      - trade
                      - fill
                      - user_orders
                      - order_group_updates
                      - corporate_actions
                    x-parser-schema-id: <anonymous-schema-4>
                  x-parser-schema-id: <anonymous-schema-3>
                market_ticker:
                  type: string
                  x-parser-schema-id: <anonymous-schema-5>
                market_tickers:
                  type: array
                  items: &ref_3
                    type: string
                    description: Unique market identifier
                    x-parser-schema-id: marketTicker
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-6>
                send_initial_snapshot:
                  type: boolean
                  description: Sends an initial snapshot for ticker subscriptions.
                  default: false
                  x-parser-schema-id: <anonymous-schema-7>
                skip_ticker_ack:
                  type: boolean
                  default: false
                  x-parser-schema-id: <anonymous-schema-8>
              x-parser-schema-id: <anonymous-schema-2>
          x-parser-schema-id: subscribeCommandPayload
        title: Subscribe Command
        description: Subscribe to one or more margin channels
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribeCommand
    bindings: []
    extensions: &ref_1
      - id: x-parser-unique-object-id
        value: root
  - &ref_8
    id: sendUnsubscribe
    title: Unsubscribe from Channels
    type: receive
    messages:
      - &ref_19
        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_0
            cmd:
              type: string
              const: unsubscribe
              x-parser-schema-id: <anonymous-schema-9>
            params:
              type: object
              required:
                - sids
              properties:
                sids:
                  type: array
                  description: List of subscription IDs to cancel
                  items: &ref_2
                    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-11>
              x-parser-schema-id: <anonymous-schema-10>
          x-parser-schema-id: unsubscribeCommandPayload
        title: Unsubscribe Command
        description: Cancel one or more subscriptions
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribeCommand
    bindings: []
    extensions: *ref_1
  - &ref_9
    id: sendListSubscriptions
    title: List Subscriptions
    type: receive
    messages:
      - &ref_20
        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_0
            cmd:
              type: string
              const: list_subscriptions
              x-parser-schema-id: <anonymous-schema-19>
          x-parser-schema-id: listSubscriptionsCommandPayload
        title: List Subscriptions Command
        description: List all active subscriptions
        example: |-
          {
            "id": 123,
            "cmd": "<string>"
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: listSubscriptionsCommand
    bindings: []
    extensions: *ref_1
  - &ref_10
    id: sendUpdateSubscription
    title: Update Subscription - Add Markets
    type: receive
    messages:
      - &ref_21
        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
                    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
                    required: false
                  - name: market_tickers
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      Sends an initial snapshot for newly added ticker
                      subscriptions.
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: &ref_4
          type: object
          required:
            - id
            - cmd
            - params
          properties:
            id: *ref_0
            cmd:
              type: string
              const: update_subscription
              x-parser-schema-id: <anonymous-schema-12>
            params:
              type: object
              required:
                - action
              properties:
                sid: *ref_2
                sids:
                  type: array
                  items: *ref_2
                  minItems: 1
                  maxItems: 1
                  x-parser-schema-id: <anonymous-schema-14>
                market_ticker:
                  type: string
                  x-parser-schema-id: <anonymous-schema-15>
                market_tickers:
                  type: array
                  items: *ref_3
                  minItems: 1
                  x-parser-schema-id: <anonymous-schema-16>
                send_initial_snapshot:
                  type: boolean
                  description: >-
                    Sends an initial snapshot for newly added ticker
                    subscriptions.
                  default: false
                  x-parser-schema-id: <anonymous-schema-17>
                action:
                  type: string
                  enum:
                    - add_markets
                    - delete_markets
                    - get_snapshot
                  x-parser-schema-id: <anonymous-schema-18>
              x-parser-schema-id: <anonymous-schema-13>
          x-parser-schema-id: updateSubscriptionCommandPayload
        title: Update Subscription - Add Markets
        description: Add markets to an existing subscription
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionCommand
    bindings: []
    extensions: *ref_1
  - &ref_11
    id: sendUpdateSubscriptionDelete
    title: Update Subscription - Delete Markets
    type: receive
    messages:
      - &ref_22
        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
                    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
                    required: false
                  - name: market_tickers
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      Sends an initial snapshot for newly added ticker
                      subscriptions.
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: *ref_4
        title: Update Subscription - Delete Markets
        description: Remove markets from an existing subscription
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionDeleteCommand
    bindings: []
    extensions: *ref_1
  - &ref_12
    id: sendUpdateSubscriptionSingleSid
    title: Update Subscription - Single SID
    type: receive
    messages:
      - &ref_23
        id: updateSubscriptionSingleSidCommand
        contentType: application/json
        payload:
          - name: Update Subscription - Single SID
            description: Update a subscription using `sid` rather than `sids`
            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
                    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
                    required: false
                  - name: market_tickers
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: string
                        description: Unique market identifier
                        required: false
                  - name: send_initial_snapshot
                    type: boolean
                    description: >-
                      Sends an initial snapshot for newly added ticker
                      subscriptions.
                    required: false
                  - name: action
                    type: string
                    enumValues:
                      - add_markets
                      - delete_markets
                      - get_snapshot
                    required: true
        headers: []
        jsonPayloadSchema: *ref_4
        title: Update Subscription - Single SID
        description: Update a subscription using `sid` rather than `sids`
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: updateSubscriptionSingleSidCommand
    bindings: []
    extensions: *ref_1
  - &ref_13
    id: receiveSubscribed
    title: Subscription Confirmed
    type: send
    messages:
      - &ref_24
        id: subscribedResponse
        contentType: application/json
        payload:
          - name: Subscribed Response
            description: Confirmation that subscription was successful
            type: object
            properties:
              - name: type
                type: string
                description: subscribed
                required: true
              - 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: 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
              - name: sending_ts_ms
                type: integer
                description: >-
                  Unix timestamp in milliseconds when Kalshi queued this message
                  at the network layer.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - msg
          properties:
            type:
              type: string
              const: subscribed
              x-parser-schema-id: <anonymous-schema-20>
            id: *ref_0
            msg:
              type: object
              required:
                - channel
                - sid
              properties:
                channel:
                  type: string
                  x-parser-schema-id: <anonymous-schema-22>
                sid: *ref_2
              x-parser-schema-id: <anonymous-schema-21>
            sending_ts_ms: &ref_5
              type: integer
              format: int64
              description: >-
                Unix timestamp in milliseconds when Kalshi queued this message
                at the network layer.
              x-parser-schema-id: sendingTimestampMs
          x-parser-schema-id: subscribedResponsePayload
        title: Subscribed Response
        description: Confirmation that subscription was successful
        example: |-
          {
            "type": "<string>",
            "id": 123,
            "msg": {
              "channel": "<string>",
              "sid": 123
            },
            "sending_ts_ms": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: subscribedResponse
    bindings: []
    extensions: *ref_1
  - &ref_14
    id: receiveUnsubscribed
    title: Unsubscription Confirmed
    type: send
    messages:
      - &ref_25
        id: unsubscribedResponse
        contentType: application/json
        payload:
          - name: Unsubscribed Response
            description: Confirmation that unsubscription was successful
            type: object
            properties:
              - name: type
                type: string
                description: unsubscribed
                required: true
              - 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: sending_ts_ms
                type: integer
                description: >-
                  Unix timestamp in milliseconds when Kalshi queued this message
                  at the network layer.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - sid
            - seq
            - type
          properties:
            type:
              type: string
              const: unsubscribed
              x-parser-schema-id: <anonymous-schema-23>
            id: *ref_0
            sid: *ref_2
            seq: &ref_6
              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
            sending_ts_ms: *ref_5
          x-parser-schema-id: unsubscribedResponsePayload
        title: Unsubscribed Response
        description: Confirmation that unsubscription was successful
        example: |-
          {
            "type": "<string>",
            "id": 123,
            "sid": 123,
            "seq": 123,
            "sending_ts_ms": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: unsubscribedResponse
    bindings: []
    extensions: *ref_1
  - &ref_15
    id: receiveOk
    title: Update Confirmed
    type: send
    messages:
      - &ref_26
        id: okResponse
        contentType: application/json
        payload:
          - name: OK Response
            description: Successful update operation response
            type: object
            properties:
              - name: type
                type: string
                description: ok
                required: true
              - 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: 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
                        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
              - name: sending_ts_ms
                type: integer
                description: >-
                  Unix timestamp in milliseconds when Kalshi queued this message
                  at the network layer.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: ok
              x-parser-schema-id: <anonymous-schema-24>
            id: *ref_0
            sid: *ref_2
            seq: *ref_6
            msg:
              type: object
              properties:
                market_tickers:
                  type: array
                  description: Full list of market tickers after update
                  items: *ref_3
                  x-parser-schema-id: <anonymous-schema-26>
                market_ids:
                  type: array
                  description: Full list of market IDs after update
                  items:
                    type: string
                    description: Unique market UUID
                    format: uuid
                    x-parser-schema-id: marketId
                  x-parser-schema-id: <anonymous-schema-27>
              x-parser-schema-id: <anonymous-schema-25>
            sending_ts_ms: *ref_5
          x-parser-schema-id: okResponsePayload
        title: OK Response
        description: Successful update operation response
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: okResponse
    bindings: []
    extensions: *ref_1
  - &ref_16
    id: receiveListSubscriptions
    title: List Subscriptions Response
    type: send
    messages:
      - &ref_27
        id: listSubscriptionsResponse
        contentType: application/json
        payload:
          - name: List Subscriptions Response
            description: Response containing all active subscriptions
            type: object
            properties:
              - name: type
                type: string
                description: ok
                required: true
              - 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: 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
              - name: sending_ts_ms
                type: integer
                description: >-
                  Unix timestamp in milliseconds when Kalshi queued this message
                  at the network layer.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - msg
          properties:
            type:
              type: string
              const: ok
              x-parser-schema-id: <anonymous-schema-28>
            id: *ref_0
            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-31>
                  sid: *ref_2
                x-parser-schema-id: <anonymous-schema-30>
              x-parser-schema-id: <anonymous-schema-29>
            sending_ts_ms: *ref_5
          x-parser-schema-id: listSubscriptionsResponsePayload
        title: List Subscriptions Response
        description: Response containing all active subscriptions
        example: |-
          {
            "type": "<string>",
            "id": 123,
            "msg": {
              "channel": "<string>",
              "sid": 123
            },
            "sending_ts_ms": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: listSubscriptionsResponse
    bindings: []
    extensions: *ref_1
  - &ref_17
    id: receiveError
    title: Error Response
    type: send
    messages:
      - &ref_28
        id: errorResponse
        contentType: application/json
        payload:
          - name: Error Response
            description: Error response for failed operations
            type: object
            properties:
              - name: type
                type: string
                description: error
                required: true
              - 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: msg
                type: object
                required: true
                properties:
                  - name: code
                    type: integer
                    description: >
                      Error codes the Margin WebSocket endpoint can emit.

                      Numbering is shared with the Predictions WebSocket API, so
                      the list is

                      not contiguous. Codes 23, 24, and 28 are used only on
                      channels

                      outside the public Margin surface. Codes 6, 16, and 17 are

                      retired; the service no longer emits them and their
                      numbers

                      stay reserved.
                    enumValues:
                      - 1
                      - 2
                      - 3
                      - 4
                      - 5
                      - 7
                      - 8
                      - 9
                      - 10
                      - 11
                      - 12
                      - 13
                      - 14
                      - 15
                      - 18
                      - 23
                      - 24
                      - 25
                      - 26
                      - 27
                      - 28
                    required: true
                  - name: msg
                    type: string
                    required: true
                  - name: market_ticker
                    type: string
                    description: Optional market ticker associated with the error
                    required: false
                  - name: market_tickers
                    type: array
                    description: Optional market tickers associated with the error
                    required: false
                    properties:
                      - name: item
                        type: string
                        required: false
              - name: sending_ts_ms
                type: integer
                description: >-
                  Unix timestamp in milliseconds when Kalshi queued this message
                  at the network layer.
                required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - type
            - msg
          properties:
            type:
              type: string
              const: error
              x-parser-schema-id: <anonymous-schema-32>
            id: *ref_0
            sid: *ref_2
            seq: *ref_6
            msg:
              type: object
              required:
                - code
                - msg
              properties:
                code:
                  type: integer
                  description: >
                    Error codes the Margin WebSocket endpoint can emit.

                    Numbering is shared with the Predictions WebSocket API, so
                    the list is

                    not contiguous. Codes 23, 24, and 28 are used only on
                    channels

                    outside the public Margin surface. Codes 6, 16, and 17 are

                    retired; the service no longer emits them and their numbers

                    stay reserved.
                  enum:
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                    - 7
                    - 8
                    - 9
                    - 10
                    - 11
                    - 12
                    - 13
                    - 14
                    - 15
                    - 18
                    - 23
                    - 24
                    - 25
                    - 26
                    - 27
                    - 28
                  x-parser-schema-id: <anonymous-schema-34>
                msg:
                  type: string
                  x-parser-schema-id: <anonymous-schema-35>
                market_ticker:
                  type: string
                  description: Optional market ticker associated with the error
                  x-parser-schema-id: <anonymous-schema-36>
                market_tickers:
                  type: array
                  description: Optional market tickers associated with the error
                  items:
                    type: string
                    x-parser-schema-id: <anonymous-schema-38>
                  x-parser-schema-id: <anonymous-schema-37>
              x-parser-schema-id: <anonymous-schema-33>
            sending_ts_ms: *ref_5
          x-parser-schema-id: errorResponsePayload
        title: Error Response
        description: Error response for failed operations
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: errorResponse
    bindings: []
    extensions: *ref_1
sendOperations:
  - *ref_7
  - *ref_8
  - *ref_9
  - *ref_10
  - *ref_11
  - *ref_12
receiveOperations:
  - *ref_13
  - *ref_14
  - *ref_15
  - *ref_16
  - *ref_17
sendMessages:
  - *ref_18
  - *ref_19
  - *ref_20
  - *ref_21
  - *ref_22
  - *ref_23
receiveMessages:
  - *ref_24
  - *ref_25
  - *ref_26
  - *ref_27
  - *ref_28
extensions:
  - id: x-parser-unique-object-id
    value: root
securitySchemes:
  - id: apiKey
    name: apiKey
    type: apiKey
    description: API key authentication required for margin WebSocket connections.
    in: user
    extensions: []

````

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