Trading API
Close an account position or cancel a pending order
Changed onBy 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.
delete/rest/api/v1/accounts/{accountId}/positions/{positionId}
Request
- Base URLhttps://api.metacopier.io
- AuthAPI key in header X-API-KEY
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Path parameters
accountIdstring uuid required
positionIdstring required
Query parameters
pendingOnlyboolean
If true, only cancel when the id is still a pending (unfilled) order; a live (filled) position is not closed (no-op).
Response
No Content
Changes
- info
added the new optional
queryrequest parameterpendingOnly
- info
- breaking
removed the success response with the status
- info
added the success response with the status
- breaking