Cancel and replace orders sequentially and non-atomically
curl --request POST \
--url https://api.limitless.exchange/orders/cancel-replace/batch \
--header 'Content-Type: application/json' \
--header 'lmts-api-key: <api-key>' \
--data '
{
"operations": [
{
"cancel": {
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203",
"clientOrderId": "partner-order-001"
},
"replacement": {
"order": {
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5000000,
"takerAmount": 10000000,
"feeRateBps": 0,
"side": 0,
"signature": "0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901",
"signatureType": 2,
"taker": "0x0000000000000000000000000000000000000000",
"expiration": "0",
"nonce": 0,
"price": 0.75
},
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"postOnly": true,
"clientOrderId": "replacement-order-001",
"timestamp": 1735689600000,
"recvWindow": 1500,
"stpPolicy": "cancel_maker"
},
"mode": "STOP_ON_FAILURE",
"onBehalfOf": 12345
}
]
}
'import requests
url = "https://api.limitless.exchange/orders/cancel-replace/batch"
payload = { "operations": [
{
"cancel": {
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203",
"clientOrderId": "partner-order-001"
},
"replacement": {
"order": {
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5000000,
"takerAmount": 10000000,
"feeRateBps": 0,
"side": 0,
"signature": "0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901",
"signatureType": 2,
"taker": "0x0000000000000000000000000000000000000000",
"expiration": "0",
"nonce": 0,
"price": 0.75
},
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"postOnly": True,
"clientOrderId": "replacement-order-001",
"timestamp": 1735689600000,
"recvWindow": 1500,
"stpPolicy": "cancel_maker"
},
"mode": "STOP_ON_FAILURE",
"onBehalfOf": 12345
}
] }
headers = {
"lmts-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'lmts-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [
{
cancel: {
orderId: '6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203',
clientOrderId: 'partner-order-001'
},
replacement: {
order: {
salt: '1778155025318314496',
maker: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
signer: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
tokenId: '19633204485790857949828516737993423758628930235371629943999544859324645414627',
makerAmount: 5000000,
takerAmount: 10000000,
feeRateBps: 0,
side: 0,
signature: '0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901',
signatureType: 2,
taker: '0x0000000000000000000000000000000000000000',
expiration: '0',
nonce: 0,
price: 0.75
},
ownerId: 12345,
orderType: 'GTC',
marketSlug: 'btc-100k',
postOnly: true,
clientOrderId: 'replacement-order-001',
timestamp: 1735689600000,
recvWindow: 1500,
stpPolicy: 'cancel_maker'
},
mode: 'STOP_ON_FAILURE',
onBehalfOf: 12345
}
]
})
};
fetch('https://api.limitless.exchange/orders/cancel-replace/batch', 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://api.limitless.exchange/orders/cancel-replace/batch",
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([
'operations' => [
[
'cancel' => [
'orderId' => '6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203',
'clientOrderId' => 'partner-order-001'
],
'replacement' => [
'order' => [
'salt' => '1778155025318314496',
'maker' => '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
'signer' => '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
'tokenId' => '19633204485790857949828516737993423758628930235371629943999544859324645414627',
'makerAmount' => 5000000,
'takerAmount' => 10000000,
'feeRateBps' => 0,
'side' => 0,
'signature' => '0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901',
'signatureType' => 2,
'taker' => '0x0000000000000000000000000000000000000000',
'expiration' => '0',
'nonce' => 0,
'price' => 0.75
],
'ownerId' => 12345,
'orderType' => 'GTC',
'marketSlug' => 'btc-100k',
'postOnly' => true,
'clientOrderId' => 'replacement-order-001',
'timestamp' => 1735689600000,
'recvWindow' => 1500,
'stpPolicy' => 'cancel_maker'
],
'mode' => 'STOP_ON_FAILURE',
'onBehalfOf' => 12345
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"lmts-api-key: <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://api.limitless.exchange/orders/cancel-replace/batch"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("lmts-api-key", "<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://api.limitless.exchange/orders/cancel-replace/batch")
.header("lmts-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.limitless.exchange/orders/cancel-replace/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["lmts-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"index": 0,
"cancel": {
"status": "SUCCESS",
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"status": "SUCCESS",
"data": {
"order": {
"id": "9e31c452-8a2b-42d1-b327-65f18d07dc96",
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": "5000000",
"takerAmount": "10000000",
"expiration": "0",
"signatureType": 0,
"nonce": "0",
"feeRateBps": 0,
"signature": "0x1234",
"orderType": "GTC",
"price": "0.5",
"side": 0,
"marketId": "7348",
"ownerId": 12345,
"createdAt": "2026-08-05T12:00:00.000Z",
"updatedAt": "2026-08-05T12:00:00.000Z",
"market": {
"id": 7348,
"slug": "btc-100k",
"title": "Will Bitcoin reach $100k?",
"status": "FUNDED",
"yesPositionId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"noPositionId": "34633204485790857949828516737993423758628930235371629943999544859324645414627"
}
},
"makerMatches": [],
"execution": {
"matched": false,
"settlementStatus": "UNMATCHED",
"clientOrderId": "replacement-101",
"feeRateBps": 0,
"effectiveFeeBps": 0,
"totalsRaw": {
"contractsGross": "0",
"contractsFee": "0",
"contractsNet": "0",
"usdGross": "0",
"usdFee": "0",
"usdNet": "0"
}
}
}
}
}
]
}{
"results": [
{
"index": 0,
"cancel": {
"status": "SUCCESS",
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"status": "SUCCESS",
"data": {
"order": {
"id": "9e31c452-8a2b-42d1-b327-65f18d07dc96",
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": "5000000",
"takerAmount": "10000000",
"expiration": "0",
"signatureType": 0,
"nonce": "0",
"feeRateBps": 0,
"signature": "0x1234",
"orderType": "GTC",
"price": "0.5",
"side": 0,
"marketId": "7348",
"ownerId": 12345,
"createdAt": "2026-08-05T12:00:00.000Z",
"updatedAt": "2026-08-05T12:00:00.000Z",
"market": {
"id": 7348,
"slug": "btc-100k",
"title": "Will Bitcoin reach $100k?",
"status": "FUNDED",
"yesPositionId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"noPositionId": "34633204485790857949828516737993423758628930235371629943999544859324645414627"
}
},
"makerMatches": [],
"execution": {
"matched": false,
"settlementStatus": "UNMATCHED",
"clientOrderId": "replacement-101",
"feeRateBps": 0,
"effectiveFeeBps": 0,
"totalsRaw": {
"contractsGross": "0",
"contractsFee": "0",
"contractsNet": "0",
"usdGross": "0",
"usdFee": "0",
"usdNet": "0"
}
}
}
}
},
{
"index": 1,
"cancel": {
"status": "FAILURE",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found"
}
},
"replacement": {
"status": "FAILURE",
"error": {
"code": "400",
"message": "Insufficient balance"
}
}
}
]
}Trading
Cancel and Replace Orders (Batch)
After request-wide preflight, processes cancel-and-replace operations with independent results and preserves their input indexes.
POST
/
orders
/
cancel-replace
/
batch
Cancel and replace orders sequentially and non-atomically
curl --request POST \
--url https://api.limitless.exchange/orders/cancel-replace/batch \
--header 'Content-Type: application/json' \
--header 'lmts-api-key: <api-key>' \
--data '
{
"operations": [
{
"cancel": {
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203",
"clientOrderId": "partner-order-001"
},
"replacement": {
"order": {
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5000000,
"takerAmount": 10000000,
"feeRateBps": 0,
"side": 0,
"signature": "0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901",
"signatureType": 2,
"taker": "0x0000000000000000000000000000000000000000",
"expiration": "0",
"nonce": 0,
"price": 0.75
},
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"postOnly": true,
"clientOrderId": "replacement-order-001",
"timestamp": 1735689600000,
"recvWindow": 1500,
"stpPolicy": "cancel_maker"
},
"mode": "STOP_ON_FAILURE",
"onBehalfOf": 12345
}
]
}
'import requests
url = "https://api.limitless.exchange/orders/cancel-replace/batch"
payload = { "operations": [
{
"cancel": {
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203",
"clientOrderId": "partner-order-001"
},
"replacement": {
"order": {
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5000000,
"takerAmount": 10000000,
"feeRateBps": 0,
"side": 0,
"signature": "0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901",
"signatureType": 2,
"taker": "0x0000000000000000000000000000000000000000",
"expiration": "0",
"nonce": 0,
"price": 0.75
},
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"postOnly": True,
"clientOrderId": "replacement-order-001",
"timestamp": 1735689600000,
"recvWindow": 1500,
"stpPolicy": "cancel_maker"
},
"mode": "STOP_ON_FAILURE",
"onBehalfOf": 12345
}
] }
headers = {
"lmts-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'lmts-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
operations: [
{
cancel: {
orderId: '6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203',
clientOrderId: 'partner-order-001'
},
replacement: {
order: {
salt: '1778155025318314496',
maker: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
signer: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
tokenId: '19633204485790857949828516737993423758628930235371629943999544859324645414627',
makerAmount: 5000000,
takerAmount: 10000000,
feeRateBps: 0,
side: 0,
signature: '0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901',
signatureType: 2,
taker: '0x0000000000000000000000000000000000000000',
expiration: '0',
nonce: 0,
price: 0.75
},
ownerId: 12345,
orderType: 'GTC',
marketSlug: 'btc-100k',
postOnly: true,
clientOrderId: 'replacement-order-001',
timestamp: 1735689600000,
recvWindow: 1500,
stpPolicy: 'cancel_maker'
},
mode: 'STOP_ON_FAILURE',
onBehalfOf: 12345
}
]
})
};
fetch('https://api.limitless.exchange/orders/cancel-replace/batch', 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://api.limitless.exchange/orders/cancel-replace/batch",
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([
'operations' => [
[
'cancel' => [
'orderId' => '6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203',
'clientOrderId' => 'partner-order-001'
],
'replacement' => [
'order' => [
'salt' => '1778155025318314496',
'maker' => '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
'signer' => '0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
'tokenId' => '19633204485790857949828516737993423758628930235371629943999544859324645414627',
'makerAmount' => 5000000,
'takerAmount' => 10000000,
'feeRateBps' => 0,
'side' => 0,
'signature' => '0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901',
'signatureType' => 2,
'taker' => '0x0000000000000000000000000000000000000000',
'expiration' => '0',
'nonce' => 0,
'price' => 0.75
],
'ownerId' => 12345,
'orderType' => 'GTC',
'marketSlug' => 'btc-100k',
'postOnly' => true,
'clientOrderId' => 'replacement-order-001',
'timestamp' => 1735689600000,
'recvWindow' => 1500,
'stpPolicy' => 'cancel_maker'
],
'mode' => 'STOP_ON_FAILURE',
'onBehalfOf' => 12345
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"lmts-api-key: <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://api.limitless.exchange/orders/cancel-replace/batch"
payload := strings.NewReader("{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("lmts-api-key", "<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://api.limitless.exchange/orders/cancel-replace/batch")
.header("lmts-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.limitless.exchange/orders/cancel-replace/batch")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["lmts-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"operations\": [\n {\n \"cancel\": {\n \"orderId\": \"6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203\",\n \"clientOrderId\": \"partner-order-001\"\n },\n \"replacement\": {\n \"order\": {\n \"salt\": \"1778155025318314496\",\n \"maker\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"signer\": \"0x742d35Cc6634C0532925a3b844Bc454e4438f44e\",\n \"tokenId\": \"19633204485790857949828516737993423758628930235371629943999544859324645414627\",\n \"makerAmount\": 5000000,\n \"takerAmount\": 10000000,\n \"feeRateBps\": 0,\n \"side\": 0,\n \"signature\": \"0x123abc456def789ghi0123abc456def789ghi0123abc456def789ghi0123456789012345678901\",\n \"signatureType\": 2,\n \"taker\": \"0x0000000000000000000000000000000000000000\",\n \"expiration\": \"0\",\n \"nonce\": 0,\n \"price\": 0.75\n },\n \"ownerId\": 12345,\n \"orderType\": \"GTC\",\n \"marketSlug\": \"btc-100k\",\n \"postOnly\": true,\n \"clientOrderId\": \"replacement-order-001\",\n \"timestamp\": 1735689600000,\n \"recvWindow\": 1500,\n \"stpPolicy\": \"cancel_maker\"\n },\n \"mode\": \"STOP_ON_FAILURE\",\n \"onBehalfOf\": 12345\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"index": 0,
"cancel": {
"status": "SUCCESS",
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"status": "SUCCESS",
"data": {
"order": {
"id": "9e31c452-8a2b-42d1-b327-65f18d07dc96",
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": "5000000",
"takerAmount": "10000000",
"expiration": "0",
"signatureType": 0,
"nonce": "0",
"feeRateBps": 0,
"signature": "0x1234",
"orderType": "GTC",
"price": "0.5",
"side": 0,
"marketId": "7348",
"ownerId": 12345,
"createdAt": "2026-08-05T12:00:00.000Z",
"updatedAt": "2026-08-05T12:00:00.000Z",
"market": {
"id": 7348,
"slug": "btc-100k",
"title": "Will Bitcoin reach $100k?",
"status": "FUNDED",
"yesPositionId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"noPositionId": "34633204485790857949828516737993423758628930235371629943999544859324645414627"
}
},
"makerMatches": [],
"execution": {
"matched": false,
"settlementStatus": "UNMATCHED",
"clientOrderId": "replacement-101",
"feeRateBps": 0,
"effectiveFeeBps": 0,
"totalsRaw": {
"contractsGross": "0",
"contractsFee": "0",
"contractsNet": "0",
"usdGross": "0",
"usdFee": "0",
"usdNet": "0"
}
}
}
}
}
]
}{
"results": [
{
"index": 0,
"cancel": {
"status": "SUCCESS",
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"status": "SUCCESS",
"data": {
"order": {
"id": "9e31c452-8a2b-42d1-b327-65f18d07dc96",
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": "5000000",
"takerAmount": "10000000",
"expiration": "0",
"signatureType": 0,
"nonce": "0",
"feeRateBps": 0,
"signature": "0x1234",
"orderType": "GTC",
"price": "0.5",
"side": 0,
"marketId": "7348",
"ownerId": 12345,
"createdAt": "2026-08-05T12:00:00.000Z",
"updatedAt": "2026-08-05T12:00:00.000Z",
"market": {
"id": 7348,
"slug": "btc-100k",
"title": "Will Bitcoin reach $100k?",
"status": "FUNDED",
"yesPositionId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"noPositionId": "34633204485790857949828516737993423758628930235371629943999544859324645414627"
}
},
"makerMatches": [],
"execution": {
"matched": false,
"settlementStatus": "UNMATCHED",
"clientOrderId": "replacement-101",
"feeRateBps": 0,
"effectiveFeeBps": 0,
"totalsRaw": {
"contractsGross": "0",
"contractsFee": "0",
"contractsNet": "0",
"usdGross": "0",
"usdFee": "0",
"usdNet": "0"
}
}
}
}
},
{
"index": 1,
"cancel": {
"status": "FAILURE",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found"
}
},
"replacement": {
"status": "FAILURE",
"error": {
"code": "400",
"message": "Insufficient balance"
}
}
}
]
}Submit multiple cancel-and-replace operations in one request. Each executed operation has the same non-atomic behavior as
The order values below illustrate the request shape. Generate each
POST /orders/cancel-replace, and one operation result does not stop later operations.
Request
Sendoperations as an array of 1 to 4 cancel-and-replace operations. Each item contains cancel, replacement, mode, and optional onBehalfOf fields as described in the single-operation reference.
Authentication and order signing also match the single endpoint. HMAC-sign the exact JSON body with the path /orders/cancel-replace/batch. Each signed replacement remains a normal EIP-712 order; delegated onBehalfOf operations follow the same authorized-owner and delegated-signing rules.
The API validates and prepares the whole request before executing any cancellation. A request-level validation, authorization, market, signature, or receive-window error rejects the batch without a
results array. Duplicate cancellation targets and duplicate replacement clientOrderId values also reject the entire request. The independent-result behavior applies after the batch passes this preflight.order.signature from its complete replacement payload instead of copying the placeholder signatures.
{
"operations": [
{
"cancel": {
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"clientOrderId": "replacement-101",
"order": {
"salt": "1778155025318314496",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5000000,
"takerAmount": 10000000,
"expiration": "0",
"nonce": 0,
"price": 0.5,
"feeRateBps": 0,
"side": 0,
"signature": "0x1234",
"signatureType": 0
}
},
"mode": "STOP_ON_FAILURE"
},
{
"cancel": {
"clientOrderId": "missing-order-102"
},
"replacement": {
"ownerId": 12345,
"orderType": "GTC",
"marketSlug": "btc-100k",
"clientOrderId": "replacement-102",
"order": {
"salt": "1778155025318314497",
"maker": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"signer": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"taker": "0x0000000000000000000000000000000000000000",
"tokenId": "19633204485790857949828516737993423758628930235371629943999544859324645414627",
"makerAmount": 5500000,
"takerAmount": 10000000,
"expiration": "0",
"nonce": 0,
"price": 0.55,
"feeRateBps": 0,
"side": 0,
"signature": "0x5678",
"signatureType": 0
}
},
"mode": "ALLOW_FAILURE"
}
]
}
Ordering and partial failures
After request-wide preflight succeeds, the response preserves request order: every result has the zero-basedindex of its input operation. Executed operations produce independent outcomes, so inspect both cancel and replacement for every index rather than treating the HTTP status as an item-level result.
If all items have top-level cancel.status: "SUCCESS" and replacement.status: "SUCCESS", the endpoint returns 200 OK. If any item has another top-level status, it returns 207 Multi-Status with every result, including successful items.
{
"results": [
{
"index": 0,
"cancel": {
"status": "SUCCESS",
"orderId": "6f52b6d2-6c9e-4a5c-8a4f-28ab4b7ff203"
},
"replacement": {
"status": "SUCCESS",
"data": {
"order": {
"id": "9e31c452-8a2b-42d1-b327-65f18d07dc96"
},
"makerMatches": [],
"execution": {
"matched": false,
"settlementStatus": "UNMATCHED",
"clientOrderId": "replacement-101",
"feeRateBps": 0,
"effectiveFeeBps": 0,
"totalsRaw": {
"contractsGross": "0",
"contractsFee": "0",
"contractsNet": "0",
"usdGross": "0",
"usdFee": "0",
"usdNet": "0"
}
}
}
}
},
{
"index": 1,
"cancel": {
"status": "FAILURE",
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found"
}
},
"replacement": {
"status": "FAILURE",
"error": {
"code": "400",
"message": "Insufficient balance"
}
}
}
]
}
STOP_ON_FAILURE produces NOT_ATTEMPTED only for the affected operation. ALLOW_FAILURE still attempts that operation’s replacement. Public cancellation and replacement outcomes can also be UNKNOWN when the final result cannot be determined.
Request-level errors use their ordinary HTTP status instead of 207 Multi-Status. A 207 is returned only after preflight succeeds and at least one executed operation has a non-success top-level result.
HTTP
200 versus 207 follows the top-level cancellation and placement statuses. A replacement accepted by the matching engine stays top-level SUCCESS even if its nested execution.settlementStatus is FAILED; the nested reason carries the settlement failure.Authorizations
Scoped API token with HMAC-SHA256 signing. Requires three headers: lmts-api-key (token ID), lmts-timestamp (ISO-8601), lmts-signature (Base64-encoded HMAC). See Authentication docs for details.
Body
application/json
Independent cancel-and-replace operations
Required array length:
1 - 4 elementsShow child attributes
Show child attributes
Response
Every operation has successful cancellation and replacement statuses
Outcomes in input order. Each item includes its zero-based input index.
Show child attributes
Show child attributes
⌘I