
How to Get a Kalshi API Key (RSA and Ed25519, 2026)
To get a Kalshi API key, log in at kalshi.com, open Account & security → API Keys, click Create Key, and save both things it gives you: the private key file and the key ID. The private key is shown exactly once, Kalshi does not store it, and there is no recovery flow if you close that page without saving it. Kalshi now issues Ed25519 key pairs by default, with RSA 2048 still supported for clients that only speak RSA-PSS.
The setup takes two minutes. The part that actually breaks integrations is the signing string, and everything below was verified against the live production API on October 12, 2026, including the four failure modes that our own first attempt hit.
Key Takeaway: A Kalshi API key is an asymmetric key pair, not a secret token. You register the public key, Kalshi hands you the private key once, and every authenticated request carries
KALSHI-ACCESS-KEY,KALSHI-ACCESS-TIMESTAMPandKALSHI-ACCESS-SIGNATURE. The signed string istimestamp + METHOD + /trade-api/v2/...with query parameters stripped. That last detail is the single most common reason a valid key returnsINCORRECT_API_KEY_SIGNATURE.
What a Kalshi API key actually is
Most trading APIs hand you a token and let you paste it into a header. Kalshi does not. You hold a private key, Kalshi holds the matching public key, and each request is signed individually. Nothing secret ever travels over the wire, and a leaked request log does not leak your account.
The practical consequences:
- Reads do not need a key at all. Market data, events, order books, candlesticks and
/exchange/statusare public. We called all of them without any headers. - Account and order endpoints do.
/portfolio/balance,/portfolio/orders,/portfolio/positions,/api_keysand the order placement endpoints all require the three signed headers. - The key is a file, so store it like one. No rotation policy will save you if the PEM ends up in a public repo. Keep it outside your project directory and load it from an environment variable or a path your deployment sets.
Two key types exist, and Kalshi picks the verification algorithm from whatever you registered:
- Ed25519 — the recommended type, 64-byte signatures, lower signing cost. The UI selects it by default.
- RSA 2048-bit with RSA-PSS over SHA-256 — still fully supported, and what most older SDK versions and copy-pasted snippets use. We verified this path end to end on October 12, 2026.
One trap is baked into the file format: the PEM header does not tell you which type you have. RSA keys exported in the newer PKCS#8 container, including the output of openssl genpkey, use the same generic private-key header as an Ed25519 key. Parse the key and branch on the object type instead of on the header text.
Create your Kalshi API key in the UI
- Log in at kalshi.com and open Account & security → API Keys, or go straight to kalshi.com/account/profile. The demo equivalent lives at demo.kalshi.co.
- Click Create Key.
- Give the key a name you will recognise in three months. Kalshi uses that name for the downloaded file, and
GET /api_keyslater returns it next to the scopes. - Copy the key ID. It is a UUID, for example
a952bcbe-ec3b-4b5b-b8f9-11dae589608c. - Save the private key PEM immediately. It is displayed once, downloaded once, and never retrievable.
Verified against the Kalshi key documentation on October 12, 2026: the key is created identically in the demo and production environments, and account verification is required before keys can be generated at all.
Or register your own key pair
If you do not want a private key to pass through a browser download, generate the pair yourself and paste only the public half into the form. Kalshi documents both variants:
# Ed25519 (recommended)
openssl genpkey -algorithm ed25519 -out kalshi.key
openssl pkey -in kalshi.key -pubout -out kalshi.pub
# RSA 2048
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out kalshi.key
openssl rsa -in kalshi.key -pubout -out kalshi.pub
Then paste the contents of kalshi.pub into the public key field. The private key stays on your machine, which is the whole point.
If you prefer to stay in code, the API does the same job without the UI: POST /trade-api/v2/api_keys registers a public key you supply, and POST /trade-api/v2/api_keys/generate returns a fresh pair with a key_type parameter, defaulting to rsa when you omit it. We confirmed both routes exist on October 12, 2026: without a JSON body they answer HTTP 400 invalid_content_type, and with a body but no valid signature they answer HTTP 401 token_authentication_failure.
The signing string, exactly
Every authenticated call needs three headers:
KALSHI-ACCESS-KEY— the key ID, not the keyKALSHI-ACCESS-TIMESTAMP— current time in millisecondsKALSHI-ACCESS-SIGNATURE— base64 signature over the pre-sign text
The pre-sign text is the concatenation of timestamp, HTTP method and path, in that order, with no separators:
1703123456789GET/trade-api/v2/portfolio/balance
Two rules decide whether that signature is accepted, and both are easy to violate by accident. The path is signed from the API root, so it includes /trade-api/v2. And everything from the ? onwards is removed before signing: for /trade-api/v2/portfolio/orders?limit=5 you sign /trade-api/v2/portfolio/orders. Both rules are stated in Kalshi’s quick start for authenticated requests, and we confirmed each one as a passing and a failing case below.
Here is the working Python module, including the type detection that keeps RSA and Ed25519 in one code path:
import base64, datetime, requests
from cryptography.hazmat.primitives import serialization, hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
BASE = "https://external-api.kalshi.com/trade-api/v2"
def load_key(path):
with open(path, "rb") as f:
return serialization.load_pem_private_key(f.read(), password=None)
def sign(private_key, text: str) -> str:
message = text.encode("utf-8")
if isinstance(private_key, Ed25519PrivateKey):
signature = private_key.sign(message) # Ed25519 signs the message itself
else:
signature = private_key.sign( # RSA uses PSS, not PKCS#1 v1.5
message,
padding.PSS(mgf=padding.MGF1(hashes.SHA256()),
salt_length=padding.PSS.DIGEST_LENGTH),
hashes.SHA256(),
)
return base64.b64encode(signature).decode()
def get(private_key, key_id, path):
ts = str(int(datetime.datetime.now().timestamp() * 1000)) # milliseconds
signed_path = path.split("?")[0] # strip query parameters
signature = sign(private_key, ts + "GET" + "/trade-api/v2" + signed_path)
headers = {
"KALSHI-ACCESS-KEY": key_id,
"KALSHI-ACCESS-TIMESTAMP": ts,
"KALSHI-ACCESS-SIGNATURE": signature,
}
return requests.get(BASE + path, headers=headers, timeout=20)
Expert insight: The failure mode that costs people an evening is not a wrong key, it is a right key with a wrong pre-sign text. Kalshi returns
INCORRECT_API_KEY_SIGNATUREfor both, so the error message tells you nothing about which half is broken. Print the exact string you hash, once, and compare it character by character withtimestamp + METHOD + /trade-api/v2/path. Every auth bug we have hit on this API was visible in that one line of output.
Four auth errors we reproduced on October 12, 2026
These are not theoretical. Each row is the raw response from the production API, using a real RSA key that works when the request is built correctly.
| What we did | HTTP | Response body |
|---|---|---|
Signed /portfolio/orders?limit=2 with the query string | 401 | authentication_error / INCORRECT_API_KEY_SIGNATURE |
| Signed the same request with the query stripped | 200 | {"cursor":"","orders":[]} |
Signed timestamp + GET + /portfolio/balance (no /trade-api/v2 prefix) | 401 | authentication_error / INCORRECT_API_KEY_SIGNATURE |
| Signed with PKCS#1 v1.5 instead of RSA-PSS | 401 | authentication_error / INCORRECT_API_KEY_SIGNATURE |
| Sent a timestamp 5 minutes in the past (or in the future) | 401 | header_timestamp_expired / header timestamp expired |
Used the old v1 headers (KALSHI-CLIENT-KEY-ID, KALSHI-CLIENT-SIGNATURE) | 401 | token_authentication_failure |
| Sent no auth headers at all | 401 | token_authentication_failure |
| Used a key ID that does not exist | 401 | authentication_error / NOT_FOUND |
| Sent a production key to the demo host | 401 | authentication_error / NOT_FOUND |
Two things are worth keeping. First, token_authentication_failure means Kalshi never found the headers — wrong header names, or none. Second, INCORRECT_API_KEY_SIGNATURE means it found them, found your key, and disagreed with your signature. Treat those as different bugs, because they are.
A bonus finding while testing: POST /portfolio/orders in v1 form now answers HTTP 410 deprecated_v1_order_endpoint and points at the V2 order endpoint. If you scripted orders against the old shape, your bot is failing at the first order and not at authentication, where you would expect it. We documented the v2 field and endpoint changes separately.
Which host and which environment
Two production hosts serve the same API and both accepted our authenticated calls on October 12, 2026:
https://external-api.kalshi.com/trade-api/v2— the documented trading hosthttps://api.elections.kalshi.com/trade-api/v2— the older host, still live
The demo environment is separate: https://external-api.demo.kalshi.co/trade-api/v2 for REST and wss://external-api-ws.demo.kalshi.co/trade-api/ws/v2 for WebSockets, with demo-api.kalshi.co still accepted as an alias. Demo markets use mock funds and, in Kalshi’s own wording, prices and behaviour there are not representative of live markets. Credentials are not shared in either direction, which is exactly what our test showed. For the full demo setup, including the mock funding options and what demo cannot test, see the Kalshi demo environment guide.
If you only need market data, skip all of this. Unauthenticated GET /exchange/status answered {"exchange_active": true, ...} for us with no key at all, and the same is true of markets, events, order books and candlesticks. That is also the cheapest way to check connectivity before you debug a signature. If you want data rather than order flow, start with our Kalshi data reference and the historical data guide before you touch portfolio endpoints.
What your key can do, and how fast
GET /api_keys returns every key registered on your account with its name and scopes, so you can inventory a machine or revoke an old bot’s key without hunting through the web app. A sample response from our test account:
{"api_keys": [{"api_key_id": "6efaf478-...", "name": "example-bot", "scopes": ["read", "write"]}]}
Rate limits are not published as headers on the responses; we checked the response headers of successful calls and found none. They come from GET /account/limits instead, which returned this for a basic tier account on October 12, 2026:
{"usage_tier": "basic",
"read": {"bucket_capacity": 600, "refill_rate": 200},
"write": {"bucket_capacity": 100, "refill_rate": 100}}
Read the numbers as a token bucket, not as requests per minute: every endpoint costs something, and order placement costs more than a balance check. Design your bot so a 429 is a retry with backoff rather than a crash, and log the bucket values at startup so a tier change does not surprise you in production. Before you size positions from those numbers, the fee arithmetic matters more than the rate limit: Kalshi’s taker fee still applies on every fill, which is what our payout calculator exists for.
Key Takeaway: Do the boring checklist in this order. Public endpoint first, then a signed
/portfolio/balance, then one read endpoint with a query parameter, then a write endpoint in the demo environment. Each step isolates one variable, and the first step that fails tells you whether the problem is connectivity, key material, the pre-sign string or permissions.
Where to go next
Once a signed balance call returns 200, you have the hardest part of a Kalshi integration behind you. From there the useful next steps are the endpoint reference for v2 field names, the Python tutorial for the full request cycle, and the cheat sheet with the endpoints and fee formulas we use most. If you would rather not rebuild the plumbing, the Kalshi Bot Kit ships the signing module, five strategies and a Docker setup that already handles retries.
The same key signs your WebSocket handshake, with one difference in the signed string. That part, plus a working orderbook stream in Python, is in the Kalshi WebSocket guide.
EdgeOutcome may earn a commission if you sign up through our affiliate links. Nothing here is trading advice.
18+. Prediction markets involve real financial risk. Availability depends on your country and US state.
Frequently Asked Questions
How do I get a Kalshi API key?
Log in at kalshi.com, open Account & security, then API Keys, and click Create Key. Kalshi shows the key ID on screen and downloads the private key as a PEM text file. The private key is shown exactly once: Kalshi does not store it and cannot show it to you again. The same flow exists in the demo environment. Verified in the Kalshi docs on October 12, 2026.
Does Kalshi use RSA or Ed25519 API keys?
Both are supported. Ed25519 is the default in the Kalshi UI and the recommended type, using 64-byte signatures. RSA 2048-bit keys with RSA-PSS over SHA-256 still authenticate, which we confirmed against the production API on October 12, 2026. The official Python and TypeScript SDKs accept either key type from version 3.31.0.
Why does my Kalshi API request return INCORRECT_API_KEY_SIGNATURE?
The string you signed does not match what Kalshi rebuilt. The three cases we reproduced on October 12, 2026: signing the path without the /trade-api/v2 prefix, leaving query parameters inside the signed string, or signing with the wrong padding (PKCS#1 v1.5 instead of RSA-PSS). Sign exactly timestamp + METHOD + path-from-API-root, with everything from ? onwards removed.
Do I need a separate API key for the Kalshi demo environment?
Yes. Kalshi does not share credentials between environments. We sent a working production key to the demo host on October 12, 2026 and got HTTP 401 with the details field NOT_FOUND, which is what Kalshi returns for an unknown key ID. Create the key again while logged into the demo account.
What are Kalshi API rate limits for a basic account?
On a basic tier account, GET /account/limits returned a read bucket of capacity 600 with refill rate 200, and a write bucket of capacity 100 with refill rate 100, measured on October 12, 2026. The values come from the API itself, not from documentation, and they change per tier.