---
title: "public/margin_watch"
method: POST
path: "/public/margin_watch"
tags: ["Liquidations"]
---

# public/margin_watch

`POST /public/margin_watch`

## Request

- Base URL: `https://api.derive.xyz/v3`
- URL: `https://api.derive.xyz/v3/public/margin_watch`
- Auth: none declared

Calculates the mark-to-market value and initial/maintenance margin for a given subaccount, with per-position and per-collateral breakdowns, computed from live feed data at request time. Margins use the subaccount's manager's params. Set is_delayed_liquidation to get them under the subaccount's delayed-liquidation override instead; the request is rejected for a subaccount without one. has_delayed_liquidation reports whether the subaccount has one. A maintenance margin below zero means the subaccount is flagged for liquidation.

## Request body

- MarginWatchRequest
  - `is_delayed_liquidation` boolean: `true` returns margins under the subaccount's delayed-liquidation override. Rejected for a subaccount without one.
  - `subaccount_id` integer, required

## Response `200`

Success

- PublicMarginWatchResponse: Result of `public/margin_watch`: the margin state a liquidation watcher needs, under the subaccount's manager's params, or its delayed-liquidation override when the request asks for it.
  - `collaterals` Collateral[], required
    - `amount` string, required
    - `amount_step` string, required
    - `asset_name` string, required
    - `asset_type` string, required
    - `average_price` string, required
    - `average_price_excl_fees` string, required
    - `creation_timestamp` integer, required
    - `cumulative_interest` string, required
    - `currency` string, required
    - `delta` string, required
    - `delta_currency` string, required
    - `initial_margin` string, required
    - `maintenance_margin` string, required
    - `mark_price` string, required
    - `mark_value` string, required
    - `open_orders_margin` string, required
    - `pending_interest` string, required
    - `realized_pnl` string, required
    - `realized_pnl_excl_fees` string, required
    - `total_fees` string, required
    - `unrealized_pnl` string, required
    - `unrealized_pnl_excl_fees` string, required
  - `currency` string[], required
  - `has_delayed_liquidation` boolean, required: `true` when the subaccount has a delayed-liquidation override.
  - `initial_margin` string, required
  - `is_delayed_liquidation` boolean, required: `true` when the margins above use the delayed-liquidation override.
  - `maintenance_margin` string, required: Below zero the subaccount is flagged for liquidation.
  - `margin_type` string, required
  - `positions` Position[], required
    - `amount` string, required
    - `amount_step` string, required
    - `average_price` string, required
    - `average_price_excl_fees` string, required
    - `creation_timestamp` integer, required
    - `cumulative_funding` string, required
    - `delta` string, required
    - `gamma` string, required
    - `index_price` string, required
    - `initial_margin` string, required
    - `instrument_name` string, required
    - `instrument_type` 'option' | 'perp' | 'erc20', required: Asset type of the instrument: `"option"`, `"perp"`, or `"erc20"`.
    - `leverage` string, nullable
    - `liquidation_price` string, nullable
    - `maintenance_margin` string, required
    - `mark_price` string, required
    - `mark_value` string, required
    - `net_settlements` string, required
    - `open_orders_margin` string, required: Uses the same params as `initial_margin`: the manager's, even for a subaccount with a delayed-liquidation override, unless `public/margin_watch` asks for the override.
    - `pending_funding` string, required
    - `realized_pnl` string, required
    - `realized_pnl_excl_fees` string, required
    - `theta` string, required
    - `total_fees` string, required
    - `unrealized_pnl` string, required
    - `unrealized_pnl_excl_fees` string, required
    - `vega` string, required
  - `regular_margin_flagged_sec` integer, nullable: Unix seconds at which a subaccount with a delayed-liquidation override was first seen below its manager's maintenance margin. Its grace period before liquidation counts from here. Null otherwise.
  - `risk_universe_id` integer, required
  - `subaccount_id` integer, required
  - `subaccount_value` string, required
  - `valuation_timestamp` integer, required: Unix seconds at which margin and MtM were computed.

## Other responses

- `default`: JSON-RPC error (see Error Codes)

## Changes

- **2026-10-20** `0c500202be49`: 1 info
  - added the media type `application/json` for the response with the status `default`

[Operation history](https://skmtc.dev/lyra/apis/derive-v3-api/changes/public/margin_watch/post.md)

---

[API](https://skmtc.dev/lyra/apis/derive-v3-api.md) - [All operations](https://skmtc.dev/lyra/apis/derive-v3-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lyra/apis/derive-v3-api/revisions/415f8a73b10c?raw)
