Cancel an order or close a position
Three different ways out, three different endpoints. Cancelling kills a resting order, flattening closes what is already open, and reversing closes it and opens the opposite leg.
-
Get the venue order id
Section titled “Get the venue order id”Cancel keys off the venue order id, so read it off the order rows first. It is
nullbefore dispatch and on an order that never dispatched.Terminal window curl -s "https://api.troncharts.xyz/api/v1/accounts/$ACCOUNT_ID/orders?symbol=BTC.HL" \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG"# → { orders: [ { orderId, venueOrderId, symbol, type, state, … } ] } -
Cancel the working order
Section titled “Cancel the working order”POST /oms/cancelcomposes a cancel intent against the resolved parent and returns201 { intentId }— the id of the cancel, not of the order you killed.Terminal window curl -s https://api.troncharts.xyz/api/v1/oms/cancel \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG" \-H 'content-type: application/json' \-H "idempotency-key: $(uuidgen)" \-d '{"venueOrderId":"'"$VENUE_ORDER_ID"'"}'await sdk.oms.cancel(venueOrderId, crypto.randomUUID()) -
Flatten the position
Section titled “Flatten the position”Both fields are optional and independent:
symbolnarrows to one market,accountIdtargets an owned account other than the token’s own. An empty body acts on the whole scope. Flatten cancels the symbol’s working orders first, then closes — so a resting order can’t fire against a now-flat account.Terminal window curl -s https://api.troncharts.xyz/api/v1/oms/flatten \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG" \-H 'content-type: application/json' \-d '{"symbol":"BTC.HL"}'# → { ok, cancelIntentIds, closeIntentId, alreadyFlat }await sdk.oms.flatten({ symbol: 'BTC.HL' }) -
Reverse instead of closing
Section titled “Reverse instead of closing”Same body, opposite intent:
/oms/reversecloses the position and opens the other side.openIntentIdcomes backnullwithreverseOpenDeferred: true— the open leg is composed at the realized close size once the close terminalizes, so it can never oversize the flip. It surfaces on the/ws/riskPosition-Update frame.Terminal window curl -s https://api.troncharts.xyz/api/v1/oms/reverse \-H "authorization: Bearer $TOKEN" \-H "x-tenant-slug: $TC_TENANT_SLUG" \-H 'content-type: application/json' \-d '{"symbol":"BTC.HL"}'const { closeIntentId, reverseOpenDeferred } = await sdk.oms.reverse({ symbol: 'BTC.HL' })Cancel and flatten only reduce exposure, so a
liquidationcredential can make them. Reverse re-establishes it and needsfullTrading. See Scopes & tiers.
Next: Place your first order · Stream account and position updates · Accounts & positions