curl --request PUT \
--url https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"count": "10.00",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"kind": "bracket",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 5000
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger"
payload = {
"count": "10.00",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"kind": "bracket",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 5000
}
headers = {
"KALSHI-ACCESS-KEY": "<api-key>",
"KALSHI-ACCESS-SIGNATURE": "<api-key>",
"KALSHI-ACCESS-TIMESTAMP": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'KALSHI-ACCESS-KEY': '<api-key>',
'KALSHI-ACCESS-SIGNATURE': '<api-key>',
'KALSHI-ACCESS-TIMESTAMP': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
count: '10.00',
anchor_order_id: '<string>',
client_trigger_id: '<string>',
kind: 'bracket',
stop_loss_price: '0.5600',
take_profit_price: '0.5600',
trail_amount: '0.5600',
trail_bps: 5000
})
};
fetch('https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger', 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/cross/positions/{ticker}/exit_trigger",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'count' => '10.00',
'anchor_order_id' => '<string>',
'client_trigger_id' => '<string>',
'kind' => 'bracket',
'stop_loss_price' => '0.5600',
'take_profit_price' => '0.5600',
'trail_amount' => '0.5600',
'trail_bps' => 5000
]),
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/cross/positions/{ticker}/exit_trigger"
payload := strings.NewReader("{\n \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}")
req, _ := http.NewRequest("PUT", 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.put("https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger")
.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 \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.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 \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"ticker": "<string>",
"kind": "bracket",
"status": "pending_on_entry",
"count": "10.00",
"filled_count": "10.00",
"created_time": "2023-11-07T05:31:56Z",
"updated_time": "2023-11-07T05:31:56Z",
"status_reason": "user_canceled",
"triggered_leg": "stop_loss",
"triggered_order_id": "<string>",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 123,
"watermark_price": "0.5600",
"effective_stop_price": "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>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}Set Cross Exit Trigger
Endpoint for setting a stop-loss / take-profit bracket or a trailing stop on a non-isolated margin position. A position holds one trailing stop and up to 20 brackets, so long as their counts fit the position. Requires an open position unless anchor_order_id is supplied, and fires reduce-only orders. A fired trigger places an immediate-or-cancel limit order near the stop price, not a market order, so it can fill partially or not at all. See Exit triggers in the Perps API overview (https://docs.kalshi.com/margin#exit-triggers) for validation errors and retry behavior.
curl --request PUT \
--url https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger \
--header 'Content-Type: application/json' \
--header 'KALSHI-ACCESS-KEY: <api-key>' \
--header 'KALSHI-ACCESS-SIGNATURE: <api-key>' \
--header 'KALSHI-ACCESS-TIMESTAMP: <api-key>' \
--data '
{
"count": "10.00",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"kind": "bracket",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 5000
}
'import requests
url = "https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger"
payload = {
"count": "10.00",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"kind": "bracket",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 5000
}
headers = {
"KALSHI-ACCESS-KEY": "<api-key>",
"KALSHI-ACCESS-SIGNATURE": "<api-key>",
"KALSHI-ACCESS-TIMESTAMP": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'KALSHI-ACCESS-KEY': '<api-key>',
'KALSHI-ACCESS-SIGNATURE': '<api-key>',
'KALSHI-ACCESS-TIMESTAMP': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
count: '10.00',
anchor_order_id: '<string>',
client_trigger_id: '<string>',
kind: 'bracket',
stop_loss_price: '0.5600',
take_profit_price: '0.5600',
trail_amount: '0.5600',
trail_bps: 5000
})
};
fetch('https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger', 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/cross/positions/{ticker}/exit_trigger",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'count' => '10.00',
'anchor_order_id' => '<string>',
'client_trigger_id' => '<string>',
'kind' => 'bracket',
'stop_loss_price' => '0.5600',
'take_profit_price' => '0.5600',
'trail_amount' => '0.5600',
'trail_bps' => 5000
]),
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/cross/positions/{ticker}/exit_trigger"
payload := strings.NewReader("{\n \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}")
req, _ := http.NewRequest("PUT", 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.put("https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger")
.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 \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://external-api.kalshi.com/trade-api/v2/margin/cross/positions/{ticker}/exit_trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.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 \"count\": \"10.00\",\n \"anchor_order_id\": \"<string>\",\n \"client_trigger_id\": \"<string>\",\n \"kind\": \"bracket\",\n \"stop_loss_price\": \"0.5600\",\n \"take_profit_price\": \"0.5600\",\n \"trail_amount\": \"0.5600\",\n \"trail_bps\": 5000\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"ticker": "<string>",
"kind": "bracket",
"status": "pending_on_entry",
"count": "10.00",
"filled_count": "10.00",
"created_time": "2023-11-07T05:31:56Z",
"updated_time": "2023-11-07T05:31:56Z",
"status_reason": "user_canceled",
"triggered_leg": "stop_loss",
"triggered_order_id": "<string>",
"anchor_order_id": "<string>",
"client_trigger_id": "<string>",
"stop_loss_price": "0.5600",
"take_profit_price": "0.5600",
"trail_amount": "0.5600",
"trail_bps": 123,
"watermark_price": "0.5600",
"effective_stop_price": "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>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}{
"code": "<string>",
"message": "<string>",
"details": "<string>"
}Authorizations
Query Parameters
Body
For bracket, supply stop_loss_price and/or take_profit_price. For trailing, supply exactly one of trail_amount or trail_bps. Fields belonging to the other kind are rejected, as is a body that sets neither — cancel with DELETE. A leg you omit is cleared.
Ties the trigger to an order: its size follows that order's cumulative fill, and it stays pending until the order first fills. Bracket only; mutually exclusive with count. If the order cannot currently be validated, the request returns 409 with error code anchor_order_unavailable before writing anything, so retrying is safe.
Your own identifier, required on a count or anchor_order_id create because those append a trigger rather than replace one; rejected on every other write. Replaying a key returns the trigger the first request made, in whatever state it has since reached. Keys are single-use per account and belong to the position they created on: reusing one returns the original even once it is canceled, and presenting it for another subaccount or ticker returns 409 with error code idempotency_key_already_used.
64Response
Exit trigger set successfully
pending_on_entry awaits an initial or further fill from the anchor order before arming — an order-anchored trigger returns here after closing its current quantity, so this status can follow active and carries a non-zero filled_count when it does. active is live and evaluated against the mark each tick. filled, failed, and canceled are terminal.
pending_on_entry, active, filled, failed, canceled, unknown