{
  "openapi": "3.1.0",
  "info": {
    "title": "Humos API",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://api.humos.tech"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/v1/search": {
      "post": {
        "operationId": "createSearch",
        "summary": "Find people",
        "responses": {
          "200": {
            "description": "Finished",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Search"
                }
              }
            }
          },
          "202": {
            "description": "Still running",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Search"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SearchRequest"
              }
            }
          }
        }
      }
    },
    "/v1/searches/{id}": {
      "get": {
        "operationId": "getSearch",
        "summary": "Read a search",
        "responses": {
          "200": {
            "description": "Search",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Search"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/contacts/unlock": {
      "post": {
        "operationId": "unlockContacts",
        "summary": "Reveal contact details",
        "responses": {
          "200": {
            "description": "Contacts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "contacts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "cost_usd": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UnlockRequest"
              }
            }
          }
        }
      }
    },
    "/v1/frameworks": {
      "get": {
        "operationId": "listFrameworks",
        "summary": "List frameworks",
        "responses": {
          "200": {
            "description": "Frameworks",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "framework": {
                        "$ref": "#/components/schemas/Framework"
                      }
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createFramework",
        "summary": "Save a framework",
        "responses": {
          "201": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Framework"
              }
            }
          }
        }
      }
    },
    "/v1/datasets": {
      "post": {
        "operationId": "createDataset",
        "summary": "Create a private dataset",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dataset"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Dataset"
              }
            }
          }
        }
      }
    },
    "/v1/datasets/{id}/records": {
      "post": {
        "operationId": "addRecords",
        "summary": "Send your own records",
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Records"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/v1/opt-out": {
      "post": {
        "operationId": "optOut",
        "summary": "Remove a person",
        "responses": {
          "202": {
            "description": "Accepted"
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OptOutRequest"
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Spend this period",
        "responses": {
          "200": {
            "description": "Usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Requirement": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "object",
            "properties": {
              "requirement": {
                "type": "string",
                "description": "The requirement in plain language."
              },
              "context_clues": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 300
                },
                "maxItems": 20,
                "description": "Signs that show the requirement is met."
              },
              "red_flags": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 300
                },
                "maxItems": 20,
                "description": "Signs that count against the person on this requirement."
              }
            },
            "required": [
              "requirement"
            ],
            "additionalProperties": false
          }
        ],
        "description": "A plain string, or an object with context clues and red flags."
      },
      "SearchRequest": {
        "type": "object",
        "properties": {
          "titles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "locations": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "years_of_experience": {
            "type": "object",
            "properties": {
              "min": {
                "type": "integer"
              },
              "max": {
                "type": "integer"
              }
            }
          },
          "must_haves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Requirement"
            }
          },
          "nice_to_haves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Requirement"
            }
          },
          "limit": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200,
            "default": 25
          },
          "min_score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "People scoring below this are not returned."
          },
          "framework": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Framework"
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  }
                },
                "required": [
                  "id"
                ]
              }
            ]
          },
          "output": {
            "$ref": "#/components/schemas/OutputSpec"
          },
          "freshness": {
            "type": "object",
            "properties": {
              "max_age_days": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "budget": {
            "type": "object",
            "properties": {
              "max_usd": {
                "type": "number",
                "minimum": 0
              }
            }
          },
          "dataset_ids": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "wait_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 60,
            "default": 30
          },
          "webhook_url": {
            "type": "string",
            "format": "uri"
          }
        },
        "additionalProperties": false,
        "description": "Send at least one of titles or must_haves."
      },
      "Framework": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "guidance": {
            "type": "string"
          },
          "criteria": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "weight": {
                  "type": "number",
                  "minimum": 0
                },
                "knockout": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "weight"
              ]
            }
          }
        },
        "required": [
          "criteria"
        ]
      },
      "OutputSpec": {
        "type": "object",
        "properties": {
          "format": {
            "type": "string",
            "enum": [
              "json",
              "jsonl",
              "csv"
            ],
            "default": "json"
          },
          "schema": {
            "type": "object",
            "description": "JSON Schema (safe subset) for each result's data object."
          }
        }
      },
      "Finding": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "evidence": {
            "type": "string"
          },
          "source": {
            "type": "string"
          }
        },
        "required": [
          "text",
          "evidence",
          "source"
        ]
      },
      "Verdict": {
        "type": "object",
        "properties": {
          "criterion": {
            "type": "string"
          },
          "met": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "evidence": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "context_clues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          },
          "red_flags": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          }
        },
        "required": [
          "criterion",
          "met"
        ]
      },
      "Source": {
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "fetched_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "provider",
          "fetched_at"
        ]
      },
      "Summary": {
        "type": "object",
        "properties": {
          "must_haves_met": {
            "type": "string",
            "description": "For example \"3 of 3\"."
          },
          "nice_to_haves_met": {
            "type": "string"
          },
          "unknown": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Criteria with no evidence either way."
          },
          "red_flags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Red flags found, in your wording."
          }
        },
        "required": [
          "must_haves_met",
          "nice_to_haves_met",
          "unknown",
          "red_flags"
        ]
      },
      "Person": {
        "type": "object",
        "properties": {
          "person_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "location": {
            "type": "string"
          },
          "years_of_experience": {
            "type": [
              "number",
              "null"
            ]
          },
          "score": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "summary": {
            "$ref": "#/components/schemas/Summary"
          },
          "must_haves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Verdict"
            }
          },
          "nice_to_haves": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Verdict"
            }
          },
          "framework": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Verdict"
            }
          },
          "verified_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Source"
            }
          },
          "data": {
            "type": "object"
          }
        },
        "required": [
          "person_id",
          "name",
          "score",
          "summary",
          "must_haves",
          "nice_to_haves",
          "sources"
        ]
      },
      "Search": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "completed",
              "failed"
            ]
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Person"
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "cost_usd": {
                "type": "number"
              },
              "profiles_searched": {
                "type": "integer"
              },
              "profiles_verified": {
                "type": "integer"
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "status",
          "created_at"
        ]
      },
      "UnlockRequest": {
        "type": "object",
        "properties": {
          "person_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "maxItems": 100
          },
          "types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "work_email",
                "personal_email",
                "mobile"
              ]
            }
          },
          "budget": {
            "type": "object",
            "properties": {
              "max_usd": {
                "type": "number"
              }
            }
          }
        },
        "required": [
          "person_ids",
          "types"
        ]
      },
      "Contact": {
        "type": "object",
        "properties": {
          "person_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "work_email",
              "personal_email",
              "mobile"
            ]
          },
          "value": {
            "type": [
              "string",
              "null"
            ]
          },
          "verified": {
            "type": "boolean"
          },
          "source": {
            "type": "string"
          }
        },
        "required": [
          "person_id",
          "type",
          "value"
        ]
      },
      "Dataset": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "records": {
            "type": "integer"
          }
        },
        "required": [
          "name"
        ]
      },
      "Records": {
        "type": "object",
        "properties": {
          "records": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "maxItems": 1000
          }
        },
        "required": [
          "records"
        ]
      },
      "OptOutRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "profile_url": {
            "type": "string"
          },
          "person_id": {
            "type": "string"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "period": {
            "type": "string"
          },
          "cost_usd": {
            "type": "number"
          },
          "searches": {
            "type": "integer"
          },
          "unlocks": {
            "type": "integer"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    }
  }
}
