Upscale
Menu
On this page

Close all positions and orders

Try it out ↓
POST/accounts/{accountId}/close-all
Close all positions and ordersAccounts

Cancels every active order on the account and then closes every open position at market.

  • Responds 204 with no body; the resulting fills appear in the position history and in the account events.
  • Send an x-idempotency-key header 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 with X-Idempotency-Cached: true and X-Idempotency-Timestamp) instead of acting again, and a second call arriving while the first one is still running gets 409 (idempotency_key_in_flight).
Base URL https://api.upscale.trade

Authorization

bearerhttp · bearerrequired

Personal API key, prefixed with usk_.

Parameters

Path
accountIdstring · uuidrequired

Trader account identifier. Must belong to the caller.

Example: 00000000-0000-4000-8000-000000000000
Header
x-idempotency-keystringoptional

Idempotency 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.

Example: 9f1c2b7e-5a3d-4f61-9b0e-2c7d4a8e1f35

Examples

curl --request POST 'https://api.upscale.trade/accounts/{accountId}/close-all' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer YOUR_API_KEY'

Responses

401

Unauthorized

403

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).

404

No account with this identifier.

409

Another call with the same x-idempotency-key is still running (idempotency_key_in_flight). Retry once it finishes.

429

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.