Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

updatePositionMode

Switches the account between one-way and hedge position mode. In one-way mode a market holds a single net position; in hedge mode it can hold a long and a short at the same time — see Margin & Leverage.

The setting is account-wide and applies to perpetuals only. There is no per-instrument variant.

POST/exchangetype updatePositionMode

Switch the whole account between one-way and hedge mode (must be flat on perps).Agent-signed

Action fields
isOnewaybooleanrequired

`true` for one-way, `false` for hedge.

typestringrequired

Must be `updatePositionMode`.

"updatePositionMode"
Request example
curl -X POST https://rpc.txflow-testnet.xyz/exchange \
  -H "Content-Type: application/json" \
  -H "x-api-version: 2026-08-16" \
  -d '{
  "action": {
    "type": "updatePositionMode",
    "isOneway": true
  },
  "signature": {
    "r": "0x<r>",
    "s": "0x<s>",
    "v": 27
  },
  "nonce": 1757992743994,
  "vaultAddress": null,
  "signatureChainId": null
}'
Try it
testnet · no account yet
Generates a throwaway key in your browser, claims testnet USDC and authorizes an agent key. The account is kept while you browse the docs and lost on reload.
Response · UpdatePositionMode 200
codeinteger

`0` on success.

dataobject
dataobject
typestring

The action's internal name, which does not always match the request `type`.

"UpdatePositionMode"
statusstring

A rejected request returns `err` with a non-zero `code` and the reason in `message` (or `response`).

"ok"
Response example
{
  "status": "ok",
  "code": 0,
  "data": {
    "type": "UpdatePositionMode",
    "data": {
      "statuses": [
        "success"
      ]
    }
  }
}

isOneway is the only field. Do not send an asset — the action carries no instrument, and any extra key would change the MessagePack bytes your client hashes without changing what the node hashes, so the signature would fail to recover.

Preconditions

The account must be flat on perpetuals before the mode can change:

ErrorCause
You have open perps orders or positionsAny perpetual open order, position, or ungrouped trigger order exists
Cannot change position mode while a TWAP order is activeA TWAP job is still running
Reverse position in progress for this coin and margin modeA reverse-position job is still running
Liquidator cannot update position modeLiquidator accounts are fixed to hedge mode

Outcome-market orders and positions do not block the switch, since position mode only applies to perpetuals. Cancel the perpetual orders and close the positions in question, then retry.

Next steps

The active mode is reflected in activeAssetData: one-way returns a single leverage.value, hedge returns separate leverage.long_value and leverage.short_value. Set those per-side leverages with updateLeverage.