Guides
Guides

Square off

Close an entire open position immediately.

Close an entire open position immediately, by UUID. The currency is inherited from the position.

Request

curl -X POST "https://trade.mudrex.com/fapi/v1/futures/positions/{position_id}/close" \
  -H "Content-Type: application/json" \
  -H "X-Authentication: your-secret-key"

Parameters

ParameterTypeRequiredDescription
position_idstringYesThe unique identifier of the position (path parameter).

Response

Status: 200 OK

{
    "success": true,
    "data": {
        "order_id": "01a0f1cb-12a7-7f30-9c86-d36db7775dfe",
        "position_id": "01a0f1ca-8e83-7c9f-b3e6-d51b34cba2e3",
        "status": "CREATED",
        "message": "OK"
    }
}

Response fields

FieldDescription
order_idUUID of the close order. Track the fill with Order by id.
position_idPosition UUID (same as the path parameter).
statusStatus of the close operation (e.g. CREATED).
messageStatus message.

When the close order fills, Position history returns a CLOSED row with this order_id and position_id.

Errors

❕Common errors

Position is not open

{
    "success": false,
    "errors": [
        {
            "code": 400,
            "text": "position is not open"
        }
    ]
}

Status: 400 Bad Request


Did this page help you?