/accounts/{accountId}/close-allCancels every active order on the account and then closes every open position at market.
- Responds
204with no body; the resulting fills appear in the position history and in the account events. - Send an
x-idempotency-keyheader to make the call replay-safe: inside the replay window stated on that header, the same key on the same route replays the stored response (marked withX-Idempotency-Cached: trueandX-Idempotency-Timestamp) instead of acting again, and a second call arriving while the first one is still running gets409(idempotency_key_in_flight).
https://api.upscale.tradeParameters
accountIdstring · uuidrequiredTrader account identifier. Must belong to the caller.
00000000-0000-4000-8000-000000000000x-idempotency-keystringoptionalIdempotency key — any opaque string, a uuid v4 works well. Repeating the call with the same key on this route within 1 minute replays the stored response instead of acting again; a replay carries X-Idempotency-Cached: true and X-Idempotency-Timestamp. Omit the header to opt out.
9f1c2b7e-5a3d-4f61-9b0e-2c7d4a8e1f35Examples
curl --request POST 'https://api.upscale.trade/accounts/{accountId}/close-all' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY'const response = await fetch("https://api.upscale.trade/accounts/{accountId}/close-all", {
method: "POST",
headers: {
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
});
console.log(response.status, await response.text());import requests
response = requests.request(
"POST",
"https://api.upscale.trade/accounts/{accountId}/close-all",
headers={"Accept":"application/json","Authorization":"Bearer YOUR_API_KEY"},
timeout=30,
)
print(response.status_code, response.text)Responses
Unauthorized
The account belongs to another user (account_access_denied), or the request is authenticated with an API key while api_trading is disabled on the account (api_trading_not_enabled).
No account with this identifier.
Another call with the same x-idempotency-key is still running (idempotency_key_in_flight). Retry once it finishes.
Rate limit of the API key exceeded (api_key_rate_limit_exceeded). Retry-After says when to come back; the body carries the bucket (read / write), the window that tripped, its limit and retryAt.