curl --request POST \
--url https://external-api.kalshi.com/trade-api/v2/margin/orders \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"client_order_id": "<string>",
"count": "10.00",
"price": "0.5600",
"ticker": "<string>",
"market_id": "<string>",
"expiration_time": 123,
"post_only": true,
"cancel_order_on_pause": true,
"reduce_only": true,
"subaccount": 1,
"order_group_id": "<string>",
"market_version": 0
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/margin/orders"
payload = {
"client_order_id": "<string>",
"count": "10.00",
"price": "0.5600",
"ticker": "<string>",
"market_id": "<string>",
"expiration_time": 123,
"post_only": True,
"cancel_order_on_pause": True,
"reduce_only": True,
"subaccount": 1,
"order_group_id": "<string>",
"market_version": 0
}
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({
client_order_id: '<string>',
count: '10.00',
price: '0.5600',
ticker: '<string>',
market_id: '<string>',
expiration_time: 123,
post_only: true,
cancel_order_on_pause: true,
reduce_only: true,
subaccount: 1,
order_group_id: '<string>',
market_version: 0
})
};
fetch('https://external-api.kalshi.com/trade-api/v2/margin/orders', 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/margin/orders",
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([
'client_order_id' => '<string>',
'count' => '10.00',
'price' => '0.5600',
'ticker' => '<string>',
'market_id' => '<string>',
'expiration_time' => 123,
'post_only' => true,
'cancel_order_on_pause' => true,
'reduce_only' => true,
'subaccount' => 1,
'order_group_id' => '<string>',
'market_version' => 0
]),
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/margin/orders"
payload := strings.NewReader("{\n \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\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/margin/orders")
.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 \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/margin/orders")
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 \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\n}"
response = http.request(request)
puts response.read_body{
"order_id": "<string>",
"fill_count": "10.00",
"remaining_count": "10.00",
"client_order_id": "<string>",
"average_fill_price": "0.5600",
"average_fee_paid": "0.5600"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}Create Order
Endpoint for submitting orders in a market.
curl --request POST \
--url https://external-api.kalshi.com/trade-api/v2/margin/orders \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"client_order_id": "<string>",
"count": "10.00",
"price": "0.5600",
"ticker": "<string>",
"market_id": "<string>",
"expiration_time": 123,
"post_only": true,
"cancel_order_on_pause": true,
"reduce_only": true,
"subaccount": 1,
"order_group_id": "<string>",
"market_version": 0
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/margin/orders"
payload = {
"client_order_id": "<string>",
"count": "10.00",
"price": "0.5600",
"ticker": "<string>",
"market_id": "<string>",
"expiration_time": 123,
"post_only": True,
"cancel_order_on_pause": True,
"reduce_only": True,
"subaccount": 1,
"order_group_id": "<string>",
"market_version": 0
}
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({
client_order_id: '<string>',
count: '10.00',
price: '0.5600',
ticker: '<string>',
market_id: '<string>',
expiration_time: 123,
post_only: true,
cancel_order_on_pause: true,
reduce_only: true,
subaccount: 1,
order_group_id: '<string>',
market_version: 0
})
};
fetch('https://external-api.kalshi.com/trade-api/v2/margin/orders', 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/margin/orders",
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([
'client_order_id' => '<string>',
'count' => '10.00',
'price' => '0.5600',
'ticker' => '<string>',
'market_id' => '<string>',
'expiration_time' => 123,
'post_only' => true,
'cancel_order_on_pause' => true,
'reduce_only' => true,
'subaccount' => 1,
'order_group_id' => '<string>',
'market_version' => 0
]),
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/margin/orders"
payload := strings.NewReader("{\n \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\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/margin/orders")
.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 \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/margin/orders")
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 \"client_order_id\": \"<string>\",\n \"count\": \"10.00\",\n \"price\": \"0.5600\",\n \"ticker\": \"<string>\",\n \"market_id\": \"<string>\",\n \"expiration_time\": 123,\n \"post_only\": true,\n \"cancel_order_on_pause\": true,\n \"reduce_only\": true,\n \"subaccount\": 1,\n \"order_group_id\": \"<string>\",\n \"market_version\": 0\n}"
response = http.request(request)
puts response.read_body{
"order_id": "<string>",
"fill_count": "10.00",
"remaining_count": "10.00",
"client_order_id": "<string>",
"average_fill_price": "0.5600",
"average_fee_paid": "0.5600"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}Authorizations
Your API key ID
Base64 signature of the pre-sign text (timestamp + method + path) made with the API key's algorithm - RSA-PSS with SHA-256 for RSA keys, Ed25519 for Ed25519 keys
Request timestamp in milliseconds
Body
The side of an order or trade (bid or ask)
bid, ask String representation of the order quantity in contracts.
"10.00"
Price for the order in fixed-point dollars.
"0.5600"
fill_or_kill, good_till_canceled, immediate_or_cancel The self-trade prevention type for orders. taker_at_cross cancels the taker order when it would trade against another order from the same user; execution stops and any partial fills already matched are executed. maker cancels the resting maker order and continues matching.
taker_at_cross, maker Market ticker. Supply ticker or market_id; ticker takes precedence when both are provided.
Stable exchange market UUID. May be supplied instead of ticker.
If this flag is set to true, the order will be canceled if the order is open and trading on the exchange is paused for any reason.
Specifies whether the order place count should be capped by the member's current position. Orders with reduce_only set to true will be rejected unless time_in_force is immediate_or_cancel or fill_or_kill.
The subaccount number to use for this margin order. 0 is the primary subaccount. Subaccount-restricted API keys must omit this field or pass their locked subaccount.
x >= 0The order group this order is part of
The market_version you expect the market to be at. If it is set and the market's current market_version differs, the order is rejected with HTTP 409 and error code market_version_mismatch. 0 skips the check.
Response
Order created successfully
Number of contracts filled immediately upon placement.
"10.00"
Number of contracts remaining after placement. For IOC orders, this reflects the final state after unfilled contracts are canceled.
"10.00"
Volume-weighted average fill price. Only present when fill_count > 0.
"0.5600"
Volume-weighted average fee paid per contract for fills resulting from this request. Only present when fill_count > 0.
"0.5600"