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
Chain of the position/order.
Mobula market identifier.
Gains trade index (regex ^\d+$). Required for Gains.
New take-profit price (≥ 0). On Gains, pass 0 to clear the TP.
New stop-loss price (≥ 0). On Gains, pass 0 to clear the SL.
Endpoint-specific errors
| Status | message |
|---|
| 400 | edit-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());