---
title: "Close an account position or cancel a pending order"
method: DELETE
path: "/rest/api/v1/accounts/{accountId}/positions/{positionId}"
tags: ["Trading API"]
---

# Close an account position or cancel a pending order

`DELETE /rest/api/v1/accounts/{accountId}/positions/{positionId}`

By default closes the position (works for both live positions and pending orders). Set `pendingOnly=true` to cancel the order ONLY if it is still a pending (unfilled) order; if it has already filled into a live position it is left untouched (safe no-op). Use this to safely cancel pending orders on expiry without risking closing a filled position.

## Path parameters

- `accountId` string, uuid, required
- `positionId` string, required

## Query parameters

- `pendingOnly` boolean

## Response `204`

No Content

---

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