{
  "openapi": "3.1.0",
  "info": {
    "title": "AI Court Orders API",
    "version": "1.0.0",
    "description": "Query 900+ U.S. court orders & opinions on AI use in legal filings (judges sanctioning hallucinated citations, AI standing orders, etc.)."
  },
  "servers": [
    {
      "url": "https://ai-orders-agent.vercel.app"
    }
  ],
  "paths": {
    "/api/search": {
      "get": {
        "operationId": "searchOrders",
        "summary": "Full-text search over name/summary/judge/court with filters.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "text query"
          },
          {
            "name": "judge",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judge (title-insensitive substring, e.g. \"Wang\")"
          },
          {
            "name": "court",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Court (alias-aware: \"sdny\" / \"S.D.N.Y.\" / \"southern district of new york\")"
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "State (full name)"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judicial Opinion | Standing Order | Local Rules | Administrative Order | Practice Direction"
          },
          {
            "name": "consequence",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "sanctions_attorney | sanctions_party | warning"
          },
          {
            "name": "ai_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Gen AI | Any AI"
          },
          {
            "name": "applies_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Attorneys | Pro Se Litigants | Any Parties (matches multi-value records)"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "rg | rails | both"
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "US | Canada | UK | New Zealand"
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "applicableTo tag substring"
          },
          {
            "name": "requires",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "only records whose reqs[KEY] is set, e.g. disclose, certify_if_ai, certify_all, verify, prohibited, proprietary"
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            }
          },
          {
            "name": "full",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "return whole records, not the summary projection"
          },
          {
            "name": "count",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "return only the number of matches"
          },
          {
            "name": "has_pdf",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "has_link",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "matching records (or {count})"
          }
        }
      }
    },
    "/api/list": {
      "get": {
        "operationId": "listOrders",
        "summary": "Filter records without a text query.",
        "parameters": [
          {
            "name": "judge",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judge (title-insensitive substring, e.g. \"Wang\")"
          },
          {
            "name": "court",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Court (alias-aware: \"sdny\" / \"S.D.N.Y.\" / \"southern district of new york\")"
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "State (full name)"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judicial Opinion | Standing Order | Local Rules | Administrative Order | Practice Direction"
          },
          {
            "name": "consequence",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "sanctions_attorney | sanctions_party | warning"
          },
          {
            "name": "ai_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Gen AI | Any AI"
          },
          {
            "name": "applies_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Attorneys | Pro Se Litigants | Any Parties (matches multi-value records)"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "rg | rails | both"
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "US | Canada | UK | New Zealand"
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "applicableTo tag substring"
          },
          {
            "name": "requires",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "only records whose reqs[KEY] is set, e.g. disclose, certify_if_ai, certify_all, verify, prohibited, proprietary"
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50
            }
          },
          {
            "name": "full",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "return whole records, not the summary projection"
          },
          {
            "name": "count",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "return only the number of matches"
          },
          {
            "name": "has_pdf",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "has_link",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "records"
          }
        }
      }
    },
    "/api/record/{id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Fetch one full record by id.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "record"
          }
        }
      }
    },
    "/api/pdf/{id}": {
      "get": {
        "operationId": "getPdf",
        "summary": "Self-hosted PDF + source links for a record.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "pdf + links"
          }
        }
      }
    },
    "/api/facets": {
      "get": {
        "operationId": "facets",
        "summary": "Distinct values + counts for a field. Honors all search/list filters (e.g. field=court&consequence=sanctions_attorney ranks courts by attorney-sanction count).",
        "parameters": [
          {
            "name": "field",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "judge | court | state | type | consequence | ai_type"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "all",
            "in": "query",
            "schema": {
              "type": "boolean"
            },
            "description": "include court-wide placeholders"
          },
          {
            "name": "judge",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judge (title-insensitive substring, e.g. \"Wang\")"
          },
          {
            "name": "court",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Court (alias-aware: \"sdny\" / \"S.D.N.Y.\" / \"southern district of new york\")"
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "State (full name)"
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Judicial Opinion | Standing Order | Local Rules | Administrative Order | Practice Direction"
          },
          {
            "name": "consequence",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "sanctions_attorney | sanctions_party | warning"
          },
          {
            "name": "ai_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Gen AI | Any AI"
          },
          {
            "name": "applies_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Attorneys | Pro Se Litigants | Any Parties (matches multi-value records)"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "rg | rails | both"
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "US | Canada | UK | New Zealand"
          },
          {
            "name": "tag",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "applicableTo tag substring"
          },
          {
            "name": "requires",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "only records whose reqs[KEY] is set, e.g. disclose, certify_if_ai, certify_all, verify, prohibited, proprietary"
          },
          {
            "name": "date_from",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "date_to",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "YYYY-MM-DD"
          },
          {
            "name": "has_pdf",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "has_link",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "value/count pairs"
          }
        }
      }
    },
    "/api/stats": {
      "get": {
        "operationId": "stats",
        "summary": "Dataset summary counts.",
        "responses": {
          "200": {
            "description": "stats"
          }
        }
      }
    },
    "/api/bar": {
      "get": {
        "operationId": "barOpinions",
        "summary": "State bar AI ethics opinions.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "bar opinions"
          }
        }
      }
    }
  }
}