Cancel order
curl --request POST \
--url https://api.hyperliquid.xyz/exchange \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"type": "cancel",
"cancels": [
{
"a": 0,
"o": 123456789
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": null
}
'import requests
url = "https://api.hyperliquid.xyz/exchange"
payload = {
"action": {
"type": "cancel",
"cancels": [
{
"a": 0,
"o": 123456789
}
]
},
"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: 'cancel', cancels: [{a: 0, o: 123456789}]},
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' => 'cancel',
'cancels' => [
[
'a' => 0,
'o' => 123456789
]
]
],
'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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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": "ok",
"response": {
"type": "cancel",
"data": {
"statuses": [
"success"
]
}
}
}Hyperliquid node API
Cancel order | Hyperliquid exchange
Cancels one or multiple open orders by order ID (oid) on the Hyperliquid exchange. Available on Hyperliquid exchange via Chainstack.
POST
/
exchange
Cancel order
curl --request POST \
--url https://api.hyperliquid.xyz/exchange \
--header 'Content-Type: application/json' \
--data '
{
"action": {
"type": "cancel",
"cancels": [
{
"a": 0,
"o": 123456789
}
]
},
"nonce": 1705234567890,
"signature": {
"r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"s": "0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321",
"v": 27
},
"vaultAddress": null
}
'import requests
url = "https://api.hyperliquid.xyz/exchange"
payload = {
"action": {
"type": "cancel",
"cancels": [
{
"a": 0,
"o": 123456789
}
]
},
"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: 'cancel', cancels: [{a: 0, o: 123456789}]},
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' => 'cancel',
'cancels' => [
[
'a' => 0,
'o' => 123456789
]
]
],
'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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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\": \"cancel\",\n \"cancels\": [\n {\n \"a\": 0,\n \"o\": 123456789\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": "ok",
"response": {
"type": "cancel",
"data": {
"statuses": [
"success"
]
}
}
}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"cancel"cancels(array) — Array of cancel objects with:a(number) — Asset indexo(number) — Order ID to cancel
-
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—"cancel"data.statuses— Array of status results:"success"— Order successfully cancelederror— Object with error message if cancellation failed
Example request
curl -X POST https://api.hyperliquid.xyz/exchange \
-H "Content-Type: application/json" \
-d '{
"action": {
"type": "cancel",
"cancels": [{
"a": 0,
"o": 77738308
}]
},
"nonce": 1234567890123,
"signature": {...}
}'
from hyperliquid.exchange import Exchange
from hyperliquid.utils import constants
import eth_account
# Initialize with your private key
account = eth_account.Account.from_key("0x...")
exchange = Exchange(account, constants.MAINNET_API_URL)
# Cancel a single order by ID
cancel_result = exchange.cancel(name="BTC", oid=77738308)
print(cancel_result)
# Cancel multiple orders in one request
cancel_results = exchange.bulk_cancel([
{"coin": "BTC", "oid": 77738308},
{"coin": "ETH", "oid": 77738309},
])
print(cancel_results)
import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
import { privateKeyToAccount } from "viem/accounts";
// Initialize with your private key
const wallet = privateKeyToAccount("0x...");
const transport = new HttpTransport();
const exchange = new ExchangeClient({ transport, wallet });
// Cancel one or multiple orders by asset index (a) and order ID (o)
const cancelResult = await exchange.cancel({
cancels: [{ a: 0, o: 77738308 }],
});
console.log(cancelResult);
Response examples
Successful cancellation
{
"status": "ok",
"response": {
"type": "cancel",
"data": {
"statuses": [
"success"
]
}
}
}
Failed cancellation
{
"status": "ok",
"response": {
"type": "cancel",
"data": {
"statuses": [{
"error": "Order was never placed, already canceled, or filled."
}]
}
}
}
Multiple orders mixed results
{
"status": "ok",
"response": {
"type": "cancel",
"data": {
"statuses": [
"success",
{
"error": "Order was never placed, already canceled, or filled."
}
]
}
}
}
Use cases
- Risk management — Quickly cancel orders when market conditions change
- Order management — Clean up open orders that are no longer needed
- Algorithmic trading — Programmatically manage order lifecycle
- Portfolio rebalancing — Cancel orders before placing new ones
You can cancel multiple orders in a single request by including multiple objects in the
cancels array. Each cancellation is processed independently.Attempting to cancel an order that doesn’t exist, was already canceled, or was filled will return an error but won’t affect other cancellations in the same request.
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?