# Close the positions a multi-account order opened

URL: https://docs.fxapis.com/api-reference/waves/close-the-positions-a-multi-account-order-opened

> Close the positions a multi-account order opened. Closes, on every account at once, the position each filled account's order opened, and answers with a result…

`POST https://api.fxapis.com/v1/execution-waves/{id}/close`

Closes, on every account at once, the position each `filled` account's order opened, and answers with a result for each account. Each close is an ordinary close order, placed exactly as `POST /v1/accounts/{id}/positions/{positionId}/close` places one: never refused for the plan's allowance, refused when trading is switched off. Send `accountIds` to close only some accounts.

**An `Idempotency-Key` is required.** A repeated close would not close twice; it would open opposing positions. Each account's close is keyed from yours, so the same key again answers with the first result (`idempotent-replay: true`) and never sends a second close.

Per account, `result` is `closed`, `not_found` (already closed), `rejected` (the broker refused), `unresolved` (sent, result being confirmed: **do not resend**; poll `closeOrderId`) or `skipped` (nothing sent; `detail` says why). Only once the order has ended; before that, **409** `WAVE_NOT_ENDED`.

Authentication: `Authorization: Bearer <API key>`.

#### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |
| `idempotency-key` | header | string | no | Any unique string, usually a UUID. A retry with the same key and body returns the first answer instead of placing a second order; the same key with a different body is refused. |

#### Request body (application/json, required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `accountIds` | string (uuid)[] | no | Close only these accounts' positions. Each must be an account of this multi-account order. |

#### Responses

- `200`
- `400`
- `401`
- `403`
- `404`
- `409`

Failures return `{ "error": { "code", "message" } }`; every code is listed at https://docs.fxapis.com/errors.

#### 200 response fields

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | object | no |  |
| `data.waveId` | string (uuid) | no |  |
| `data.summary` | object | no |  |
| `data.summary.total` | integer | no |  |
| `data.summary.closed` | integer | no |  |
| `data.summary.notFound` | integer | no |  |
| `data.summary.rejected` | integer | no |  |
| `data.summary.unresolved` | integer | no |  |
| `data.summary.skipped` | integer | no |  |
| `data.legs` | object[] | no | One entry per account: the position its order opened and what happened when it was closed. |
| `data.legs[].accountId` | string (uuid) | no |  |
| `data.legs[].orderId` | null \| string (uuid) | no | The order that opened the position. |
| `data.legs[].positionId` | null \| string | no | The position's ticket: the order's `brokerPositionId`, or its `brokerOrderId` until that is set. |
| `data.legs[].result` | "closed" \| "not_found" \| "rejected" \| "unresolved" \| "skipped" | no | `closed`: the broker closed it. `not_found`: already closed, or no such open position. `rejected`: the broker refused the close. `unresolved`: sent, and we are confirming the result with the broker — do not resend; poll `closeOrderId`. `skipped`: nothing was sent, and `detail` says why (the account's order did not fill, the account is not online, trading is switched off). |
| `data.legs[].closeOrderId` | null \| string (uuid) | no | The close order, an ordinary order. Null when nothing was sent. |
| `data.legs[].detail` | null \| string | no |  |