Skip to content

Cancel order#

POST https://api.pro.anboto.xyz/api/v2/trading/order/cancel

This will initiate a cancellation request and set the order state to pending cancel. For the finalized state call /order/id?orderId=xxx ApiKeyAuth required.

Body params#

order_id integer
The Anboto generated order id
Example: 123456
client_order_id string
The client provided order id
Example: xxx-yyy-zzzz

Headers#

Header
X-API-KEY string required
X-TIMESTAMP int64 ms required
X-SIGN string required
X-RECV-WINDOW int, default 5000

Responses#

200 Cancellation request processed and in progress.
401 Unauthorized, Invalid Signature
429 Rate limit exceeded, retry later

Response fields — OrderSummary#

order_id integer
The Anboto assigned order identifier
client_order_id string
A custom string to identify the order
Example: ABC-12345^12-10-23
status enum
The order status — PENDING_NEW, ACCEPTED, REJECTED, PARTIALLY_FILLED, FILLED, PENDING_CANCEL, CANCELLED, PENDING_PAUSE, … (12 values)
created_at date-time required
The time in UTC when the order was created
Example: 2024-01-22T22:05:00Z
message string
Any additional information, usually if the order was rejected
error_code enum
The error code used to describe why an order was rejected. — OTHER, QUANTITY_EXCEED, AUTHENTICATION_ERROR, INSUFFICIENT_FUNDS, RATE_LIMIT_EXCEEDED, DDOS_PROTECTION, EXCHANGE_NOT_AVAILABLE, NETWORK_ERROR, … (34 values)
Example: INVALID_ORDER
body='{
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
}'

curl -X POST "$BASE/api/v2/trading/order/cancel" \
  -H "X-API-KEY: $API_KEY" -H "X-TIMESTAMP: $ts" \
  -H "X-SIGN: $sign" \
  -H "Content-Type: application/json" -d "$body"
payload = {
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
}

r = requests.post(f"{BASE}/api/v2/trading/order/cancel",
    data=json.dumps(payload)
    headers=signed_headers(payload))
print(r.json())
let payload = serde_json::json!({
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
});

let resp = client
    .post(format!("{BASE}/api/v2/trading/order/cancel"))
    .headers(signed_headers(&payload))
    .json(&payload)
    .send()?;
println!("{}", resp.text()?);
payload := map[string]any{
    "order_id": 123456,
    "client_order_id": "xxx-yyy-zzzz",
}
body, _ := json.Marshal(payload)

req, _ := http.NewRequest("POST", BASE+"/api/v2/trading/order/cancel", bytes.NewReader(body))
for k, v := range signedHeaders(string(body)) {
    req.Header.Set(k, v)
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer resp.Body.Close()
io.Copy(os.Stdout, resp.Body)
String jsonBody = mapper.writeValueAsString(payload);
HttpResponse<String> resp = client.send(
    signedPost("/api/v2/trading/order/cancel", jsonBody),
    HttpResponse.BodyHandlers.ofString());
const payload: CancelUpstreamOrderRequest = {
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
};

const res = await fetch(`${BASE}/api/v2/trading/order/cancel`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
const data: OrderSummary = await res.json();
val jsonBody = mapper.writeValueAsString(payload)
val request = signedPost("/api/v2/trading/order/cancel", jsonBody)
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
println(response.body())
std::string body = R"({
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
})";

cpr::Response r = cpr::Post(
    cpr::Url{BASE + "/api/v2/trading/order/cancel"},
    signedHeaders(body),
    cpr::Header{{"Content-Type", "application/json"}},
    cpr::Body{body});
std::cout << r.text << std::endl;
const payload = {
  "order_id": 123456,
  "client_order_id": "xxx-yyy-zzzz"
};

const res = await fetch(`${BASE}/api/v2/trading/order/cancel`, {
  method: "POST",
  headers: signedHeaders(payload),
  body: JSON.stringify(payload),
});
console.log(await res.json());

Response 200

{
  "order_id": 0,
  "client_order_id": "ABC-12345^12-10-23",
  "status": "PENDING_NEW",
  "created_at": "2024-01-22T22:05:00Z",
  "message": "string",
  "error_code": "OTHER"
}