{
  "openapi": "3.1.0",
  "info": {
    "title": "SD Home Pros public directory API",
    "version": "1.0.0",
    "description": "Read-only public business listings. No messages, quotes, bookings, account changes or purchases."
  },
  "servers": [
    {
      "url": "https://sdhomepros.app"
    }
  ],
  "paths": {
    "/api/agent/contractors/": {
      "get": {
        "operationId": "readPublicContractorDirectory",
        "summary": "Search listings or retrieve one by ID",
        "description": "Provide id alone for detail. Otherwise combine search filters. Categories and neighborhoods are exact names or slugs from the MCP list_service_areas tool. Results are alphabetically ordered. Data is directory information, not a credential or availability guarantee.",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 150
            }
          },
          {
            "name": "query",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "neighborhood",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "zipcode",
            "in": "query",
            "schema": {
              "type": "string",
              "pattern": "^\\d{5}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 10000,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public listings or one contractor, source label and retrieval time",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contractor"
                      }
                    },
                    "contractor": {
                      "anyOf": [
                        {
                          "$ref": "#/components/schemas/Contractor"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "totalMatches": {
                      "type": "integer"
                    },
                    "nextOffset": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "source": {
                      "enum": [
                        "turso",
                        "postgres",
                        "local_snapshot"
                      ]
                    },
                    "sourceTruncated": {
                      "type": "boolean"
                    },
                    "retrievedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "notice": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported query filters"
          },
          "403": {
            "description": "Host or browser origin rejected"
          },
          "404": {
            "description": "Listing not found"
          },
          "429": {
            "description": "Rate limit exceeded; honor Retry-After"
          },
          "503": {
            "description": "Directory temporarily unavailable"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Contractor": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "businessName": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "description": {
            "type": "string"
          },
          "businessPhone": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "zipcode": {
            "type": [
              "string",
              "null"
            ]
          },
          "serviceZipcodes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "listingClaimed": {
            "type": "boolean"
          },
          "profileUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "MCP connection and usage guide",
    "url": "https://sdhomepros.app/agents/"
  }
}
