{
  "openapi": "3.1.0",
  "info": {
    "title": "ResearchOS Research Workers API",
    "version": "1.0.0",
    "description": "AI-agnostic API for parallel research projects, persistent numbered windows, live dedupe and flexible JSON catalog entries. Requires a project-issued secret bearer key and an HTTP-capable client or GPT Action."
  },
  "servers": [
    {
      "url": "https://www.findmethis.dev"
    }
  ],
  "components": {
    "securitySchemes": {
      "ResearchOSKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Use the key issued by the ResearchOS owner for this specific project. Do not publish it."
      }
    }
  },
  "paths": {
    "/api/ai/brief": {
      "get": {
        "operationId": "getResearchBrief",
        "summary": "Get current research brief",
        "description": "Fetch the canonical project objective and all current filtering rules before every research round.",
        "parameters": [
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "ResearchOS project UUID"
          }
        ],
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/windows": {
      "get": {
        "operationId": "listResearchWindows",
        "summary": "List project windows",
        "description": "Retrieve globally numbered AI window sessions and contribution summaries.",
        "parameters": [
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "ResearchOS project UUID"
          }
        ],
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      },
      "post": {
        "operationId": "registerResearchWindow",
        "summary": "Register a research chat",
        "description": "Register one stable session_key per AI chat. Reuse it for subsequent research rounds in that same chat; always use the returned numeric window.id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id",
                  "session_key"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "session_key": {
                    "type": "string",
                    "minLength": 8
                  },
                  "label": {
                    "type": "string"
                  },
                  "model": {
                    "type": "string"
                  },
                  "focus": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/check": {
      "post": {
        "operationId": "checkResearchCandidate",
        "summary": "Validate and deduplicate discovery",
        "description": "Check project rules, exclusions, and existing records. Submit this before every catalog import. status=eligible permits a later import.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id",
                  "title",
                  "window_id"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "window_id": {
                    "type": "integer"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "identity_key": {
                    "type": "string"
                  },
                  "source_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "category": {
                    "type": "string"
                  },
                  "attributes": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/entries": {
      "get": {
        "operationId": "listResearchEntries",
        "summary": "Search existing catalog",
        "description": "Read existing permanent discoveries; use q, before_id and limit for paginated results. Never assume a partial page contains the whole catalog.",
        "parameters": [
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "ResearchOS project UUID"
          },
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 200
            }
          },
          {
            "name": "before_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      },
      "post": {
        "operationId": "importResearchEntry",
        "summary": "Import a verified new discovery",
        "description": "Atomic database dedupe, server-side machine-checkable filters and permanent window attribution. A success response may still be duplicate, excluded or rejected; only status=added confirms insertion.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id",
                  "window_id",
                  "title"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "window_id": {
                    "type": "integer"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "identity_key": {
                    "type": "string"
                  },
                  "source_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "category": {
                    "type": "string"
                  },
                  "attributes": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/events": {
      "get": {
        "operationId": "listResearchEvents",
        "summary": "View research activity",
        "description": "See recent research rounds, duplicate logs and evidence of actual submissions.",
        "parameters": [
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "ResearchOS project UUID"
          },
          {
            "name": "window_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      },
      "post": {
        "operationId": "logResearchActivity",
        "summary": "Log research activity",
        "description": "Append a permanent factual activity report attributed to the real registered window.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id",
                  "window_id",
                  "type"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "window_id": {
                    "type": "integer"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "note",
                      "prompt_sent",
                      "round",
                      "researching",
                      "heartbeat",
                      "state",
                      "error",
                      "no_results",
                      "source_checked",
                      "rejected"
                    ]
                  },
                  "round_number": {
                    "type": "integer"
                  },
                  "message": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  },
                  "details": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/exclusions": {
      "get": {
        "operationId": "listResearchExclusions",
        "summary": "List excluded identities",
        "description": "List project-level prohibited candidate identifiers.",
        "parameters": [
          {
            "name": "project_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "ResearchOS project UUID"
          }
        ],
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      },
      "post": {
        "operationId": "excludeResearchCandidate",
        "summary": "Exclude a verified invalid candidate",
        "description": "Only exclude an identity if genuinely invalid. Do not exclude entire sources for a no-results search round.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "window_id": {
                    "type": "integer"
                  },
                  "title": {
                    "type": "string"
                  },
                  "source_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "identity_key": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "201": {
            "description": "JSON result from ResearchOS",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    },
    "/api/ai/batch": {
      "post": {
        "operationId": "importResearchBatch",
        "summary": "Import up to 12 verified discoveries for one registered AI window",
        "description": "One authenticated request, up to twelve entries; each outcome is added, duplicate, excluded, or rejected. Shared window_id is mandatory for AI workers; each item can override it with another window registered to the same project. Server atomically de-duplicates by stable identity and normalized URL. Avoid submitting unverifiable claims.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "project_id",
                  "window_id",
                  "entries"
                ],
                "properties": {
                  "project_id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "window_id": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "entries": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 12,
                    "items": {
                      "type": "object",
                      "required": [
                        "title"
                      ],
                      "properties": {
                        "title": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "identity_key": {
                          "type": "string"
                        },
                        "source_url": {
                          "type": "string",
                          "format": "uri"
                        },
                        "category": {
                          "type": "string"
                        },
                        "attributes": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-item import results and summary with added, duplicate, excluded, rejected counts"
          }
        },
        "security": [
          {
            "ResearchOSKey": []
          }
        ]
      }
    }
  }
}