---
title: "Close all margin positions"
method: POST
path: "/api/prime/trading/v1/accounts/{accountId}/margin/positions/close"
tags: ["Margin"]
---

# Close all margin positions

`POST /api/prime/trading/v1/accounts/{accountId}/margin/positions/close`

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 parameters

- `accountId` string, required

## Request body

- union
  - object
    - `currencies` string[]
  - object
    - `all` boolean

## Response `202`

Returns an acknowledgement that the action was received. Async process will kick off to perform trades to close out open positions.

- ClosePositionRequestResponse
  - `closePositionsRequestId` string, uuid, required — Unique identifier for the close position request
  - `accountId` string, required — The ID of the account
  - `enterpriseId` string, required — Enterprise ID associated with the request
  - `status` 'pending' | 'in_progress' | 'completed' | 'failed', required — Status of a close position request or order
  - `bitgoUserId` string, required — BitGo user ID who initiated the request
  - `creationDate` string, date-time, required — Timestamp when the request was created

## Other responses

- `400` — Bad request - Invalid parameters
- `401` — Unauthorized - Invalid or missing authentication
- `403` — Forbidden - Insufficient permissions
- `409` — Conflict - A pending close position request already exists for this account
- `422` — Unprocessable Entity - JSON payload is improperly formatted
- `429` — Too Many Requests - Rate limit exceeded
- `500` — Internal Server Error

---

[API](https://skmtc.net/bitgo/apis/bitgo-api.md) · [All operations](https://skmtc.net/bitgo/apis/bitgo-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bitgo/bitgo-api/revisions/e445c15e5bee/schema)
