{"format":"opendoc-document","version":1,"url":"https://docs.upscale.trade/developers/operations/closeallpositions","title":"Close all positions","description":"POST /positions/{accountId}/close-all: Closes every open position of the account at market. Stop and take orders attached to them end up as canceled by position; pending entry…","kind":"api-operation","locale":"en","inLanguage":"en","lastModified":"2026-09-28T19:22:49.100Z","revision":"25c86f549328fcff320805d5945f4c9804e3927950d831e601d6e3b18c170f66","section":{"title":"Developers","url":"https://docs.upscale.trade/developers"},"representations":{"html":"https://docs.upscale.trade/developers/operations/closeallpositions","markdown":"https://docs.upscale.trade/developers/operations/closeallpositions.md","json":"https://docs.upscale.trade/developers/operations/closeallpositions.json"},"translations":{"en":"https://docs.upscale.trade/developers/operations/closeallpositions","ru":"https://docs.upscale.trade/ru/developers/operations/closeallpositions","es":"https://docs.upscale.trade/es/developers/operations/closeallpositions"},"operation":{"id":"closeAllPositions","method":"POST","path":"/positions/{accountId}/close-all","summary":"Close all positions","description":"Closes every open position of the account at market. Stop and take orders attached to them end up as `canceled_by_position`;\npending entry orders are left alone.\n\nResponds `204` with no body.","tags":["Trading"],"deprecated":false,"parameters":[{"name":"accountId","location":"path","schema":{"type":"string · uuid","types":["string"],"nullable":false,"readOnly":false,"writeOnly":false,"constraints":{"format":"uuid"},"properties":[],"variants":[]},"type":"string · uuid","required":true,"description":"Trader account identifier. Must belong to the caller.","example":"00000000-0000-4000-8000-000000000000"}],"bodies":[],"responses":[{"status":"401","description":"Unauthorized","properties":[],"headers":[]},{"status":"403","description":"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`).","properties":[],"headers":[]},{"status":"404","description":"No account with this identifier.","properties":[],"headers":[]},{"status":"429","description":"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`.","properties":[],"headers":[]}],"security":[{"name":"bearer","type":"http · bearer","description":"Personal API key, prefixed with `usk_`.","required":true,"scopes":[]}],"codeSamples":[{"label":"cURL","language":"bash","source":"curl --request POST 'https://api.upscale.trade/positions/{accountId}/close-all' \\\n  --header 'Accept: application/json' \\\n  --header 'Authorization: Bearer YOUR_API_KEY'"},{"label":"JavaScript","language":"javascript","source":"const response = await fetch(\"https://api.upscale.trade/positions/{accountId}/close-all\", {\n  method: \"POST\",\n  headers: {\n    \"Accept\": \"application/json\",\n    \"Authorization\": \"Bearer YOUR_API_KEY\"\n  },\n});\nconsole.log(response.status, await response.text());"},{"label":"Python","language":"python","source":"import requests\n\nresponse = requests.request(\n    \"POST\",\n    \"https://api.upscale.trade/positions/{accountId}/close-all\",\n    headers={\"Accept\":\"application/json\",\"Authorization\":\"Bearer YOUR_API_KEY\"},\n    timeout=30,\n)\nprint(response.status_code, response.text)"}]},"breadcrumbs":[{"title":"What is Prop Trading","url":"https://docs.upscale.trade"},{"title":"Developers","url":"https://docs.upscale.trade/developers"},{"title":"Close all positions","url":"https://docs.upscale.trade/developers/operations/closeallpositions"}],"headings":[{"depth":2,"id":"authorization","title":"Authorization"},{"depth":2,"id":"parameters","title":"Parameters"},{"depth":2,"id":"examples","title":"Examples"},{"depth":2,"id":"responses","title":"Responses"}],"markdown":"# Close all positions\n\n`POST /positions/{accountId}/close-all`\n\nCloses every open position of the account at market. Stop and take orders attached to them end up as `canceled_by_position`;\npending entry orders are left alone.\n\nResponds `204` with no body.\n\n## Authorization\n\nbearer: http · bearer (required). Personal API key, prefixed with `usk_`.\n\n## Parameters\n\n- path: accountId (string · uuid; required). Trader account identifier. Must belong to the caller.\n\nType: string · uuid\n\nformat: uuid\n\n## Example · cURL\n\n```bash\ncurl --request POST 'https://api.upscale.trade/positions/{accountId}/close-all' \\\n  --header 'Accept: application/json' \\\n  --header 'Authorization: Bearer YOUR_API_KEY'\n```\n\n## Example · JavaScript\n\n```javascript\nconst response = await fetch(\"https://api.upscale.trade/positions/{accountId}/close-all\", {\n  method: \"POST\",\n  headers: {\n    \"Accept\": \"application/json\",\n    \"Authorization\": \"Bearer YOUR_API_KEY\"\n  },\n});\nconsole.log(response.status, await response.text());\n```\n\n## Example · Python\n\n```python\nimport requests\n\nresponse = requests.request(\n    \"POST\",\n    \"https://api.upscale.trade/positions/{accountId}/close-all\",\n    headers={\"Accept\":\"application/json\",\"Authorization\":\"Bearer YOUR_API_KEY\"},\n    timeout=30,\n)\nprint(response.status_code, response.text)\n```\n\n## Response 401\n\n**401**  — Unauthorized\n\n## Response 403\n\n**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`).\n\n## Response 404\n\n**404**  — No account with this identifier.\n\n## Response 429\n\n**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`.","text":"Close all positions Closes every open position of the account at market. Stop and take orders attached to them end up as `canceled_by_position`; pending entry orders are left alone. Responds `204` with no body. POST /positions/{accountId}/close-all Trading accountId Trader account identifier. Must belong to the caller. string · uuid 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. 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`.","api":{"title":"Upscale Public API","version":"d796ac9","documentation":"https://docs.upscale.trade/developers","playgroundServer":"https://api.upscale.trade"}}