Improved

Error details documented on the close all positions endpoint

Broker API

Documents the per-position result returned when closing all positions for an account. The wire contract is unchanged.

  • The 207 response now describes both outcomes: when a result's status is 200, body is the Order created to close the position; for any other status, body is the error object explaining why that position was not closed.
  • Adds a documented 422 response for a request-level failure such as an invalid cancel_orders value, returned as a single Error with code 40010001 before any per-position results.
  • Clarifies that request-level failure responses contain no per-position results, and that positions that fail to close are reported in the 207 response.
  • Documents Error.code (Alpaca error code, usually the HTTP status followed by a five-digit suffix) and Error.message, and lists the optional fields the server can include on a rejected close: symbol, existing_qty, held_for_orders, and available.

Affected Endpoints

  • DELETE /v1/trading/accounts/{account_id}/positions