> ## 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.

# Orderbook Updates

> Real-time margin orderbook price-level changes.

Requirements:
- authenticated connection
- market specification required via `market_ticker` or `market_tickers`
- sends `orderbook_snapshot` first, then incremental `orderbook_delta` updates
- supports `get_snapshot` on `update_subscription` to request a fresh snapshot without changing the subscription




## AsyncAPI

````yaml perps_asyncapi.yaml orderbook_delta
id: orderbook_delta
title: Orderbook Updates
description: >
  Real-time margin orderbook price-level changes.


  Requirements:

  - authenticated connection

  - market specification required via `market_ticker` or `market_tickers`

  - sends `orderbook_snapshot` first, then incremental `orderbook_delta` updates

  - supports `get_snapshot` on `update_subscription` to request a fresh snapshot
  without changing the subscription
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: orderbook_delta
parameters: []
bindings: []
operations:
  - &ref_6
    id: receiveOrderbookSnapshot
    title: Orderbook Snapshot
    type: send
    messages:
      - &ref_8
        id: orderbookSnapshot
        contentType: application/json
        payload:
          - name: Orderbook Snapshot
            description: Complete view of the margin order book's aggregated price levels
            type: object
            properties:
              - name: type
                type: string
                description: orderbook_snapshot
                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: msg
                type: object
                required: true
                properties:
                  - name: market_ticker
                    type: string
                    description: Unique market identifier
                    required: true
                  - name: bid
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: array
                        description: '[price_in_dollars, contract_count_fp]'
                        required: false
                        properties:
                          - name: item
                            type: string
                            required: false
                  - name: ask
                    type: array
                    required: false
                    properties:
                      - name: item
                        type: array
                        description: '[price_in_dollars, contract_count_fp]'
                        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
            - sid
            - seq
            - msg
          properties:
            type:
              type: string
              const: orderbook_snapshot
              x-parser-schema-id: <anonymous-schema-43>
            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.
              minimum: 0
              x-parser-schema-id: commandId
            sid: &ref_1
              type: integer
              description: >-
                Server-generated subscription identifier (sid) used to identify
                the channel
              minimum: 1
              x-parser-schema-id: subscriptionId
            seq: &ref_2
              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
            msg:
              type: object
              required:
                - market_ticker
              properties:
                market_ticker: &ref_3
                  type: string
                  description: Unique market identifier
                  x-parser-schema-id: marketTicker
                bid:
                  type: array
                  items: &ref_0
                    type: array
                    items:
                      type: string
                      x-parser-schema-id: <anonymous-schema-46>
                    minItems: 2
                    maxItems: 2
                    description: '[price_in_dollars, contract_count_fp]'
                    x-parser-schema-id: priceLevelDollarsCountFp
                  x-parser-schema-id: <anonymous-schema-45>
                ask:
                  type: array
                  items: *ref_0
                  x-parser-schema-id: <anonymous-schema-47>
              x-parser-schema-id: <anonymous-schema-44>
            sending_ts_ms: &ref_4
              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: marginOrderbookSnapshotPayload
        title: Orderbook Snapshot
        description: Complete view of the margin order book's aggregated price levels
        example: No examples found
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderbookSnapshot
    bindings: []
    extensions: &ref_5
      - id: x-parser-unique-object-id
        value: orderbook_delta
  - &ref_7
    id: receiveOrderbookDelta
    title: Orderbook Delta
    type: send
    messages:
      - &ref_9
        id: orderbookDelta
        contentType: application/json
        payload:
          - name: Orderbook Delta
            description: Update to be applied to the current margin order book view
            type: object
            properties:
              - name: type
                type: string
                description: orderbook_delta
                required: true
              - 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: msg
                type: object
                required: true
                properties:
                  - name: market_ticker
                    type: string
                    description: Unique market identifier
                    required: true
                  - name: price
                    type: string
                    required: true
                  - name: delta
                    type: string
                    required: true
                  - name: side
                    type: string
                    enumValues:
                      - bid
                      - ask
                    required: true
                  - name: last_update_reason
                    type: string
                    description: >-
                      Margin order update reason. The value ReduceOnlyCancel
                      means reduce_only capped the order at placement. The field
                      is omitted when no reason applies.
                    enumValues:
                      - Decrease
                      - Amend
                      - MarginCancel
                      - SelfTradeCancel
                      - ExpiryCancel
                      - CloseCancel
                      - HaltCancel
                      - Trade
                      - PostOnlyCrossCancel
                      - ReduceOnlyCancel
                    required: false
                  - name: client_order_id
                    type: string
                    required: false
                  - name: ts_ms
                    type: integer
                    description: Unix timestamp in milliseconds.
                    required: false
                  - name: subaccount
                    type: integer
                    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
            - sid
            - seq
            - msg
          properties:
            type:
              type: string
              const: orderbook_delta
              x-parser-schema-id: <anonymous-schema-48>
            sid: *ref_1
            seq: *ref_2
            msg:
              type: object
              required:
                - market_ticker
                - price
                - delta
                - side
              properties:
                market_ticker: *ref_3
                price:
                  type: string
                  x-rust-type: common::types::Price
                  x-rust-serialize-with: ws::dto::serde_money::serialize_price_dollars
                  x-parser-schema-id: <anonymous-schema-50>
                delta:
                  type: string
                  x-rust-type: i64
                  x-rust-serialize-with: ws::dto::serde_money::serialize_centicount_fixed_point_count
                  x-parser-schema-id: <anonymous-schema-51>
                side:
                  type: string
                  enum:
                    - bid
                    - ask
                  x-parser-schema-id: bookSide
                last_update_reason:
                  type: string
                  enum:
                    - Decrease
                    - Amend
                    - MarginCancel
                    - SelfTradeCancel
                    - ExpiryCancel
                    - CloseCancel
                    - HaltCancel
                    - Trade
                    - PostOnlyCrossCancel
                    - ReduceOnlyCancel
                  description: >-
                    Margin order update reason. The value ReduceOnlyCancel means
                    reduce_only capped the order at placement. The field is
                    omitted when no reason applies.
                  x-parser-schema-id: lastUpdateReason
                client_order_id:
                  type: string
                  x-parser-schema-id: <anonymous-schema-52>
                ts_ms:
                  type: integer
                  format: int64
                  description: Unix timestamp in milliseconds.
                  x-parser-schema-id: <anonymous-schema-53>
                subaccount:
                  type: integer
                  x-parser-schema-id: <anonymous-schema-54>
              x-parser-schema-id: <anonymous-schema-49>
            sending_ts_ms: *ref_4
          x-parser-schema-id: marginOrderbookDeltaPayload
        title: Orderbook Delta
        description: Update to be applied to the current margin order book view
        example: |-
          {
            "type": "<string>",
            "sid": 123,
            "seq": 123,
            "msg": {
              "market_ticker": "<string>",
              "price": "<string>",
              "delta": "<string>",
              "side": "<string>",
              "last_update_reason": "<string>",
              "client_order_id": "<string>",
              "ts_ms": 123,
              "subaccount": 123
            },
            "sending_ts_ms": 123
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: orderbookDelta
    bindings: []
    extensions: *ref_5
sendOperations: []
receiveOperations:
  - *ref_6
  - *ref_7
sendMessages: []
receiveMessages:
  - *ref_8
  - *ref_9
extensions:
  - id: x-parser-unique-object-id
    value: orderbook_delta
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.