PearPear
API IntegrationAPI SpecificationTrade

Close a position

Close a position using MARKET or TRIGGER execution type

POST
/trade/{positionId}/close
x-api-key<token>

In: header

Path Parameters

positionId*string

Position identifier

Formatuuid

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/3fa85f64-5717-4562-b3fc-2c963f66afa6/close" \  -H "X-Trade-Account-Id: 3fa85f64-5717-4562-b3fc-2c963f66afa6" \  -H "Content-Type: application/json" \  -d '{    "type": "MARKET"  }'
{  "execution": {    "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      }    ]  }}