POST
Close all margin positions
Initiates an asynchronous process to close margin positions by executing market trades to net positions to zero. Unlike 'cover' which transfers assets, 'close' creates trade orders to sell or buy assets. Returns immediately with a request ID that can be used to track progress via the close position requests endpoints.
Path Params
-
accountIdstring requiredThe ID of the account
Body Params
ONE OF
-
currenciesarray of strings
-
allboolean
Responses
202
Returns an acknowledgement that the action was received. Async process will kick off to perform trades to close out open positions.
Response Body
object
-
closePositionsRequestIdstring uuid requiredUnique identifier for the close position request -
accountIdstring requiredThe ID of the account -
enterpriseIdstring requiredEnterprise ID associated with the request -
statusstring enum requiredStatus of a close position request or orderpendingin_progresscompletedfailed -
bitgoUserIdstring requiredBitGo user ID who initiated the request -
creationDatestring date-time requiredTimestamp when the request was created
400
Bad request - Invalid parameters
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
401
Unauthorized - Invalid or missing authentication
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
403
Forbidden - Insufficient permissions
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
409
Conflict - A pending close position request already exists for this account
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
422
Unprocessable Entity - JSON payload is improperly formatted
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
429
Too Many Requests - Rate limit exceeded
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-
500
Internal Server Error
Response Body
object
-
errorstring required -
errorNamestring required -
reqIdstring required -
contextobjectOptional structured metadata for REST validation failures. The schema is fixed for client contract stability.context object
-
errorNamestring requiredSame value as the top-level errorName. -
fieldstringRequest field associated with the validation failure. -
messagestringHuman-readable field-level validation message.
-