{
  "openapi": "3.1.0",
  "info": {
    "title": "FaraidPro Estate API",
    "version": "1.0.0",
    "description": "Islamic inheritance (Faraid) for five schools with jurisdiction overlays. Money is integer minor units as strings; shares are exact fractions. Live keys `fp_live_…` count against the monthly quota; test keys `fp_test_…` are sandboxed and return watermarked PDFs. PDF links are signed and expire after one hour."
  },
  "servers": [
    {
      "url": "https://www.faraidpro.com/api/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "fp_live_… or fp_test_…"
      }
    },
    "schemas": {
      "Heir": {
        "type": "object",
        "required": [
          "type",
          "count"
        ],
        "properties": {
          "type": {
            "type": "string",
            "example": "son",
            "enum": [
              "husband",
              "wife",
              "son",
              "daughter",
              "father",
              "mother",
              "grandfather",
              "grandmother",
              "maternalGrandmother",
              "greatGrandfather",
              "brother",
              "sister",
              "paternalBrother",
              "paternalSister",
              "maternalBrother",
              "maternalSister",
              "nephew",
              "paternalNephew",
              "sonOfSon",
              "daughterOfSon",
              "sonOfSonOfSon",
              "daughterOfSonOfSon",
              "uncle",
              "paternalUncle",
              "cousin",
              "paternalCousin",
              "sonOfDaughter",
              "daughterOfDaughter",
              "maternalGrandfather",
              "daughterOfBrother",
              "daughterOfPaternalBrother",
              "sonOfSister",
              "daughterOfSister",
              "sonOfPaternalSister",
              "daughterOfPaternalSister",
              "sonOfMaternalSibling",
              "daughterOfMaternalSibling",
              "paternalAunt",
              "maternalUncle",
              "maternalAunt"
            ],
            "description": "Heir position. Spouses: husband, wife. Class/line relatives: son, daughter, father, mother, grandfather (paternal), grandmother (paternal), maternalGrandmother, greatGrandfather, brother, sister, paternalBrother, paternalSister, maternalBrother, maternalSister, nephew (full brother's son), paternalNephew, sonOfSon, daughterOfSon, sonOfSonOfSon, daughterOfSonOfSon, uncle (father's full brother), paternalUncle (father's paternal half-brother), cousin (full uncle's son), paternalCousin. Distant kindred (dhawu al-arham in the Sunni schools): sonOfDaughter, daughterOfDaughter, maternalGrandfather, daughterOfBrother, daughterOfPaternalBrother, sonOfSister, daughterOfSister, sonOfPaternalSister, daughterOfPaternalSister, sonOfMaternalSibling, daughterOfMaternalSibling, paternalAunt (father's full sister), maternalUncle, maternalAunt. Sunni schools: distant kindred inherit only with no 'asaba and no non-spouse fard heir (`options.dhawilArhamMode`). Ja'fari (madhab \"jafari\"): every type is a regular heir of its class — class 1 parents and descendants, class 2 grandparents and siblings with their children, class 3 uncles and aunts with their children. The children of a deceased child, sibling or uncle stand in that relative's place and divide the share 2:1 (paternal side) or per head (maternal side); give each deceased relative's children their own `branch` id; without branch ids the engine assumes all members of a group descend from ONE deceased relative and says so in `warnings` (ruleId `j.represent`). Maternal uncles and aunts take 1/3 (`j.khal.third`) or everything when alone (`j.khal.all`)."
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 50
          },
          "label": {
            "type": "string"
          },
          "branch": {
            "type": "string",
            "maxLength": 40,
            "description": "Ja'fari representation only: id of the deceased relative through whom these heirs connect (e.g. \"Fatima\" for her children). Entries of one represented group (a daughter's children, a full brother's children, a full uncle's sons, ...) with different branch ids are treated as descending from different deceased relatives, each taking that relative's share. Without branch ids the whole group is assumed to descend from one relative. Ignored by the Sunni schools."
          },
          "circumstances": {
            "type": "object",
            "description": "isKiller, killingType, religion (muslim|nonMuslim|apostate), isUnborn, isMissing, missingSince, birthDate, courtDeclaredDead, isIntersex, isAdopted, isStepChild, isIllegitimate"
          }
        }
      },
      "Asset": {
        "type": "object",
        "required": [
          "type",
          "valuationMinor"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "cash",
              "bank",
              "gold",
              "silver",
              "land_barani",
              "land_nahri",
              "land_urban",
              "land_other",
              "house",
              "flat",
              "shop",
              "vehicle",
              "business_share",
              "shares",
              "fund",
              "crypto",
              "pension",
              "life_policy",
              "receivable",
              "other"
            ]
          },
          "label": {
            "type": "string"
          },
          "valuationMinor": {
            "type": "string",
            "pattern": "^\\d+$"
          },
          "divisible": {
            "type": "boolean"
          },
          "quantity": {
            "type": "number"
          },
          "unit": {
            "type": "string",
            "enum": [
              "acre",
              "kanal",
              "marla",
              "g",
              "unit"
            ]
          }
        }
      },
      "Deduction": {
        "type": "object",
        "required": [
          "category",
          "amountMinor"
        ],
        "properties": {
          "category": {
            "type": "string",
            "enum": [
              "funeral",
              "debt",
              "mahr",
              "zakat_due",
              "bequest",
              "other"
            ]
          },
          "label": {
            "type": "string"
          },
          "amountMinor": {
            "type": "string"
          },
          "beneficiaryIsHeir": {
            "type": "boolean"
          },
          "heirConsent": {
            "type": "boolean"
          },
          "bequeathed": {
            "type": "boolean",
            "description": "zakat_due: willed by the deceased (Hanafi rule)"
          }
        }
      },
      "EstateRequest": {
        "type": "object",
        "required": [
          "currency",
          "heirs"
        ],
        "properties": {
          "reference": {
            "type": "string"
          },
          "madhab": {
            "type": "string",
            "enum": [
              "hanafi",
              "maliki",
              "shafii",
              "hanbali",
              "jafari"
            ],
            "default": "hanafi",
            "description": "Sunni schools follow the classical fard/'asaba system; jafari uses the Twelver three-class system (no ta'sib, no 'awl, radd within the class, representation of a deceased relative by their children). The Ja'fari module is pending review by a Shi'i scholar and says so in `warnings`."
          },
          "jurisdiction": {
            "type": "string",
            "example": "PK"
          },
          "currency": {
            "type": "string",
            "example": "PKR"
          },
          "deceased": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "gender": {
                "type": "string",
                "enum": [
                  "male",
                  "female"
                ]
              },
              "dateOfDeath": {
                "type": "string",
                "format": "date"
              }
            }
          },
          "heirs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Heir"
            }
          },
          "assets": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Asset"
            }
          },
          "estateValueMinor": {
            "type": "string",
            "description": "Cash-only estate when no assets are given"
          },
          "deductions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Deduction"
            }
          },
          "allocation": {
            "type": "object",
            "properties": {
              "strategy": {
                "type": "string",
                "enum": [
                  "compensate",
                  "pro_rata"
                ]
              },
              "locks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "assetId": {
                      "type": "string"
                    },
                    "heirId": {
                      "type": "string",
                      "example": "wife:0"
                    }
                  }
                }
              }
            }
          },
          "options": {
            "type": "object",
            "description": "jurisdictionOptions, dhawilArhamMode, raddToSpouseMode, takharuj, deceasedApostate, asOfDate, heirsConsentToExcess"
          },
          "pdf": {
            "oneOf": [
              {
                "type": "boolean",
                "enum": [
                  false
                ]
              },
              {
                "type": "object",
                "properties": {
                  "language": {
                    "type": "string",
                    "enum": [
                      "en",
                      "ur",
                      "ar"
                    ]
                  }
                }
              }
            ]
          }
        }
      }
    }
  },
  "paths": {
    "/estates": {
      "post": {
        "summary": "Compute an estate (ledger, shares, allocation, PDF)",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            },
            "description": "Retries with the same key and body within 24 h return the stored response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EstateRequest"
              },
              "examples": {
                "sunni": {
                  "summary": "Hanafi estate with assets, deductions and a PDF",
                  "value": {
                    "reference": "CASE-1042",
                    "madhab": "hanafi",
                    "jurisdiction": "PK",
                    "currency": "PKR",
                    "deceased": {
                      "name": "Ahmad Khan",
                      "gender": "male",
                      "dateOfDeath": "2025-03-01"
                    },
                    "heirs": [
                      {
                        "type": "wife",
                        "count": 1
                      },
                      {
                        "type": "son",
                        "count": 2
                      },
                      {
                        "type": "daughter",
                        "count": 1
                      }
                    ],
                    "assets": [
                      {
                        "id": "house",
                        "type": "house",
                        "label": "House",
                        "valuationMinor": "1500000000",
                        "divisible": false
                      },
                      {
                        "id": "bank",
                        "type": "bank",
                        "label": "Bank",
                        "valuationMinor": "2500000000"
                      },
                      {
                        "id": "land",
                        "type": "land_nahri",
                        "label": "Nahri land",
                        "valuationMinor": "3000000000",
                        "quantity": 4,
                        "unit": "acre"
                      }
                    ],
                    "deductions": [
                      {
                        "category": "funeral",
                        "label": "Burial",
                        "amountMinor": "5000000"
                      },
                      {
                        "category": "mahr",
                        "label": "Deferred mahr",
                        "amountMinor": "20000000"
                      }
                    ],
                    "allocation": {
                      "strategy": "compensate",
                      "locks": [
                        {
                          "assetId": "house",
                          "heirId": "wife:0"
                        }
                      ]
                    },
                    "pdf": {
                      "language": "en"
                    }
                  }
                },
                "jafariBranches": {
                  "summary": "Ja'fari: two deceased daughters' children as separate branches",
                  "description": "Without `branch` all three grandchildren would be read as one daughter's children (1/2 + radd); with two branches the two daughters' 2/3 + radd is split between the branches.",
                  "value": {
                    "reference": "CASE-1043",
                    "madhab": "jafari",
                    "jurisdiction": "IR",
                    "currency": "IRR",
                    "deceased": {
                      "name": "Hossein Karimi",
                      "gender": "male",
                      "dateOfDeath": "2025-06-10"
                    },
                    "heirs": [
                      {
                        "type": "wife",
                        "count": 1
                      },
                      {
                        "type": "sonOfDaughter",
                        "count": 1,
                        "branch": "Fatima"
                      },
                      {
                        "type": "daughterOfDaughter",
                        "count": 2,
                        "branch": "Zaynab"
                      }
                    ],
                    "estateValueMinor": "12000000000",
                    "pdf": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Computed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "sunni": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "6f1c…",
                        "ledger": {
                          "grossMinor": "7000000000",
                          "netEstateMinor": "6975000000"
                        },
                        "shares": [
                          {
                            "heirId": "wife:0",
                            "type": "wife",
                            "share": "1/8",
                            "amountMinor": "871875000",
                            "ruleId": "wife.eighth",
                            "evidence": [
                              "Qurʾān 4:12"
                            ]
                          }
                        ],
                        "allocation": {
                          "settlements": []
                        },
                        "pdfUrl": "https://…",
                        "pdfExpiresAt": "…"
                      }
                    }
                  },
                  "jafariBranches": {
                    "value": {
                      "success": true,
                      "data": {
                        "id": "7a2d…",
                        "ledger": {
                          "grossMinor": "12000000000",
                          "netEstateMinor": "12000000000"
                        },
                        "shares": [
                          {
                            "heirId": "wife:0",
                            "type": "wife",
                            "share": "1/8",
                            "amountMinor": "1500000000",
                            "ruleId": "j.wife.eighth",
                            "evidence": [
                              "Qurʾān 4:12"
                            ]
                          },
                          {
                            "heirId": "sonOfDaughter:1",
                            "type": "sonOfDaughter",
                            "branch": "Fatima",
                            "share": "7/16",
                            "amountMinor": "5250000000",
                            "ruleId": "j.represent",
                            "evidence": [
                              "Qurʾān 4:11",
                              "Sharāʾiʿ al-Islām, Kitāb al-Farāʾiḍ"
                            ]
                          },
                          {
                            "heirId": "daughterOfDaughter:2",
                            "type": "daughterOfDaughter",
                            "branch": "Zaynab",
                            "share": "7/16",
                            "amountMinor": "5250000000",
                            "ruleId": "j.represent",
                            "evidence": [
                              "Qurʾān 4:11",
                              "Sharāʾiʿ al-Islām, Kitāb al-Farāʾiḍ"
                            ]
                          }
                        ],
                        "warnings": [
                          "Jaʿfarī representation: daughter “Fatima”, daughter “Zaynab” — each branch id is treated as one deceased relative and takes that relative's share.",
                          "Jaʿfarī module v2.2 — pending review by a Shīʿī scholar."
                        ],
                        "allocation": {
                          "settlements": []
                        },
                        "pdfUrl": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Calculation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/estates/batch": {
      "post": {
        "summary": "Compute up to 500 estates (no PDFs)",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 100
            },
            "description": "Retries with the same key and body within 24 h return the stored response."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "example": {
                "estates": [
                  {
                    "reference": "CASE-1042",
                    "madhab": "hanafi",
                    "jurisdiction": "PK",
                    "currency": "PKR",
                    "deceased": {
                      "name": "Ahmad Khan",
                      "gender": "male",
                      "dateOfDeath": "2025-03-01"
                    },
                    "heirs": [
                      {
                        "type": "wife",
                        "count": 1
                      },
                      {
                        "type": "son",
                        "count": 2
                      },
                      {
                        "type": "daughter",
                        "count": 1
                      }
                    ],
                    "assets": [
                      {
                        "id": "house",
                        "type": "house",
                        "label": "House",
                        "valuationMinor": "1500000000",
                        "divisible": false
                      },
                      {
                        "id": "bank",
                        "type": "bank",
                        "label": "Bank",
                        "valuationMinor": "2500000000"
                      },
                      {
                        "id": "land",
                        "type": "land_nahri",
                        "label": "Nahri land",
                        "valuationMinor": "3000000000",
                        "quantity": 4,
                        "unit": "acre"
                      }
                    ],
                    "deductions": [
                      {
                        "category": "funeral",
                        "label": "Burial",
                        "amountMinor": "5000000"
                      },
                      {
                        "category": "mahr",
                        "label": "Deferred mahr",
                        "amountMinor": "20000000"
                      }
                    ],
                    "allocation": {
                      "strategy": "compensate",
                      "locks": [
                        {
                          "assetId": "house",
                          "heirId": "wife:0"
                        }
                      ]
                    },
                    "pdf": {
                      "language": "en"
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Results per item",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "data": {
                    "count": 1,
                    "succeeded": 1,
                    "failed": 0,
                    "results": [
                      {
                        "index": 0,
                        "ok": true,
                        "data": {}
                      }
                    ]
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/estates/{id}": {
      "get": {
        "summary": "A stored estate",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/estates/{id}/pdf": {
      "get": {
        "summary": "Fresh one-hour PDF link",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "redirect",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "data": {
                    "url": "https://…",
                    "expiresAt": "…"
                  }
                }
              }
            }
          },
          "302": {
            "description": "Redirect to the file (redirect=1)"
          },
          "404": {
            "description": "No PDF",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/webhooks": {
      "post": {
        "summary": "Register a webhook (secret returned once)",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "url": "https://example.com/hooks/faraidpro",
                "events": [
                  "estate.computed",
                  "batch.completed"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "…",
                    "secret": "whsec_…"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate or monthly limit reached",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "description": "Deliveries carry X-FaraidPro-Signature: t=<unix>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">."
      },
      "get": {
        "summary": "List webhooks",
        "responses": {
          "200": {
            "description": "Webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Revoke a webhook",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked"
          }
        }
      }
    },
    "/usage": {
      "get": {
        "summary": "This month's usage",
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "data": {
                    "plan": "business",
                    "period": "2026-11",
                    "used": 1234,
                    "limit": 100000,
                    "remaining": 98766,
                    "resetInDays": 24
                  }
                }
              }
            }
          }
        }
      }
    },
    "/calculate": {
      "post": {
        "summary": "Shares only (legacy, simpler body)",
        "requestBody": {
          "content": {
            "application/json": {
              "examples": {
                "sunni": {
                  "value": {
                    "estateValue": 1000000,
                    "currency": "USD",
                    "madhab": "hanafi",
                    "heirs": [
                      {
                        "type": "wife",
                        "count": 1
                      },
                      {
                        "type": "son",
                        "count": 2
                      }
                    ]
                  }
                },
                "jafariBranches": {
                  "summary": "Ja'fari branches",
                  "value": {
                    "estateValue": 1200000,
                    "currency": "USD",
                    "madhab": "jafari",
                    "heirs": [
                      {
                        "type": "husband",
                        "count": 1
                      },
                      {
                        "type": "sonOfDaughter",
                        "count": 1,
                        "branch": "Fatima"
                      },
                      {
                        "type": "daughterOfDaughter",
                        "count": 2,
                        "branch": "Zaynab"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/zakat": {
      "post": {
        "summary": "Advanced zakat: nisab, school rules (all five madhabs), liabilities, ushr, livestock, business (AAOIFI SS 35), country notes",
        "security": [
          {
            "bearer": []
          },
          {}
        ],
        "description": "madhab: hanafi | shafii | maliki | hanbali | jafari (decides nisab weights, debt deduction, jewellery, loans and the Ja'fari nine-items scope). Optional school-specific asset fields: `worn` (gold/silver jewellery in use; exempt outside the Hanafi school), `minted` (gold/silver as coin; Ja'fari zakat applies only to minted coin, not bars or jewellery), `received`, `yearsOutstanding` and `debtStrength` on receivables (Maliki: loans are zakatable once, on receipt). Crops take `irrigation` (rain | canal | mixed, with `rainShare`) and `perishable` (fresh fruit and vegetables: no ushr except under Abu Hanifa's view, `options.cropNisab: \"abu_hanifa\"`). Other options: `deductFullInstalments`, `includeAccessiblePension`, `mixedIrrigation` (average | dominant). `jurisdiction` (ISO country code) adds a country note on how zakat is collected and treated for tax: PK, MY, SA, US, UK, BD, IN, ID, AE, EG, JO, MA, TR, IR, NG. `locale` (en, ar, ur, id, ms, tr, bn, fr, ha, fa; falls back to the Accept-Language header, then English) sets the language of `notes`, line `note`s, livestock `due` and the business note; the codes in `noteKeys`, `noteKey` and `dueParts` are language-independent. The response echoes `locale`, `jurisdiction` (code as sent, or null) and `country` (its name in that locale, or null).",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "madhab": "hanafi",
                "currency": "USD",
                "jurisdiction": "US",
                "locale": "en",
                "nisabBasis": "silver",
                "prices": {
                  "goldPerGramMinor": "8500",
                  "silverPerGramMinor": "100",
                  "source": "LBMA",
                  "date": "2026-11-06"
                },
                "assets": [
                  {
                    "category": "bank",
                    "valueMinor": "2500000"
                  },
                  {
                    "category": "gold",
                    "grams": 50,
                    "karat": 22,
                    "worn": true
                  },
                  {
                    "category": "silver",
                    "grams": 200,
                    "minted": true
                  },
                  {
                    "category": "receivable",
                    "debtStrength": "strong",
                    "valueMinor": "400000",
                    "received": true,
                    "yearsOutstanding": 3
                  }
                ],
                "liabilities": [
                  {
                    "kind": "instalment",
                    "amountMinor": "1200000",
                    "currentYearMinor": "240000"
                  }
                ],
                "crops": [
                  {
                    "crop": "Wheat",
                    "yieldKg": 2000,
                    "valueMinor": "300000",
                    "irrigation": "canal"
                  },
                  {
                    "crop": "Tomatoes",
                    "valueMinor": "50000",
                    "irrigation": "rain",
                    "perishable": true
                  }
                ],
                "livestock": [
                  {
                    "animal": "cattle",
                    "count": 40,
                    "freeGrazing": true
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Zakat result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "success": true,
                  "data": {
                    "nisab": {
                      "basis": "silver",
                      "valueMinor": "18370800"
                    },
                    "totalDueMinor": "…",
                    "balanceMinor": "…",
                    "locale": "en",
                    "jurisdiction": "US",
                    "country": "United States"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": false
                    },
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    },
                    "details": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "field": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
