> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rails.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Margin

> Estimate per-unit order cost and the maximum affordable quantity for an order.



## OpenAPI

````yaml POST /contracts/margin
openapi: 3.1.0
info:
  title: Options API
  version: 1.0.0
  description: >-
    REST endpoints for Rails Options. Base URLs vary by environment — see the
    Environments page. Authorize with the access token obtained from the Auth
    API.
servers:
  - url: https://api-options.sandbox.rails.xyz
security:
  - bearerAuth: []
paths:
  /contracts/margin:
    post:
      summary: Get Margin
      description: >-
        Estimates the per-unit cost of an options order — initial margin plus
        taker fee — and the maximum quantity affordable for a given available
        balance.
      operationId: getOptionsMargin
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - market
                - side
                - orderPrice
                - indexPrice
                - availableBalance
              properties:
                market:
                  type: string
                  description: Option contract name, e.g. `BTC-19JUN26-62000-C`.
                side:
                  type: string
                  description: 'Order side: `buy` or `sell`.'
                orderPrice:
                  type: string
                  description: Order price per contract (positive decimal).
                indexPrice:
                  type: string
                  description: Current index price of the underlying (positive decimal).
                availableBalance:
                  type: string
                  description: Balance available to allocate to the order.
            example:
              market: BTC-3JUL26-62000-C
              side: buy
              orderPrice: '150.00'
              indexPrice: '61665.11'
              availableBalance: '10000.00'
      responses:
        '200':
          description: Per-unit cost and maximum affordable quantity
          content:
            application/json:
              schema:
                type: object
                properties:
                  costPerUnit:
                    type: string
                    description: Cost per contract — initial margin plus taker fee.
                  maxQty:
                    type: string
                    description: >-
                      Maximum whole quantity affordable: `floor(availableBalance
                      / costPerUnit)`.
              example:
                costPerUnit: '193.245'
                maxQty: '51'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````