curl --request POST \
--url https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel \
--header 'Api-Access-Key: <api-key>' \
--header 'Api-Signature: <api-signature>' \
--header 'Api-Timestamp: <api-timestamp>' \
--header 'Idempotency-Key: <idempotency-key>'import requests
url = "https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel"
headers = {
"Idempotency-Key": "<idempotency-key>",
"Api-Signature": "<api-signature>",
"Api-Timestamp": "<api-timestamp>",
"Api-Access-Key": "<api-key>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'Api-Signature': '<api-signature>',
'Api-Timestamp': '<api-timestamp>',
'Api-Access-Key': '<api-key>'
}
};
fetch('https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"externalId": "9d2c6a1e-4f7b-4c3d-8e5a-1b2c3d4e5f6a"
}
}Cancel an order
Permissions required: Execute trades
Requests cancellation of an order.
Cancellation is asynchronous: a successful response means the
cancel request was accepted, and only the order ID and external
ID are returned. The order moves to status CANCELING, and once
the cancellation is confirmed, to CANCELED (nothing was
executed) or PARTIALLY_CANCELED (partially executed before
cancellation; the filled portion stands). Use the order lookup
endpoint to observe the cancellation state.
Canceling an order that is already in CANCELING is
idempotent: the request succeeds again.
Orders that cannot be canceled are rejected with 409
ORDER_NOT_CANCELABLE. This includes orders already in a terminal
state (FILLED, CANCELED, PARTIALLY_CANCELED, EXPIRED,
REJECTED) and orders that execute immediately (FOK and IOC,
including all MARKET orders).
Rejections. A request that passes schema validation but breaks a
business rule returns the listed status with a message of the
form <rejectCode>: <detail>, where <rejectCode> is one of the
rejectCode values of the Order schema. A request that fails
schema validation, such as a malformed field, returns 400 with
the validator’s message and no code.
An unknown order, or one not visible through the given
accountId, returns 404 with the message order not found and
no code.
curl --request POST \
--url https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel \
--header 'Api-Access-Key: <api-key>' \
--header 'Api-Signature: <api-signature>' \
--header 'Api-Timestamp: <api-timestamp>' \
--header 'Idempotency-Key: <idempotency-key>'import requests
url = "https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel"
headers = {
"Idempotency-Key": "<idempotency-key>",
"Api-Signature": "<api-signature>",
"Api-Timestamp": "<api-timestamp>",
"Api-Access-Key": "<api-key>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'Api-Signature': '<api-signature>',
'Api-Timestamp': '<api-timestamp>',
'Api-Access-Key': '<api-key>'
}
};
fetch('https://api.anchorage-staging.com/v4/accounts/{accountId}/orders/{orderId}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"data": {
"id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"externalId": "9d2c6a1e-4f7b-4c3d-8e5a-1b2c3d4e5f6a"
}
}Headers
Path Parameters
Was this page helpful?