Connections and ports
Each enabled product has a dedicated SBE market-data listener and a dedicated SBE order-entry listener. The destination selects the encoding before Logon. Contact your institutional connectivity representative for the enabled hostname and port for each product, session type and network route.
To use market data and order entry together, open two bidirectional connections per product, each with its own authorized FIX key. Running both sessions on Predictions and Margin simultaneously uses four connections. The operating system normally selects the client source port. Each direction maintains its own FIX sequence on each connection.
For AWS PrivateLink or VPC peering, use the binary destination port assigned to that private route. Allow the outbound connection to that port and its return traffic. Keep the assigned Kalshi FIX hostname as the TLS server name even when dialing a private endpoint DNS name. Sign the binary Logon as described below. FIX connectivity
Framing
Each frame carries one session or application message. Read the six-byte framing header, validate its size, then read exactly the declared number of remaining bytes. Both client and gateway send binary frames from Logon onward. A frame is at most 2 MiB including its headers.
Session sequences start at 1 in each direction. Reserve 2147483647 for orderly logout. Reconnect and reconcile outstanding requests before sequence exhaustion. Strings have a little-endian uint32 byte length and UTF-8 bytes. Follow the fixed block and repeating-group declarations in the published schema.
On a live connection, a gap triggers ResendRequest (template 9). For example,
if the gateway expects sequence 26 and receives 28, it requests 26 through 27
and retains 28. Supply the missing messages, or send a SequenceReset gap fill
(template 8) at 26 with next sequence 28 for messages you deliberately skipped.
The gateway can then process 28. It closes an unresolved gap after twice the
negotiated heartbeat, capped at 120 seconds. A client request to resend missed
outbound messages receives a gap fill on this nonpersistent stream. Reconcile
uncertain orders and refresh the book on reconnect.
For example, this Heartbeat frame has sequence 2 and test request ID
abc:
Authentication
Select the profile assigned to the endpoint. The client principal is its canonical lowercase FIX API key UUID. Predictions and Margin share logical gateway names and have distinct signed profiles.
Encode the eight-byte fixed Logon block first. The reset flag must be 1. The heartbeat interval must be at least three seconds. The two option masks distinguish an omitted boolean from an explicitly supplied false. Enable only options declared for the profile in the XML. NR prices use fixed dollar units. On NR, set both the presence and enabled masks for option bit 0 to request cancel-on-disconnect. Omit it or explicitly set false to let resting orders retain their normal lifetime.
Clients generate encoders and decoders from the public XML and negotiate this exact version. Keep a decoder for each supported version. Incompatible layouts receive a new version or profile and a member notice before their serving endpoints change.
Use sequence 1 and a sending time aligned to a whole millisecond. Join the following strings with one SOH byte (
0x01) between fields and no trailing delimiter:
- Profile string
- Schema ID and version as two decimal strings
- UTC sending time in
YYYYMMDD-HH:MM:SS.mmmform A- Decimal session sequence (
1) - Canonical API key UUID
- Logical TargetCompID
- Lowercase SHA-256 hex digest of the exact eight option bytes
01 01 1e 00 00 00 00 00 and digest 4139006b015253ecac5de8d3a330979fb38f76bf1733a65fbf739cb63599a37f. Sign the resulting bytes with the registered Ed25519 key, or RSA-PSS with SHA-256. Send the base64 signature and both identities in template 1. Verify the profile and identities in template 2 before issuing application requests. A rejected Logon does not establish a session.
The downloadable Logon vectors include the exact signed bytes, public verification keys, signatures, and complete frames. One uses Ed25519 with omitted options and one uses RSA-PSS/SHA-256 with explicit option values. Download the v1 Logon vectors
Client examples
The Go and C++ initiators connect to the assigned MD TLS hostname, sign Logon with a local PEM file, verify the echoed profile, request a snapshot, and print its level count and best bid and offer. The output shows price in 1/10,000 USD and quantity in 1/100 contract. Both handle TestRequest and chunked snapshots. The examples accept Ed25519 or RSA-PSS credentials. Go source · C++ source Generate client codecs from the downloaded XML with Real Logic SBE 1.42.1 and Java 25. The build commands assume the downloaded examples and schema are in the current directory. The C++ example requires OpenSSL 3 or newer.predictions or margin). By default the client sends the destination hostname as TLS SNI and verifies it against the certificate. When dialing a private endpoint DNS name or IP address, pass the assigned Kalshi service hostname as the optional last argument. Both clients use it for SNI and certificate verification. Set KALSHI_FIX_CA_FILE to a trusted CA bundle when your assigned test endpoint requires one.
Market data
Use template 100 to request a snapshot, subscribe to updates, or unsubscribe. The optional feed selects bids, offers and trades. Books use absolute resulting sizes. A deletion means the price level has been removed. Apply all entries in template 102 in order, including any prints. Private order identity and subaccount fields are included only in the recipient’s authorized view. A trades-only subscription starts without a snapshot. Use template 101 as a replacement snapshot for the subscribed sides. For a larger ladder, buffer template 106 chunks belonging to the same snapshot, symbol and connection. Validate chunk index, declared total chunks, total levels and cursor. Apply the assembled ladder only after the final expected chunk arrives; discard incomplete snapshots on disconnect. Predictions’ optional MDExecID identifies an exchange position and can skip values. Margin omits it. Predictions supports security-status subscriptions through templates 104 and 105. Market data semanticsOrder entry
This binary profile covers ordinary order-book trading. For the optional settlement-report subscription (35=UMS) or accepting an RFQ quote by QuoteID, use the existing classic FIX sessions.
Predictions NR supports markets on the native Predictions shards. A request
for a Predictions market hosted on the Margin matcher is refused before order
placement with
UNSUPPORTED_FIX_ROUTE. Margin NR uses the native Margin matcher.
Ordinary new orders are limit orders. New, cancel, replace and market-scoped mass-cancel requests may select a customer account or a subaccount. Supplying both selectors on those requests is rejected. A session-scoped mass cancel uses the authenticated session and ignores both selectors. Preserve an explicitly supplied subaccount zero for market-scoped cancellation. Prices are in ten-thousandths of a US dollar. Order and fill quantities use hundredths of a contract. The order-group contractsLimit field uses whole contracts. Mass-cancel scope and response are ASCII FIX codes: market scope is byte 0x31 and session scope is byte 0x36. The market determines allowed tick and quantity increments. Average price carries a whole-dollar part and a signed fractional part at scale 10. Fees and collateral values use their schema-specific units. A pending report acknowledges processing. Use the exchange-confirmed new, replaced, canceled, rejected or fill report to decide the actual outcome. Order entry · Order groups
New, replace, cancel and mass-cancel requests require a nonempty clOrdId for response correlation. A single cancel or replace also requires origClOrdId for the order being changed, including a replacement that supplies an exchange orderId. On Predictions, a supplied maxExecutionCost must be positive. Leave execInst empty or send the exact single instruction 6 for post-only or E for reduce-only, subject to the product and time-in-force rules. For a standard limit new order, the matching engine rejects a GTD deadline at or before its processing time, before matching against resting liquidity. Send timeInForce='3' for immediate-or-cancel execution. A GTD replacement requires a future deadline. Leave the replacement price null to keep the existing price. A supplied price, including zero, is subject to the market’s price rules.
Session-wide mass cancel uses the same shard fanout as classic FIX. A cancel can complete on some shards while another is unavailable, and a previously submitted order can still be in flight. If an orderly binary listener drain interrupts the request, the gateway stops sending it to further shards. After a disconnect without a confirmed mass-cancel report, reconcile surviving orders before retrying or resuming trading.
Cancel-on-disconnect
TheKalshiNR binary listener uses the same policy as classic NR on each product. When an opted-in connection closes, the gateway requests cancellation of resting orders in the existing scope of that FIX key and authenticated account. After a gateway process loss, FIX-data performs the same cleanup when its Redis lease expires. The lease lasts twice the negotiated heartbeat interval for a COD-enabled session. Other keys keep their own orders.
A definitive binary Logon rejection preserves earlier resting orders. If the connection closes before you receive LogonAck, the requested policy may already be active. Reconcile orders under that key before resuming trading.
Wait for the confirmed execution report when you need a definite outcome. A command in flight at disconnect can have an uncertain outcome. Reconcile it and any resting orders before resuming trading. An introducing broker using affiliate accounts should reconcile those orders under their economic owner, as with classic FIX.
Use a key provisioned for the nonpersistent NR endpoint. Before reusing a key from a persistent classic session, reconcile outstanding commands. KalshiRT uses its existing classic listener.
Both MD and NR reset their FIX sequence numbers to 1 on reconnect. Recover a book with a fresh snapshot and treat skipped prints explicitly. For an uncertain order outcome, use authorized execution-event replay or reconcile the account and order using its identifiers. Historical replay retains the existing entitlements and locked-key restrictions. An empty asynchronous state read does not establish that an order failed. Submit a new command only after resolving the previous outcome. Drop-copy and historical-event rules