# Margin Requirement Calculator

> Margin Requirement Calculator is a paid API for AI agents from margin-api-production-d413.up.railway.app, paid per call via x402, $0.01/call, status unknown (last checked 2026-10-30).

Calculates the required margin amount for a given collateral position

## Facts

- Endpoint: GET https://margin-api-production-d413.up.railway.app/calculate?utm_source=zero.xyz
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-30
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/margin-requirement-calculator-a44acbd1
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_txPCuXzMVckgGkzN9qJ5m

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability margin-requirement-calculator-a44acbd1
```

Example prompt: What's the required margin for my collateral position — I want to make sure I know how much I need to post before opening a trade.

## When to prefer this

Use this endpoint when you need to compute the required margin before posting collateral or opening a leveraged position, particularly in automated trading or DeFi workflows where precise margin calculations are needed programmatically. Pair it with the sibling 'check if posted margin is sufficient' endpoint for a complete pre- and post-collateral workflow.

## Known failure modes

- Missing or invalid input parameters returns a 400 error
- Unsupported collateral type or asset returns a validation error
- Service unavailable or Railway deployment downtime returns a 503
- Payment not included or insufficient USDC results in a 402 Payment Required response
- Malformed query parameters cause computation failure

## How this service works

Calculate required margin for collateral

## Output

Returns the calculated required margin amount for the specified collateral, typically including the minimum margin needed, margin ratio, and any relevant thresholds or warnings about sufficiency.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {}
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/margin-requirement-calculator-a44acbd1/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from margin-api-production-d413.up.railway.app](https://www.zero.xyz/host/margin-api-production-d413.up.railway.app/llms.txt)
