Orderbook

Atomically cancels a resting order (identified by order_id_to_cancel or nonce_to_cancel) and submits a replacement order in a single request. The payload is a full new-order specification plus the cancel target and an optional expected_filled_amount guard. Requires a signed order payload and Orderbook trade scope; returns both the cancelled and the newly created order.

post/private/replace

Request

  • Base URL
    https://api.derive.xyz/v3
  • Auth
    API key in header X-DeriveWallet and API key in header X-DeriveTimestamp and API key in header X-DeriveSignature

Request body

ReplaceOrderRequest required

private/replace parameters: a private/order payload plus the cancel-target fields (order_id_to_cancel, nonce_to_cancel, expected_filled_amount).

algo_duration_sec, integer nullable
algo_num_slices, integer nullable
algo_type, 'twap' nullable
amount, string decimal required

Order amount in units of the base, as a decimal string (e.g. "1.5") or a JSON number.

client, string nullable
direction, 'buy' | 'sell' required
expected_filled_amount, string decimal nullable

Optional decimal string of the human value (e.g. "1.5"), up to 12 fractional digits, or null; a string or JSON number is accepted

extra_fee, string decimal nullable

Optional builder fee for the whole order, in USDC, as a decimal string or JSON number. Each fill pays its pro-rata share. Defaults to zero.

instrument_name, string required
is_atomic_signing, boolean nullable
label, string nullable
limit_price, string decimal required

Limit price in quote currency, as a decimal string (e.g. "3100.5") or a JSON number.

max_fee, string decimal required

Max fee per unit of volume in quote currency, as a decimal string or a JSON number.

mmp, boolean nullable

Tags the order for market maker protection. Only tagged orders are cancelled by cancel on disconnect.

nonce, string required
nonce_to_cancel, string nullable
order_id_to_cancel, string uuid nullable

Optional UUID v4 string

order_type, 'limit' | 'market'
reduce_only, boolean nullable
referral_code, string nullable
reject_post_only, boolean nullable
reject_timestamp, integer nullable
signature, string required
signature_expiry_sec, integer required
signer, string required
subaccount_id, integer required
time_in_force, 'gtc' | 'post_only' | 'fok' | 'ioc'
trigger_price, string decimal nullable

Trigger price as a decimal string or JSON number; omit for non-trigger orders.

trigger_price_type, 'mark' | 'index' nullable
trigger_type, 'stoploss' | 'takeprofit' nullable

Response

Success

ReplaceOrderResponse required
cancelled_order, Order required
create_order_error, RPCError nullable
order, Order nullable
trades, Trade[] nullable

Changes

    • info

      added the required property trades/items/block_trade_id to the response with the status

    • info

      the endpoint scheme security DeriveWallet AND DeriveTimestamp AND DeriveSignature was added to the API

    • info

      added the media type application/json for the response with the status