{
  "openapi": "3.1.0",
  "info": {
    "title": "Midwest Legal Docs AI Agent API",
    "version": "2026-09-08",
    "description": "Catalog discovery and approved-agent checkout API for Midwest Legal Docs. Midwest Legal Docs is not a law firm and does not provide legal advice."
  },
  "servers": [
    {
      "url": "https://midwestlegaldocs.com"
    }
  ],
  "paths": {
    "/api/agent/catalog": {
      "get": {
        "summary": "Return the AI-readable Midwest Legal Docs catalog.",
        "responses": {
          "200": {
            "description": "Catalog response."
          }
        }
      }
    },
    "/api/agent/catalog/search": {
      "get": {
        "summary": "Search catalog items by query, state, and category.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": { "type": "string" },
            "description": "Search words, such as will, lease, refund, deed, or bill of sale."
          },
          {
            "name": "state",
            "in": "query",
            "schema": { "type": "string" },
            "description": "US state name when relevant."
          },
          {
            "name": "category",
            "in": "query",
            "schema": { "type": "string" },
            "description": "Catalog category slug."
          }
        ],
        "responses": {
          "200": {
            "description": "Search results."
          }
        }
      }
    },
    "/api/agent/checkout-session": {
      "post": {
        "summary": "Create a Stripe Checkout Session for an approved agent purchase.",
        "security": [
          {
            "agentBearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["item_id"],
                "properties": {
                  "item_id": { "type": "string", "example": "bill-of-sale" },
                  "agent_id": { "type": "string", "example": "partner-agent-name" },
                  "agent_platform": { "type": "string", "example": "partner-platform" },
                  "buyer_reference": { "type": "string", "example": "buyer-or-session-reference" },
                  "email": { "type": "string", "example": "buyer@example.com" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stripe Checkout Session response with checkout URL."
          },
          "401": {
            "description": "Missing agent API key."
          },
          "403": {
            "description": "Invalid key or item not allowed for agent purchase."
          }
        }
      }
    },
    "/api/agent/orders/{id}": {
      "get": {
        "summary": "Look up an approved agent order or Stripe Checkout Session.",
        "security": [
          {
            "agentBearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "Stripe Checkout Session ID or Midwest Legal Docs order ID."
          }
        ],
        "responses": {
          "200": {
            "description": "Order or checkout-session status."
          },
          "401": {
            "description": "Missing agent API key."
          },
          "403": {
            "description": "Invalid agent API key."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "agentBearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Approved Midwest Legal Docs agent API key."
      }
    }
  },
  "externalDocs": {
    "description": "Midwest Legal Docs AI Agent Catalog",
    "url": "https://midwestlegaldocs.com/ai-agent-catalog.html"
  }
}
