Skip to main content

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.

API Key Setup

FIX API keys use the same RSA key pair as the REST API. Generate a 2048-bit RSA key pair and register the public key in your account profile. The resulting API Key ID (UUID) is your SenderCompID.
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out kalshi-fix.key
openssl rsa -in kalshi-fix.key -pubout -out kalshi-fix.pub

Logon (35=A)

The initiator sends a Logon message. The acceptor responds with either a Logon (success) or Logout (failure).

Required Fields

TagNameDescriptionValue
98EncryptMethodMethod of encryptionNone<0>
96RawDataClient logon message signatureBase64 encoded signature
1137DefaultApplVerIDDefault application versionFIX50SP2<9>

Optional Fields

TagNameDescriptionDefault
141ResetSeqNumFlagReset sequence numbers on logon. Must be Y for KalshiNR and KalshiDC.N
108HeartbeatIntHeartbeat interval in seconds, must be >= 3.30
8013CancelOrdersOnDisconnectCancel orders on disconnectionN
20126ListenerSessionListen-only session. KalshiNR/KalshiRT only, requires SkipPendingExecReports=Y.N
20200MessageRetentionPeriodHow long session messages are stored for retransmission, max 72 hours. KalshiRT only.24
21005UseDollarsFixed-point dollar pricing flag. Margin sessions always use fixed-point dollar pricing; clients should treat this as always enabled.Always on
21011SkipPendingExecReportsSkip PENDING_NEW / PENDING_REPLACE / PENDING_CANCEL execution reportsN
21012UseExpiredOrdStatusEmit Expired<C> for expiry-style system cancellations instead of Canceled<4>N
21007EnableIocCancelReportPartially filled IOC orders produce a cancel reportN
21008PreserveOriginalOrderQtyOrderQty tag 38 always reflects original order quantity across statesN

Signature Generation

The RawData field must contain a PSS RSA signature of the pre-hash string:
PreHashString = SendingTime + SOH + MsgType + SOH + MsgSeqNum + SOH + SenderCompID + SOH + TargetCompID
The SendingTime in the PreHashString must match exactly the value in field 52 of the Logon message. SendingTime must be within 30 seconds of the server’s current time, or the message will be rejected with SessionRejectReason<373>=10.
from base64 import b64encode
from Cryptodome.Signature import pss
from Cryptodome.Hash import SHA256
from Cryptodome.PublicKey import RSA

private_key = RSA.import_key(open('kalshi-fix.key').read().encode('utf-8'))

sending_time = "20230809-05:28:18.035"
msg_type = "A"
msg_seq_num = "1"
sender_comp_id = "your-fix-api-key-uuid"
target_comp_id = "KalshiNR"

msg_string = chr(1).join([
    sending_time, msg_type, msg_seq_num,
    sender_comp_id, target_comp_id
])

msg_hash = SHA256.new(msg_string.encode('utf-8'))
signature = pss.new(private_key).sign(msg_hash)
raw_data_value = b64encode(signature).decode('utf-8')

Heartbeat & Sequence Numbers

BehaviorDetail
Default heartbeat interval30 seconds
Missed heartbeatConnection terminates if heartbeat response not received within interval
Sequence number lower than expectedConnection terminated
Sequence number higher than expectedRecoverable with ResendRequest (KalshiRT only)

Message Retransmission

Message retransmission (ResendRequest, SequenceReset) is only supported on KalshiRT. ResetSeqNumFlag<141> must always be Y on KalshiNR and KalshiDC. The drop copy session provides an alternative way to query for missed execution reports. For a real-time streaming feed, see Listener Sessions.

ResendRequest (35=2)

KalshiRT only. Lookback window controlled by MessageRetentionPeriod.
TagNameDescription
7BeginSeqNoLower bound (inclusive)
16EndSeqNoUpper bound (inclusive)

Logout (35=5)

Either side may initiate a Logout. The counterparty responds with a Logout, and the transport connection is terminated. If CancelOrdersOnDisconnect=Y was set on Logon, all open orders are canceled.