# Cancel a pending limit order by ID.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
ORDER_ID='afc47108-d059-473c-b2e1-5f2ca7951466' # from POST /limit-order
METHOD=DELETE
ENDPOINT="/limit-order/$ORDER_ID"
QUERY=''
BODY='' # DELETE has no body: the signature covers the empty string
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type LimitOrder = { id: string; status: string; deletedAt: string };
const orderId = "afc47108-d059-473c-b2e1-5f2ca7951466"; // from POST /limit-order
const current = await olympexRequest<LimitOrder>("GET", `/limit-order/${orderId}`);
if (current.status !== "pending") throw new Error(`The order is ${current.status}; only pending orders can be cancelled`);
const cancelled = await olympexRequest<LimitOrder>("DELETE", `/limit-order/${orderId}`);
console.log(cancelled.status, cancelled.deletedAt); // "cancelled", an ISO 8601 time
// Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
from sign_request import olympex_request # /authentication/sign-requests
order_id = "afc47108-d059-473c-b2e1-5f2ca7951466" # from POST /limit-order
current = olympex_request("GET", f"/limit-order/{order_id}")
if current["status"] != "pending":
raise RuntimeError(f'The order is {current["status"]}; only pending orders can be cancelled')
cancelled = olympex_request("DELETE", f"/limit-order/{order_id}")
print(cancelled["status"], cancelled["deletedAt"]) # "cancelled", an ISO 8601 time
# Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
{
"success": true,
"data": {
"id": "afc47108-d059-473c-b2e1-5f2ca7951466",
"accountTo": "0x1E67cb01969D79B2B895179e4A07D24a839dBb52",
"chainId": 137,
"gasPrice": "35",
"inTokenAddress": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
"outTokenAddress": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
"slippage": "1",
"tokenASymbol": "ETH",
"tokenBSymbol": "USDC",
"amount": 0.5,
"price": 4300,
"priceTrigger": 4300,
"expired": "1791302400000",
"txHash": "",
"status": "cancelled",
"reasonFail": [],
"attemptNumber": 0,
"allowance": "",
"estimateGas": "",
"effectivePriceGas": "",
"createdAt": "2026-09-29T16:01:22.237Z",
"updatedAt": "2026-09-29T16:01:23.835Z",
"deletedAt": "2026-09-29T16:01:23.835Z"
},
"meta": {
"requestId": "EeARGj0boAMEcoQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Limit order not found",
"details": []
},
"meta": {
"requestId": "EdjeXjypoAMEbrQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Limit order can only be modified while pending (current status: cancelled)",
"details": []
},
"meta": {
"requestId": "E7ei6hBIIAMEPZg=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"message": "Forbidden"
}
Cancel a limit order
Cancel a pending limit order, then lower the token allowance if no other order needs it.
# Cancel a pending limit order by ID.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
ORDER_ID='afc47108-d059-473c-b2e1-5f2ca7951466' # from POST /limit-order
METHOD=DELETE
ENDPOINT="/limit-order/$ORDER_ID"
QUERY=''
BODY='' # DELETE has no body: the signature covers the empty string
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type LimitOrder = { id: string; status: string; deletedAt: string };
const orderId = "afc47108-d059-473c-b2e1-5f2ca7951466"; // from POST /limit-order
const current = await olympexRequest<LimitOrder>("GET", `/limit-order/${orderId}`);
if (current.status !== "pending") throw new Error(`The order is ${current.status}; only pending orders can be cancelled`);
const cancelled = await olympexRequest<LimitOrder>("DELETE", `/limit-order/${orderId}`);
console.log(cancelled.status, cancelled.deletedAt); // "cancelled", an ISO 8601 time
// Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
from sign_request import olympex_request # /authentication/sign-requests
order_id = "afc47108-d059-473c-b2e1-5f2ca7951466" # from POST /limit-order
current = olympex_request("GET", f"/limit-order/{order_id}")
if current["status"] != "pending":
raise RuntimeError(f'The order is {current["status"]}; only pending orders can be cancelled')
cancelled = olympex_request("DELETE", f"/limit-order/{order_id}")
print(cancelled["status"], cancelled["deletedAt"]) # "cancelled", an ISO 8601 time
# Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
{
"success": true,
"data": {
"id": "afc47108-d059-473c-b2e1-5f2ca7951466",
"accountTo": "0x1E67cb01969D79B2B895179e4A07D24a839dBb52",
"chainId": 137,
"gasPrice": "35",
"inTokenAddress": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
"outTokenAddress": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
"slippage": "1",
"tokenASymbol": "ETH",
"tokenBSymbol": "USDC",
"amount": 0.5,
"price": 4300,
"priceTrigger": 4300,
"expired": "1791302400000",
"txHash": "",
"status": "cancelled",
"reasonFail": [],
"attemptNumber": 0,
"allowance": "",
"estimateGas": "",
"effectivePriceGas": "",
"createdAt": "2026-09-29T16:01:22.237Z",
"updatedAt": "2026-09-29T16:01:23.835Z",
"deletedAt": "2026-09-29T16:01:23.835Z"
},
"meta": {
"requestId": "EeARGj0boAMEcoQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Limit order not found",
"details": []
},
"meta": {
"requestId": "EdjeXjypoAMEbrQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Limit order can only be modified while pending (current status: cancelled)",
"details": []
},
"meta": {
"requestId": "E7ei6hBIIAMEPZg=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"message": "Forbidden"
}
DELETE /limit-order/{id} cancels a pending order: its status becomes cancelled and deletedAt records the time of the call. The order isn’t removed: it stays readable with GET /limit-order/{id} and stays in GET /limit-order. Cancelling doesn’t change the maker’s token allowance, so lower it yourself if no other order needs it.
Cancel pending orders only
Read the order withGET /limit-order/{id} first, and cancel it only while its status is pending. At executing or submitted, Olympex is already executing the order.
Olympex cancels only a pending order. On any other status, including an order you already cancelled, DELETE returns 409 CONFLICT and changes nothing. DELETE is still safe to repeat after a timeout: if the repeat returns 409, read the order with GET /limit-order/{id}, and if it’s cancelled, the first call went through.
Lower the allowance
- If no other open limit order or active DCA strategy sells the same token on the same chain, set the allowance to
0. - Otherwise, lower it to what those orders and strategies still need, as How much to approve explains.
- Setting the allowance to
0stops every limit order and DCA strategy that sells that token on that chain, not only this one.
0 looks like this:
// npm install ethers. Reads WALLET_PRIVATE_KEY and POLYGON_RPC_URL from the environment.
import { Contract, JsonRpcProvider, Wallet } from "ethers";
const ORDER_CONTRACT = "0x50186B03dc7315271FB58da0d3b9f2c65A51dA76"; // Polygon. Every chain: /concepts/order-authorization#the-order-contract
const WETH = "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619"; // the token the cancelled order sold
const wallet = new Wallet(process.env.WALLET_PRIVATE_KEY!, new JsonRpcProvider(process.env.POLYGON_RPC_URL));
const weth = new Contract(WETH, ["function approve(address spender, uint256 amount) returns (bool)"], wallet);
await (await weth.approve(ORDER_CONTRACT, 0n)).wait();
0 before a new non-zero value. To lower the allowance to another non-zero value, use setOrderAllowance from Set the allowance, which resets it to 0 first.
# Cancel a pending limit order by ID.
# Needs openssl, curl and OLYMPEX_API_KEY_ID, OLYMPEX_SECRET_KEY, OLYMPEX_PASSPHRASE.
ORDER_ID='afc47108-d059-473c-b2e1-5f2ca7951466' # from POST /limit-order
METHOD=DELETE
ENDPOINT="/limit-order/$ORDER_ID"
QUERY=''
BODY='' # DELETE has no body: the signature covers the empty string
TS="${OLYMPEX_TIMESTAMP:-$(date +%s)}"
NONCE="${OLYMPEX_NONCE:-$(openssl rand -hex 12)}"
BODY_HASH="$(printf '%s' "$BODY" | openssl dgst -sha256 -binary | openssl base64 -A | tr '+/' '-_' | tr -d '=')"
VALUE_INFO="$(printf '%s\n%s\n%s' "$TS" "$NONCE" "$BODY_HASH")"
MESSAGE="$(printf 'OLPX-HMAC-SHA256-V2\n%s\n%s\n%s\n%s\n%s\n%s' "$TS" "$NONCE" "$METHOD" "/api/v1$ENDPOINT" "$QUERY" "$BODY_HASH")"
curl -sS -X "$METHOD" "https://api-rest.olympex.io/api/v1$ENDPOINT${QUERY:+?$QUERY}" \
-H "content-type: application/json" \
-H "x-api-key-id: $OLYMPEX_API_KEY_ID" \
-H "x-value-info: $(printf '%s' "$VALUE_INFO" | openssl base64 -A)" \
-H "x-passphrase: $OLYMPEX_PASSPHRASE" \
-H "x-signature: $(printf '%s' "$MESSAGE" | openssl dgst -sha256 -hmac "$OLYMPEX_SECRET_KEY" -binary | od -An -v -tx1 | tr -d ' \n')"
import { olympexRequest } from "./sign-request.ts"; // /authentication/sign-requests
type LimitOrder = { id: string; status: string; deletedAt: string };
const orderId = "afc47108-d059-473c-b2e1-5f2ca7951466"; // from POST /limit-order
const current = await olympexRequest<LimitOrder>("GET", `/limit-order/${orderId}`);
if (current.status !== "pending") throw new Error(`The order is ${current.status}; only pending orders can be cancelled`);
const cancelled = await olympexRequest<LimitOrder>("DELETE", `/limit-order/${orderId}`);
console.log(cancelled.status, cancelled.deletedAt); // "cancelled", an ISO 8601 time
// Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
from sign_request import olympex_request # /authentication/sign-requests
order_id = "afc47108-d059-473c-b2e1-5f2ca7951466" # from POST /limit-order
current = olympex_request("GET", f"/limit-order/{order_id}")
if current["status"] != "pending":
raise RuntimeError(f'The order is {current["status"]}; only pending orders can be cancelled')
cancelled = olympex_request("DELETE", f"/limit-order/{order_id}")
print(cancelled["status"], cancelled["deletedAt"]) # "cancelled", an ISO 8601 time
# Next: lower the maker's allowance to the Olympex order contract if no other order needs it.
{
"success": true,
"data": {
"id": "afc47108-d059-473c-b2e1-5f2ca7951466",
"accountTo": "0x1E67cb01969D79B2B895179e4A07D24a839dBb52",
"chainId": 137,
"gasPrice": "35",
"inTokenAddress": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
"outTokenAddress": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
"slippage": "1",
"tokenASymbol": "ETH",
"tokenBSymbol": "USDC",
"amount": 0.5,
"price": 4300,
"priceTrigger": 4300,
"expired": "1791302400000",
"txHash": "",
"status": "cancelled",
"reasonFail": [],
"attemptNumber": 0,
"allowance": "",
"estimateGas": "",
"effectivePriceGas": "",
"createdAt": "2026-09-29T16:01:22.237Z",
"updatedAt": "2026-09-29T16:01:23.835Z",
"deletedAt": "2026-09-29T16:01:23.835Z"
},
"meta": {
"requestId": "EeARGj0boAMEcoQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Limit order not found",
"details": []
},
"meta": {
"requestId": "EdjeXjypoAMEbrQ=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"success": false,
"error": {
"code": "CONFLICT",
"message": "Limit order can only be modified while pending (current status: cancelled)",
"details": []
},
"meta": {
"requestId": "E7ei6hBIIAMEPZg=",
"version": "v1",
"accountType": "integrator",
"apiKeyId": "00000000-0000-4000-8000-000000000000"
}
}
{
"message": "Forbidden"
}
Authorizations
Your API key ID (UUID). See Sign requests.
Lowercase hex HMAC-SHA256 (signature v2), keyed with your secret key string (UTF-8, not decoded), of seven lines joined with \n, with no trailing newline: OLPX-HMAC-SHA256-V2, timestamp, nonce, the uppercase method, path, canonicalQuery and bodyHash. path is the request path including /api/v1, without the query string, for example /api/v1/limit-order/<id>. canonicalQuery is the query parameters decoded (+ is a space), sorted by key and then by value, re-encoded per RFC 3986 and joined with &, or the empty string when there is no query. Headers signed for one request are rejected on any other. See Sign requests.
Was this page helpful?
