PearPear
API IntegrationAPI SpecificationTrade

Close all positions

Close all positions using MARKET execution type

POST
/trade/close-all
x-api-key<token>

In: header

Header Parameters

X-Trade-Account-Id*string

UUID of the trade account the request acts on. Must belong to the authenticated user.

Formatuuid

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/trade/close-all" \  -H "X-Trade-Account-Id: 3fa85f64-5717-4562-b3fc-2c963f66afa6" \  -H "Content-Type: application/json" \  -d '{    "type": "MARKET"  }'
{  "executions": [    {      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",      "connector": "hyperliquid",      "intent": "OPEN",      "orderType": "MARKET",      "status": "IDLE",      "error": "string",      "createdAt": "string",      "updatedAt": "string",      "orders": [        {          "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",          "connector": "hyperliquid",          "status": "PENDING",          "error": "string",          "errorCode": "string",          "createdAt": "string",          "updatedAt": "string",          "type": "MARKET",          "symbol": "BTC",          "side": "BUY",          "reduceOnly": true,          "quantity": "1250.75",          "price": "1250.75",          "filledQuantity": "1250.75",          "filledPrice": "1250.75"        }      ],      "legs": [        {          "symbol": "BTC",          "side": "BUY",          "mode": "QUANTITY",          "amount": "1250.75",          "reduceOnly": true        }      ]    }  ]}