{
  "openapi": "3.1.0",
  "info": {
    "title": "DeedAgent AI assistant API",
    "version": "1.0.0",
    "description": "Read-only access to the signed-in organization's probate queue. The tenant comes from the token; a tenant id in the request is rejected. Outputs are diligence support, not legal, tax, or investment advice.",
    "contact": {
      "email": "support@deedagent.ai"
    },
    "termsOfService": "https://deedagent.ai/terms"
  },
  "servers": [
    {
      "url": "https://deedagent.ai/api/assistants/v1"
    }
  ],
  "security": [
    {
      "oauth": [
        "counties:read",
        "deals:read"
      ]
    }
  ],
  "paths": {
    "/counties": {
      "get": {
        "operationId": "list_counties",
        "summary": "Counties this account can open",
        "security": [
          {
            "oauth": [
              "counties:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Counties",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "counties": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "jurisdiction": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/deals": {
      "get": {
        "operationId": "search_deals",
        "summary": "Probate opportunities in the account's queue",
        "security": [
          {
            "oauth": [
              "deals:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "County code from /counties."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "property_match",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "missing"
              ]
            },
            "description": "Only deals still missing a property match."
          }
        ],
        "responses": {
          "200": {
            "description": "Deals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deals": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deal"
                      }
                    },
                    "reason": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Set when the list is empty: the queue is empty, or the county is not open to this account."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{id}": {
      "get": {
        "operationId": "get_deal",
        "summary": "One deal with its evidence and source links",
        "security": [
          {
            "oauth": [
              "deals:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deal": {
                      "$ref": "#/components/schemas/Deal"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Deal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "case_number": {
            "type": [
              "string",
              "null"
            ]
          },
          "jurisdiction": {
            "type": [
              "string",
              "null"
            ],
            "description": "County code."
          },
          "status": {
            "type": "string"
          },
          "filing_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "valuation_outcome": {
            "type": [
              "string",
              "null"
            ]
          },
          "refusal_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the valuation was refused, when it was."
          },
          "property_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "property_match": {
            "type": "string",
            "enum": [
              "matched",
              "missing"
            ]
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "execution_id": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "oauth": {
        "type": "oauth2",
        "description": "Authorization code with PKCE (S256). Client id: muse. Tokens expire after one hour and are not refreshed.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://deedagent.ai/assistants/connect",
            "tokenUrl": "https://deedagent.ai/api/assistants/oauth/token",
            "scopes": {
              "account:read": "Read the signed-in account",
              "counties:read": "List counties the account can open",
              "deals:read": "Read deals in the account's queue"
            }
          }
        }
      }
    }
  }
}