Cancel working orders on an account
Cancels an account’s working orders without closing any position, with the organization API key. Positions stay open, and the account keeps its status and is not locked out.
- Default: every working order is cancelled except the take-profit and stop-loss orders protecting an open position. Cancelling an entry order also cancels the take-profit and stop-loss attached to it. This matches a trader’s “Cancel all”.
includeExits: true: the take-profit and stop-loss orders of open positions are cancelled too.contract: only that contract’s orders are considered; other contracts are untouched.
Works while the market is closed. Each cancelled order appears on the real-time stream (OrderCancelled) and in order history with reason Admin cancel: <who> — <your reason> (trigger admin_flatten). When anything was cancelled, an ACCOUNT_UPDATED event (trigger admin_orders_cancel) lands on the account’s event log and goes to account.updated webhooks.
Retries: safe. A repeated call cancels nothing more and answers 200 with ordersCancelled: 0; an Idempotency-Key header returns the first answer instead.
To close a position as well, use POST .../positions/{contract}/close or POST .../flatten.
Requires manage permission on traders.
curl -X POST "https://api.hyperprop.com/platform/v1/organization/trading-accounts/7c9e6679-7425-40de-944b-e07fc1f90ae7/orders/cancel" \
-H "X-API-Key: hp_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"reason": "Risk review", "contract": "MNQZ6"}'
curl --request POST \
--url https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"reason": "Risk review",
"contract": "MNQZ6",
"includeExits": false
}
'import requests
url = "https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel"
payload = {
"reason": "Risk review",
"contract": "MNQZ6",
"includeExits": False
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Risk review', contract: 'MNQZ6', includeExits: false})
};
fetch('https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel', 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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel",
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([
'reason' => 'Risk review',
'contract' => 'MNQZ6',
'includeExits' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel"
payload := strings.NewReader("{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"accountId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"accountNumber": "ACC-50K-000123",
"contract": "MNQZ6",
"includeExits": false,
"ordersCancelled": 2,
"exitsKept": 2,
"orders": [
{
"orderId": "<string>",
"contract": "MNQZ6",
"side": "buy",
"type": "limit",
"quantity": 1,
"filledQuantity": 0,
"limitPrice": 19950.25,
"stopPrice": null,
"exit": false,
"status": "cancelled",
"reason": "Admin cancel: API key — Risk review"
}
],
"reason": "Admin cancel: API key — Risk review"
}
}{
"success": false,
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR"
}{
"success": false,
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication required",
"code": "UNAUTHORIZED"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Your role does not have write access to \"Traders & accounts\"",
"code": "INSUFFICIENT_PERMISSIONS"
}{
"success": false,
"statusCode": 404,
"error": "Not Found",
"message": "Trading account not found",
"code": "ACCOUNT_NOT_FOUND"
}{
"success": false,
"statusCode": 409,
"error": "Conflict",
"message": "A request with this Idempotency-Key is still in progress",
"code": "IDEMPOTENCY_KEY_IN_PROGRESS"
}{
"success": false,
"statusCode": 500,
"error": "Internal Server Error",
"message": "An unexpected error occurred",
"code": "INTERNAL_ERROR"
}{
"success": false,
"statusCode": 502,
"error": "Error",
"message": "The trading engine could not be reached; nothing was cancelled",
"code": "ENGINE_UNAVAILABLE"
}{
"success": false,
"statusCode": 504,
"error": "Error",
"message": "The trading engine did not answer in time; some orders may have been cancelled. Retrying is safe.",
"code": "CANCEL_OUTCOME_UNKNOWN"
}Authorizations
Organization API key. Format: "hp_live_{key}". Organization admins manage the key in the dashboard.
Path Parameters
Trading account ID
Body
Why the orders are being cancelled. Recorded on each cancelled order and on the account's event log.
3 - 200"Risk review"
Only cancel orders on this contract. Omit to cancel on every contract.
^[A-Za-z0-9._-]{1,40}$"MNQZ6"
Also cancel the take-profit and stop-loss orders of open positions, leaving them unprotected. Default false: they stay.
false
curl --request POST \
--url https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"reason": "Risk review",
"contract": "MNQZ6",
"includeExits": false
}
'import requests
url = "https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel"
payload = {
"reason": "Risk review",
"contract": "MNQZ6",
"includeExits": False
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: 'Risk review', contract: 'MNQZ6', includeExits: false})
};
fetch('https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel', 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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel",
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([
'reason' => 'Risk review',
'contract' => 'MNQZ6',
'includeExits' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel"
payload := strings.NewReader("{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/platform/v1/organization/trading-accounts/{accountId}/orders/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"Risk review\",\n \"contract\": \"MNQZ6\",\n \"includeExits\": false\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"accountId": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"accountNumber": "ACC-50K-000123",
"contract": "MNQZ6",
"includeExits": false,
"ordersCancelled": 2,
"exitsKept": 2,
"orders": [
{
"orderId": "<string>",
"contract": "MNQZ6",
"side": "buy",
"type": "limit",
"quantity": 1,
"filledQuantity": 0,
"limitPrice": 19950.25,
"stopPrice": null,
"exit": false,
"status": "cancelled",
"reason": "Admin cancel: API key — Risk review"
}
],
"reason": "Admin cancel: API key — Risk review"
}
}{
"success": false,
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed",
"code": "VALIDATION_ERROR"
}{
"success": false,
"statusCode": 401,
"error": "Unauthorized",
"message": "Authentication required",
"code": "UNAUTHORIZED"
}{
"statusCode": 403,
"error": "Forbidden",
"message": "Your role does not have write access to \"Traders & accounts\"",
"code": "INSUFFICIENT_PERMISSIONS"
}{
"success": false,
"statusCode": 404,
"error": "Not Found",
"message": "Trading account not found",
"code": "ACCOUNT_NOT_FOUND"
}{
"success": false,
"statusCode": 409,
"error": "Conflict",
"message": "A request with this Idempotency-Key is still in progress",
"code": "IDEMPOTENCY_KEY_IN_PROGRESS"
}{
"success": false,
"statusCode": 500,
"error": "Internal Server Error",
"message": "An unexpected error occurred",
"code": "INTERNAL_ERROR"
}{
"success": false,
"statusCode": 502,
"error": "Error",
"message": "The trading engine could not be reached; nothing was cancelled",
"code": "ENGINE_UNAVAILABLE"
}{
"success": false,
"statusCode": 504,
"error": "Error",
"message": "The trading engine did not answer in time; some orders may have been cancelled. Retrying is safe.",
"code": "CANCEL_OUTCOME_UNKNOWN"
}