Skip to main content
Edits the take-profit and/or stop-loss attached to a position or pending order. Pass 0 on Gains to remove a leg.

Request Body

dex
string
required
gains or lighter.
chainId
string
required
Chain of the position/order.
marketId
string
Mobula market identifier.
positionId
string
Gains trade index (regex ^\d+$). Required for Gains.
newTp
number
New take-profit price (≥ 0). On Gains, pass 0 to clear the TP.
newSl
number
New stop-loss price (≥ 0). On Gains, pass 0 to clear the SL.

Endpoint-specific errors

Statusmessage
400edit-order payload action failed — invalid TP/SL direction, missing position, or DEX refusal

Example

Set a new TP at 75000 and remove the SL on a Gains long:
const endpoint = 'api/2/perp/payloads/edit-order';
const timestamp = Date.now();
const signature = await wallet.signMessage(`${endpoint}-${timestamp}`);

const res = await fetch(`https://api.mobula.io/${endpoint}`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    timestamp,
    signature,
    dex: 'gains',
    chainId: 'evm:42161',
    marketId: 'gains-btc-usd',
    positionId: '12345',
    newTp: 75000,
    newSl: 0,
  }),
}).then(r => r.json());