curl --request POST \
--url https://external-api.kalshi.com/trade-api/v2/api_keys/generate \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"name": "<string>",
"scopes": [],
"subaccount": 31,
"fcm_subtrader_id": "<string>"
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/api_keys/generate"
payload = {
"name": "<string>",
"scopes": [],
"subaccount": 31,
"fcm_subtrader_id": "<string>"
}
headers = {
"KALSHI-ACCESS-KEY": "<api-key>",
"KALSHI-ACCESS-SIGNATURE": "<api-key>",
"KALSHI-ACCESS-TIMESTAMP": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'KALSHI-ACCESS-KEY': '<api-key>',
'KALSHI-ACCESS-SIGNATURE': '<api-key>',
'KALSHI-ACCESS-TIMESTAMP': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', scopes: [], subaccount: 31, fcm_subtrader_id: '<string>'})
};
fetch('https://external-api.kalshi.com/trade-api/v2/api_keys/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://external-api.kalshi.com/trade-api/v2/api_keys/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'scopes' => [
],
'subaccount' => 31,
'fcm_subtrader_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"KALSHI-ACCESS-KEY: <api-key>",
"KALSHI-ACCESS-SIGNATURE: <api-key>",
"KALSHI-ACCESS-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://external-api.kalshi.com/trade-api/v2/api_keys/generate"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("KALSHI-ACCESS-KEY", "<api-key>")
req.Header.Add("KALSHI-ACCESS-SIGNATURE", "<api-key>")
req.Header.Add("KALSHI-ACCESS-TIMESTAMP", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://external-api.kalshi.com/trade-api/v2/api_keys/generate")
.header("KALSHI-ACCESS-KEY", "<api-key>")
.header("KALSHI-ACCESS-SIGNATURE", "<api-key>")
.header("KALSHI-ACCESS-TIMESTAMP", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/api_keys/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["KALSHI-ACCESS-KEY"] = '<api-key>'
request["KALSHI-ACCESS-SIGNATURE"] = '<api-key>'
request["KALSHI-ACCESS-TIMESTAMP"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"api_key_id": "<string>",
"private_key": "<string>",
"key_type": "rsa",
"warning": "<string>"
}Generate API Key
Endpoint for generating a new API key with an automatically created key pair. This endpoint generates a key pair of the requested key_type (RSA when omitted). The public key is stored on the platform, while the private key is returned to the user and must be stored securely. The private key cannot be retrieved again. In production, an account can hold up to 100 directly managed API keys (keys created on the account settings page or through the API key endpoints).
curl --request POST \
--url https://external-api.kalshi.com/trade-api/v2/api_keys/generate \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"name": "<string>",
"scopes": [],
"subaccount": 31,
"fcm_subtrader_id": "<string>"
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/api_keys/generate"
payload = {
"name": "<string>",
"scopes": [],
"subaccount": 31,
"fcm_subtrader_id": "<string>"
}
headers = {
"KALSHI-ACCESS-KEY": "<api-key>",
"KALSHI-ACCESS-SIGNATURE": "<api-key>",
"KALSHI-ACCESS-TIMESTAMP": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'KALSHI-ACCESS-KEY': '<api-key>',
'KALSHI-ACCESS-SIGNATURE': '<api-key>',
'KALSHI-ACCESS-TIMESTAMP': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({name: '<string>', scopes: [], subaccount: 31, fcm_subtrader_id: '<string>'})
};
fetch('https://external-api.kalshi.com/trade-api/v2/api_keys/generate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://external-api.kalshi.com/trade-api/v2/api_keys/generate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'scopes' => [
],
'subaccount' => 31,
'fcm_subtrader_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"KALSHI-ACCESS-KEY: <api-key>",
"KALSHI-ACCESS-SIGNATURE: <api-key>",
"KALSHI-ACCESS-TIMESTAMP: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://external-api.kalshi.com/trade-api/v2/api_keys/generate"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("KALSHI-ACCESS-KEY", "<api-key>")
req.Header.Add("KALSHI-ACCESS-SIGNATURE", "<api-key>")
req.Header.Add("KALSHI-ACCESS-TIMESTAMP", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://external-api.kalshi.com/trade-api/v2/api_keys/generate")
.header("KALSHI-ACCESS-KEY", "<api-key>")
.header("KALSHI-ACCESS-SIGNATURE", "<api-key>")
.header("KALSHI-ACCESS-TIMESTAMP", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/api_keys/generate")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["KALSHI-ACCESS-KEY"] = '<api-key>'
request["KALSHI-ACCESS-SIGNATURE"] = '<api-key>'
request["KALSHI-ACCESS-TIMESTAMP"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"scopes\": [],\n \"subaccount\": 31,\n \"fcm_subtrader_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"api_key_id": "<string>",
"private_key": "<string>",
"key_type": "rsa",
"warning": "<string>"
}Authorizations
Body
Signature algorithm of an API key pair. rsa - 2048-bit RSA; requests are signed with RSA-PSS SHA-256. ed25519 - Ed25519 (RFC 8032) signatures over the same pre-sign text, with lower client-side signing cost. Defaults to rsa when omitted from a generate request, for compatibility with existing clients.
rsa, ed25519 List of scopes to grant to the API key. If the broad write parent scope is included, read must also be included. Child scopes may be granted without the broad parent scope. Defaults to full access (read, write) if not provided.
Scope granted to an API key. Parent scopes grant broad access; for example, read grants all read endpoints and write grants all write endpoints. Child scopes such as read::block_trade_accept, read::portfolio_balance, write::trade, write::transfer, write::fcm_risk (FCM subtrader creation, trading blocks, daily premium caps, and margin caps), and write::block_trade_accept grant only their specific endpoint group and can be granted without the parent scope.
read, write, read::block_trade_accept, read::portfolio_balance, write::trade, write::transfer, write::fcm_risk, write::block_trade_accept If set, restricts the API key to a single sub-account (0-63) that you own. A restricted key may only read and trade on that sub-account; it cannot act on other sub-accounts, transfer funds between sub-accounts, or create sub-accounts. Omit to leave the key unrestricted. Mutually exclusive with fcm_subtrader_id.
0 <= x <= 63FCM members only. If set, binds the API key to a single FCM subtrader that you own, spelled {your_user_id}_{suffix} with a suffix of 1-16 case-sensitive ASCII alphanumeric characters. The subtrader must already exist. A bound key is the institution's trading credential for that subtrader - FIX order-entry and market-data sessions, plus margin WebSocket sessions scoped to the subtrader's own data - and is denied on every REST endpoint, including key management. Mutually exclusive with subaccount.
Response
API key generated successfully
Signature algorithm of an API key pair. rsa - 2048-bit RSA; requests are signed with RSA-PSS SHA-256. ed25519 - Ed25519 (RFC 8032) signatures over the same pre-sign text, with lower client-side signing cost. Defaults to rsa when omitted from a generate request, for compatibility with existing clients.
rsa, ed25519 Present only when the minted key is bound to an FCM subtrader that is missing a per-subtrader risk control - the initial-margin cap (margin lane) or the event-contract daily cap. The mint still succeeds; the warning names each missing control - an event-contract subtrader without a daily cap has its event-contract orders rejected until one is set, while a margin subtrader without an initial-margin cap is bounded only by firm-level risk limits.