Docs
Waves

Close the positions a multi-account order opened

Request

Synthetic example for the production API. Replace YOUR_API_KEY and the ids. Do not send it against a live account until you mean to.

curl -X POST "https://api.fxapis.com/v1/execution-waves/ACCOUNT_ID/close" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: 3f0c9a52-8a8e-4f7e-9b0e-6c1d2f5a7b10"
POST
/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.

Authorization

apiKey
AuthorizationBearer <token>

Authorization: Bearer fx_live_<id>_<secret>.

A key is shown once, at creation. We cannot show it again or recover it for you. Keys carry a label (live or test) in the key itself, so each configuration is easy to tell apart. Both reach real brokers: test with a broker demo account.

Scopes are per key. A key without accounts:write can read accounts and nothing else.

In: header

Path Parameters

id*string
Formatuuid

Header Parameters

idempotency-key?string

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.

Lengthlength <= 200

Request Body

application/json

Optional. Without a body, every account of the multi-account order is closed.

TypeScript Definitions

Use the request body type in TypeScript.

Optional. Without a body, every account of the multi-account order is closed.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://api.fxapis.com/v1/execution-waves/497f6eca-6276-4993-bfeb-53cbbbba6f08/close" \  -H "idempotency-key: 3f0c9a52-8a8e-4f7e-9b0e-6c1d2f5a7b10" \  -H "Content-Type: application/json" \  -d '{}'
{  "data": {    "waveId": "7cbdac82-3101-4108-89e1-852fa315e8a7",    "summary": {      "total": 0,      "closed": 0,      "notFound": 0,      "rejected": 0,      "unresolved": 0,      "skipped": 0    },    "legs": [      {        "accountId": "3d07c219-0a88-45be-9cfc-91e9d095a1e9",        "orderId": null,        "positionId": null,        "result": "closed",        "closeOrderId": null,        "detail": null      }    ]  }}