Cancel order by cloid
curl --request POST \
--url https://api.hyperliquid.xyz/exchange \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"type": "cancelByCloid",
"cancels": [
{
"asset": 0,
"cloid": "0x1234567890abcdef1234567890abcdef"
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": null
}
'import requests
url = "https://api.hyperliquid.xyz/exchange"
payload = {
"action": {
"type": "cancelByCloid",
"cancels": [
{
"asset": 0,
"cloid": "0x1234567890abcdef1234567890abcdef"
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": None
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
action: {
type: 'cancelByCloid',
cancels: [{asset: 0, cloid: '0x1234567890abcdef1234567890abcdef'}]
},
nonce: 1705234567890,
signature: {
r: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
s: '0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321',
v: 27
},
vaultAddress: null
})
};
fetch('https://api.hyperliquid.xyz/exchange', 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.hyperliquid.xyz/exchange",
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([
'action' => [
'type' => 'cancelByCloid',
'cancels' => [
[
'asset' => 0,
'cloid' => '0x1234567890abcdef1234567890abcdef'
]
]
],
'nonce' => 1705234567890,
'signature' => [
'r' => '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
's' => '0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321',
'v' => 27
],
'vaultAddress' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.hyperliquid.xyz/exchange"
payload := strings.NewReader("{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
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.hyperliquid.xyz/exchange")
.header("Content-Type", "application/json")
.body("{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperliquid.xyz/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"response": {
"type": "<string>",
"data": {
"statuses": "<array>"
}
}
}Hyperliquid node API
Cancel order by cloid | Hyperliquid exchange
Cancels one or multiple open orders by client order ID (cloid) on the Hyperliquid exchange. Chainstack Hyperliquid exchange reference.
POST
/
exchange
Cancel order by cloid
curl --request POST \
--url https://api.hyperliquid.xyz/exchange \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"type": "cancelByCloid",
"cancels": [
{
"asset": 0,
"cloid": "0x1234567890abcdef1234567890abcdef"
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": null
}
'import requests
url = "https://api.hyperliquid.xyz/exchange"
payload = {
"action": {
"type": "cancelByCloid",
"cancels": [
{
"asset": 0,
"cloid": "0x1234567890abcdef1234567890abcdef"
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": None
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
action: {
type: 'cancelByCloid',
cancels: [{asset: 0, cloid: '0x1234567890abcdef1234567890abcdef'}]
},
nonce: 1705234567890,
signature: {
r: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
s: '0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321',
v: 27
},
vaultAddress: null
})
};
fetch('https://api.hyperliquid.xyz/exchange', 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.hyperliquid.xyz/exchange",
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([
'action' => [
'type' => 'cancelByCloid',
'cancels' => [
[
'asset' => 0,
'cloid' => '0x1234567890abcdef1234567890abcdef'
]
]
],
'nonce' => 1705234567890,
'signature' => [
'r' => '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
's' => '0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321',
'v' => 27
],
'vaultAddress' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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.hyperliquid.xyz/exchange"
payload := strings.NewReader("{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
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.hyperliquid.xyz/exchange")
.header("Content-Type", "application/json")
.body("{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperliquid.xyz/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {\n \"type\": \"cancelByCloid\",\n \"cancels\": [\n {\n \"asset\": 0,\n \"cloid\": \"0x1234567890abcdef1234567890abcdef\"\n }\n ]\n },\n \"nonce\": 1705234567890,\n \"signature\": {\n \"r\": \"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef\",\n \"s\": \"0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321\",\n \"v\": 27\n },\n \"vaultAddress\": null\n}"
response = http.request(request)
puts response.read_body{
"status": "<string>",
"response": {
"type": "<string>",
"data": {
"statuses": "<array>"
}
}
}You can only use this endpoint on the official Hyperliquid public API. It is not available through Chainstack, as the open-source node implementation does not support it yet. See Hyperliquid methods for the full availability breakdown.
This endpoint requires signature authentication. See our comprehensive Authentication via Signatures guide for implementation details.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
Required parameters
-
action(object, required) — The cancel action object containing:type(string) — Must be"cancelByCloid"cancels(array) — Array of cancel objects with:asset(number) — Asset indexcloid(string) — Client order ID (128-bit hex string, e.g.,0x1234567890abcdef1234567890abcdef)
-
nonce(number, required) — Current timestamp in milliseconds (must be recent) -
signature(object, required) — EIP-712 signature of the action
Optional parameters
vaultAddress(string, optional) — Address when trading on behalf of a vault or subaccountexpiresAfter(number, optional) — Timestamp in milliseconds after which the request is rejected
Returns
Returns an object with cancellation status:status—"ok"if request processedresponse— Contains cancellation details:type—"cancelByCloid"data.statuses— Array of status results for each cancellation attempt
Example request
curl -X POST https://api.hyperliquid.xyz/exchange \
-H "Content-Type: application/json" \
-d '{
"action": {
"type": "cancelByCloid",
"cancels": [{
"asset": 0,
"cloid": "0x1234567890abcdef1234567890abcdef"
}]
},
"nonce": 1234567890123,
"signature": {...}
}'
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants
from hyperliquid.utils.types import Cloid
import eth_account
# Initialize with your private key
account = eth_account.Account.from_key("0x...")
exchange = Exchange(account, constants.MAINNET_API_URL)
# Cancel an order by client order ID
cancel_result = exchange.cancel_by_cloid(
name="BTC",
cloid=Cloid.from_str("0x1234567890abcdef1234567890abcdef"),
)
print(cancel_result)
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";
// Set up the client with a wallet and the public transport
const wallet = privateKeyToAccount("0x...");
const transport = new HttpTransport();
const exchange = new ExchangeClient({ transport, wallet });
// Cancel an order by client order ID
const result = await exchange.cancelByCloid({
cancels: [
{ asset: 0, cloid: "0x1234567890abcdef1234567890abcdef" },
],
});
console.log(result);
Client Order ID (cloid)
The client order ID is a 128-bit hexadecimal string that you provide when placing an order. It allows you to:- Track orders using your own identification system
- Cancel orders without needing to store exchange-generated order IDs
- Implement idempotent order placement strategies
0x1234567890abcdef1234567890abcdef
Use cases
- Custom order tracking — Cancel orders using your internal order management system IDs
- Failover systems — Cancel orders without needing to query order IDs first
- Multi-system integration — Use consistent order IDs across different systems
- Idempotent operations — Safely retry cancellations using deterministic IDs
Client order IDs must be unique per user. Attempting to place an order with a duplicate cloid will be rejected.
Make sure to store the cloid when placing orders if you plan to use this cancellation method. The cloid must match exactly what was provided during order placement.
Body
application/json
Show child attributes
Show child attributes
Current timestamp in milliseconds
EIP-712 signature of the action with r, s, v components
Show child attributes
Show child attributes
Address when trading on behalf of a vault or subaccount (optional)
Timestamp in milliseconds after which the request is rejected (optional)
Last modified on June 24, 2026
Was this page helpful?