{
  "openapi": "3.1.0",
  "info": {
    "title": "Bris Calculator API",
    "version": "1.0.0",
    "description": "Date planning estimates from the same service as the website. All results require rabbi or mohel confirmation. Review-required results include a provisional date and sunset caution; they are not ceremony times, medical assessments, or halachic rulings. Created in 2024; maintainer review only, with no independent rabbinic review or Chabad.org endorsement claimed.",
    "contact": {
      "email": "briscalculator@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://www.briscalculator.com"
    }
  ],
  "security": [],
  "externalDocs": {
    "description": "Methodology and limitations",
    "url": "https://www.briscalculator.com/methodology.html"
  },
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculateBrisDate",
        "summary": "Return a brit milah date estimate, with a provisional status near sunset",
        "description": "Supply local birth details as JSON. Every successful response includes a date. When status is review_required, display estimatedDate as provisional with a prominent near-sunset confirmation note; do not present it as confirmed or hide it solely due to that status. Retain warnings and source attribution. Request data is not stored in an application database. JSON body limit: 4 KB. Per-process rate limit: 30 calculation requests per minute per IP.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CalculationRequest"
              },
              "example": {
                "birthDate": "2026-11-11",
                "birthTime": "12:00",
                "birthPlace": "Cleveland, Ohio, United States",
                "cSection": false,
                "observance": "diaspora"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A date estimate with status estimate or review_required. Review-required dates are provisional; all dates require rabbi or mohel confirmation.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string"
                },
                "description": "no-store"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or malformed JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "413": {
            "description": "Request body exceeds the supported size.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "415": {
            "description": "Content-Type must be application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "422": {
            "description": "Ambiguous or unsupported location, local time or sunset.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit exceeded. Respect Retry-After.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "minimum": 1
                },
                "description": "Minimum seconds before retrying."
              }
            }
          },
          "502": {
            "description": "A required upstream service returned invalid data or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "503": {
            "description": "Service configuration unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "504": {
            "description": "A required upstream request timed out.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "405": {
            "description": "Use POST with a JSON request body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          },
          "500": {
            "description": "Unexpected internal failure; no estimate is returned.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CalculationRequest": {
        "type": "object",
        "properties": {
          "birthDate": {
            "type": "string",
            "format": "date",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Local civil birth date, 1900-01-01 through 2100-12-31."
          },
          "birthTime": {
            "type": "string",
            "pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
            "description": "Local 24-hour clock time at birthplace."
          },
          "birthPlace": {
            "type": "string",
            "minLength": 3,
            "maxLength": 200,
            "description": "City, state/region and country; no names or precise street addresses."
          },
          "cSection": {
            "type": "boolean",
            "description": "Whether birth was by C-section."
          },
          "observance": {
            "type": "string",
            "enum": [
              "israel",
              "diaspora"
            ],
            "description": "Applicable holiday schedule. Default is based on birth country; confirm if ceremony region or personal practice differs."
          },
          "birthUtcOffset": {
            "type": "string",
            "pattern": "^[+-](?:0\\d|1[0-3]):[0-5]\\d$|^[+-]14:00$",
            "description": "Optional valid local UTC offset to resolve a repeated clock time, e.g. -04:00."
          }
        },
        "required": [
          "birthDate",
          "birthTime",
          "birthPlace",
          "cSection"
        ],
        "additionalProperties": false
      },
      "CalculationResponse": {
        "type": "object",
        "properties": {
          "apiVersion": {
            "type": "string",
            "const": "1"
          },
          "status": {
            "type": "string",
            "enum": [
              "estimate",
              "review_required"
            ],
            "description": "estimate outside the sunset caution window; review_required within 60 minutes before through 60 minutes after modeled sunset, inclusive. Both statuses include a date; review_required must be presented as provisional."
          },
          "estimatedDate": {
            "type": "string",
            "format": "date",
            "description": "Returned planning date after modeled deferrals. Provisional when status is review_required; never a confirmed ruling or ceremony time."
          },
          "eighthDayDate": {
            "type": "string",
            "format": "date",
            "description": "Counted civil date before deferral: birth date plus 7 calendar days before sunset, plus 8 at or after sunset. This counting assumption does not determine halachic twilight."
          },
          "daysDeferred": {
            "type": "integer",
            "minimum": 0,
            "description": "Number of dates skipped for C-section or the at/after-sunset caution policy. Both policies avoid Shabbat and explicitly flagged Yom Tov dates."
          },
          "possibleDates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "maxItems": 0,
            "description": "Reserved for future use; always empty. Read estimatedDate for the single returned estimate, including provisional review_required results."
          },
          "deferrals": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "reason": {
                  "type": "string"
                }
              },
              "required": [
                "date",
                "reason"
              ]
            },
            "description": "Dates skipped because of C-section or, for either delivery method, birth at/after sunset within the one-hour caution window. Each reason explains the adjustment; the sunset policy is provisional and requires individual confirmation."
          },
          "birth": {
            "type": "object",
            "properties": {
              "localDateTime": {
                "type": "string",
                "format": "date-time"
              },
              "timeZone": {
                "type": "string"
              },
              "utcOffset": {
                "type": "string"
              },
              "resolvedPlace": {
                "type": "string"
              },
              "country": {
                "type": "string"
              }
            },
            "required": [
              "localDateTime",
              "timeZone",
              "utcOffset",
              "resolvedPlace",
              "country"
            ]
          },
          "sunset": {
            "type": "object",
            "properties": {
              "localDateTime": {
                "type": "string",
                "format": "date-time"
              },
              "differenceMinutes": {
                "type": "number",
                "description": "Birth instant minus modeled sunset, in minutes; negative means before sunset."
              }
            },
            "required": [
              "localDateTime",
              "differenceMinutes"
            ]
          },
          "observance": {
            "type": "object",
            "properties": {
              "schedule": {
                "type": "string",
                "enum": [
                  "israel",
                  "diaspora"
                ]
              },
              "source": {
                "type": "string",
                "enum": [
                  "request",
                  "birth_country"
                ]
              }
            },
            "required": [
              "schedule",
              "source"
            ]
          },
          "explanation": {
            "type": "string"
          },
          "warnings": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              },
              "required": [
                "code",
                "message"
              ]
            }
          },
          "source": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "methodologyUrl": {
                "type": "string",
                "format": "uri"
              }
            },
            "required": [
              "name",
              "url",
              "methodologyUrl"
            ]
          },
          "dataSources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "required": [
                "name",
                "url"
              ]
            }
          }
        },
        "required": [
          "apiVersion",
          "status",
          "estimatedDate",
          "eighthDayDate",
          "daysDeferred",
          "possibleDates",
          "deferrals",
          "birth",
          "sunset",
          "observance",
          "explanation",
          "warnings",
          "source",
          "dataSources"
        ],
        "additionalProperties": false
      },
      "CalculationError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "fields": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "candidates": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}
