{
  "openapi": "3.1.0",
  "info": {
    "title": "HeirPros API",
    "version": "1.0.0",
    "description": "Estimate the research hours for an heir search. Estimated hours = 1.5 + known heirs + estimated unknown heirs. No pricing is returned. Requests are not emailed or stored.",
    "contact": {
      "name": "HeirPros",
      "url": "https://heirpros.com/contact-us/"
    }
  },
  "externalDocs": {
    "description": "API documentation",
    "url": "https://heirpros.com/developers/"
  },
  "servers": [
    {
      "url": "https://heirpros.com/api/v1"
    }
  ],
  "security": [
    {
      "ApiKeyHeader": []
    },
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/hours": {
      "post": {
        "operationId": "estimateHours",
        "summary": "Estimate research hours",
        "description": "Returns the estimated research hours for an heir search, from the number of known and estimated unknown heirs.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "known_heirs",
                  "unknown_heirs"
                ],
                "properties": {
                  "known_heirs": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "description": "Total number of known family members."
                  },
                  "unknown_heirs": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 25,
                    "description": "Estimated number of unknown family members."
                  },
                  "estate_type": {
                    "type": "string",
                    "enum": [
                      "testate",
                      "intestate",
                      "n/a"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "search_purpose": {
                    "type": "string",
                    "enum": [
                      "notice",
                      "distribution",
                      "n/a"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "has_identifying_info": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "last_contact_known": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no",
                      "unknown"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "lifestyle_considerations": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no",
                      "unknown"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "distribution_method": {
                    "type": "string",
                    "enum": [
                      "per stirpes",
                      "per capita",
                      "unsure"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "immigration_or_emigration": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  },
                  "has_additional_details": {
                    "type": "string",
                    "enum": [
                      "yes",
                      "no"
                    ],
                    "description": "Optional case detail. Validated, but does not change the hours in v1."
                  }
                }
              },
              "example": {
                "known_heirs": 3,
                "unknown_heirs": 2,
                "estate_type": "intestate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Estimated hours",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "estimated_hours": {
                      "type": "number",
                      "example": 6.5
                    },
                    "total_heirs": {
                      "type": "integer",
                      "example": 5
                    },
                    "known_heirs": {
                      "type": "integer",
                      "example": 3
                    },
                    "unknown_heirs": {
                      "type": "integer",
                      "example": 2
                    },
                    "case_details": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      },
                      "example": {
                        "estate_type": "intestate"
                      }
                    },
                    "method": {
                      "type": "string"
                    },
                    "note": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The body is not valid JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Wrong HTTP method.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "A field is missing or not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The API is not configured.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ping": {
      "get": {
        "operationId": "ping",
        "summary": "Check an API key",
        "responses": {
          "200": {
            "description": "The key is valid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "api": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "example": "validation_failed"
              },
              "message": {
                "type": "string",
                "example": "Some fields are missing or not valid. unknown_heirs: Must be between 1 and 25."
              },
              "details": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}