> ## Documentation Index
> Fetch the complete documentation index at: https://docs.magicmarkets.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk close

> Inspect open orders and close one, a set, or everything. Look before you close.

Three endpoints close orders. The first two take order IDs. `close_all/` closes everything, or only the orders on one sport or one event.

| Endpoint | Closes |
| - | - |
| `POST /v2/orders/{order_id}/close/` | One order |
| `POST /v2/orders/close_many/` | The orders you list |
| `POST /v2/orders/close_all/` | Every open order on the account, or only those on one sport or event. Returns `202` while the cancellation runs |

Closing an order cancels its unmatched remainder. Anything already matched stays matched: a fill cannot be undone. To exit a matched position, place an order on the opposite side of the same selection. The app calls this Trade out: see [Closing a position](/traders/trading/closing-positions).

## Always look first

```bash theme={"dark"}
API=https://magicmarkets.com/v2
H="X-Api-Key: $MAGICMARKETS_API_KEY"

curl -s "$API/orders/?status=open&status=pending&page_size=100" -H "$H" | jq '[.data[]
      | {order_id, sport, event_id: .event_info.event_id, bet_type, want_price, want_stake}]'
```

## Close one

```bash theme={"dark"}
curl -s -X POST "$API/orders/12345/close/" -H "$H"
```

Closing an already-closed order returns `400 order_closed`, which is distinct from `404 not_found`. `close_many/` does not return these errors. It answers `200` with `closed` and `not_found` lists instead.

## Close a specific set

```bash theme={"dark"}
curl -s -X POST "$API/orders/close_many/" -H "$H" -H 'Content-Type: application/json' \
  -d '{"order_ids": [12345, 12346]}'
```

## Close everything

```bash theme={"dark"}
curl -s -X POST "$API/orders/close_all/" -H "$H"

# only one event (event_id requires sport)
curl -s -X POST "$API/orders/close_all/" -H "$H" -H 'Content-Type: application/json' \
  -d '{"sport": "fb", "event_id": "2026-09-13,1001,2002"}'
```

<Warning>
  `close_all` with no body closes every open order on the account, across every key and every strategy. Send `sport`, or `sport` and `event_id`, to narrow it. For any other selection, list the orders and use `close_many/`.
</Warning>

## In the CLI

```bash theme={"dark"}
magicmarkets orders --open             # open and pending orders only
magicmarkets order close 12345
magicmarkets order close-many 12345 12346
magicmarkets order close-all           # asks for confirmation
magicmarkets order close-all --sport fb --event 2026-09-13,1001,2002
```

## Heartbeats close too

If a heartbeat expires, the server closes every open order on the account, including orders placed through other keys and sessions. See [Safety](/developers/safety).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.