Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_cancel_order(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", asset="AAPL", order_id=12345)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingCancelOrder({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
asset: "AAPL",
orderId: 12345,
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/cancel_order \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"asset": "AAPL",
"order_id": 12345
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0x06A9aF046187895AcFc7258450B15397CAc67400',
asset: 'AAPL',
order_id: 12345
})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/cancel_order', 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.compasslabs.ai/v2/perpetual_trading/cancel_order",
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([
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'asset' => 'AAPL',
'order_id' => 12345
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-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.compasslabs.ai/v2/perpetual_trading/cancel_order"
payload := strings.NewReader("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-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.compasslabs.ai/v2/perpetual_trading/cancel_order")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/cancel_order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}"
response = http.request(request)
puts response.read_body{
"action": {
"grouping": "na",
"orders": [
{
"a": 12,
"b": true,
"p": "213.50",
"r": false,
"s": "5.00",
"t": {
"limit": {
"tif": "Gtc"
}
}
}
],
"type": "order"
},
"nonce": 1747010983250,
"typed_data": {
"domain": {
"chainId": 1337,
"name": "Exchange",
"verifyingContract": "0x0000000000000000000000000000000000000000",
"version": "1"
},
"message": {
"connectionId": "0xc4e1f04d6b1bf2f2f7a6c0e8a5f3b1d2c9e0a4b7d1c3e5f7a9b1d3e5f7a9e9a2",
"source": "a"
},
"primaryType": "Agent",
"types": {
"Agent": [
{
"name": "source",
"type": "string"
},
{
"name": "connectionId",
"type": "bytes32"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Perpetual Trading
Cancel order
Prepare an order cancellation.
Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint.
POST
/
v2
/
perpetual_trading
/
cancel_order
Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_cancel_order(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", asset="AAPL", order_id=12345)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingCancelOrder({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
asset: "AAPL",
orderId: 12345,
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/cancel_order \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"asset": "AAPL",
"order_id": 12345
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0x06A9aF046187895AcFc7258450B15397CAc67400',
asset: 'AAPL',
order_id: 12345
})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/cancel_order', 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.compasslabs.ai/v2/perpetual_trading/cancel_order",
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([
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'asset' => 'AAPL',
'order_id' => 12345
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-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.compasslabs.ai/v2/perpetual_trading/cancel_order"
payload := strings.NewReader("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-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.compasslabs.ai/v2/perpetual_trading/cancel_order")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/cancel_order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"asset\": \"AAPL\",\n \"order_id\": 12345\n}"
response = http.request(request)
puts response.read_body{
"action": {
"grouping": "na",
"orders": [
{
"a": 12,
"b": true,
"p": "213.50",
"r": false,
"s": "5.00",
"t": {
"limit": {
"tif": "Gtc"
}
}
}
],
"type": "order"
},
"nonce": 1747010983250,
"typed_data": {
"domain": {
"chainId": 1337,
"name": "Exchange",
"verifyingContract": "0x0000000000000000000000000000000000000000",
"version": "1"
},
"message": {
"connectionId": "0xc4e1f04d6b1bf2f2f7a6c0e8a5f3b1d2c9e0a4b7d1c3e5f7a9b1d3e5f7a9e9a2",
"source": "a"
},
"primaryType": "Agent",
"types": {
"Agent": [
{
"name": "source",
"type": "string"
},
{
"name": "connectionId",
"type": "bytes32"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request to cancel an open order on a perpetual trading market.
Owner of the perpetual trading product account
Example:
"0x06A9aF046187895AcFc7258450B15397CAc67400"
Asset ticker symbol (e.g. AAPL, GOLD, EUR)
Example:
"AAPL"
Hyperliquid order ID to cancel
Example:
12345
Client order ID to cancel (alternative to order_id)
Response
Successful Response
Returned by prepare endpoints — contains EIP-712 typed data for the user to sign.
Was this page helpful?
⌘I