{
  "openapi": "3.1.0",
  "info": {
    "title": "Mandatory Minimum",
    "version": "1.0.0",
    "description": "Computes this year's required minimum distribution, its exact deadline, and the excise penalty for missing it, for anyone 73+ or holding an inherited IRA."
  },
  "servers": [
    {
      "url": "https://mandatory-minimum.embyra.workers.dev"
    }
  ],
  "paths": {
    "/api/compute": {
      "post": {
        "operationId": "compute",
        "summary": "Compute an RMD",
        "description": "Compute the required minimum distribution (RMD) for a US retirement account: the dollar amount due for the tax year, the IRS life expectancy divisor it came from, the deadline to take it, and the 25% excise tax owed if it is missed. Uses the Uniform Lifetime table for an account owner and the Single Life table for an inherited account; the deadline is 31 December, or 1 April of the next year for an owner's first distribution. Returns rmd 0 and divisor 0 when none is due — an owner below the applicable age (73, or 75 from the 1960 birth cohort) or a Roth IRA the holder owns. Deterministic arithmetic over the public IRS tables; no advice, no account access, nothing stored.",
        "x-price-per-call": {
          "amount": 0.01,
          "currency": "USD",
          "freeCallsPerDay": 3,
          "rails": []
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "age": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 120,
                    "description": "Age the account holder (or beneficiary) reaches during the tax year"
                  },
                  "balance": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1000000000,
                    "description": "Account balance in USD on 31 December of the prior year"
                  },
                  "accountType": {
                    "type": "string",
                    "enum": [
                      "traditional-ira",
                      "roth-ira",
                      "sep-ira",
                      "simple-ira",
                      "401k",
                      "403b",
                      "457b"
                    ],
                    "description": "Kind of retirement account the balance sits in"
                  },
                  "inherited": {
                    "default": false,
                    "description": "True for an inherited account: Single Life table, no April 1 deferral",
                    "type": "boolean"
                  },
                  "taxYear": {
                    "default": 2026,
                    "description": "Tax year the distribution is for; defaults to the current year",
                    "type": "integer",
                    "minimum": 2023,
                    "maximum": 2100
                  }
                },
                "required": [
                  "age",
                  "balance",
                  "accountType"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rmd": {
                      "type": "number",
                      "description": "Required minimum distribution for the tax year, USD; 0 when none is due"
                    },
                    "deadline": {
                      "type": "string",
                      "description": "Last day to take it, ISO date (YYYY-MM-DD)"
                    },
                    "divisor": {
                      "type": "number",
                      "description": "Life expectancy factor the balance was divided by; 0 when none is due"
                    },
                    "penalty": {
                      "type": "number",
                      "description": "Excise tax owed if the distribution is missed, USD"
                    }
                  },
                  "required": [
                    "rmd",
                    "deadline",
                    "divisor",
                    "penalty"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          },
          "402": {
            "description": "Payment required: free tier exhausted. Headers carry an MPP challenge (WWW-Authenticate: Payment) and/or an x402 PAYMENT-REQUIRED payload.",
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
