{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "US Pipeline.AI Public Construction Records, Statutory Rules & AX Live API",
    "version": "1.2.0",
    "summary": "Agent-Experience (AX) API: read-only permit, violation, contractor license and benchmark queries, plus watchlist subscribe and unsubscribe.",
    "description": "Real-time machine-readable public construction intelligence across 27 US states (AZ, CA, CO, CT, DC, DE, FL, HI, IL, IN, KY, LA, MA, MD, MI, MO, NC, NY, OH, OR, PA, RI, TN, TX, UT, VA, WA). Enforces 100-Block parcel corridor privacy masking (zero exact street numbers or resident PII) and excludes unvalued municipal filings from cost medians rather than counting them as zero. All other endpoints are read-only. Double opt-in: the subscription only becomes active after the owner of the email address confirms it. POST /api/public/v1/live/watchlist stores the request as pending and emails a confirmation link that expires in 48 hours; the API never returns that link or any token. The owner opens the link (GET /api/public/v1/live/watchlist/confirm shows a Confirm button) and the button (POST /api/public/v1/live/watchlist/confirm) activates the weekly alert. No alert is sent to pending or expired requests. GET /api/public/v1/live/watchlist/unsubscribe (one-click opt-out with the emailed token) cancels at any time. Agents must call the subscribe operation only after the person who owns the email explicitly asks to subscribe.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    },
    "contact": {
      "name": "US Pipeline.AI Public Data Engineering",
      "url": "https://uspipeline.ai/open-datasets/"
    }
  },
  "servers": [
    {
      "url": "https://uspipeline.ai",
      "description": "US Pipeline.AI Production Public & AI-Agent Endpoint"
    }
  ],
  "paths": {
    "/api/public/v1/live/health": {
      "get": {
        "operationId": "getLiveServiceHealth",
        "summary": "Check live AX & Watchlist microservice health and active shard inventory",
        "responses": {
          "200": {
            "description": "Service operational",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/live/search": {
      "get": {
        "operationId": "searchPublicPermitsViolationsAndLicenses",
        "summary": "Real-time read-only search across municipal permit, code violation, and state license shards",
        "description": "Queries US Pipeline SQLite/zlib shards in read-only mode. Filters across record ID, 100-Block corridor, 5-digit ZIP code, scope description, application type, and trade discipline. Returns declared_valuation_usd = null whenever municipal valuation is missing or non-positive.",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Two-letter state code filter (AZ, CA, CO, CT, DC, DE, FL, HI, IL, IN, KY, LA, MA, MD, MI, MO, NC, NY, OH, OR, PA, RI, TN, TX, UT, VA, WA)",
            "schema": {
              "type": "string",
              "enum": [
                "AZ",
                "CA",
                "CO",
                "CT",
                "DC",
                "DE",
                "FL",
                "HI",
                "IL",
                "IN",
                "KY",
                "LA",
                "MA",
                "MD",
                "MI",
                "MO",
                "NC",
                "NY",
                "OH",
                "OR",
                "PA",
                "RI",
                "TN",
                "TX",
                "UT",
                "VA",
                "WA"
              ]
            }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "description": "Municipality slug (e.g. los-angeles, miami, boston, austin, new-york)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Keyword, ZIP code, 100-Block street name, permit docket, or license number",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum records returned (1..25, default 10)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Structured 100-Block privacy-masked public records",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LiveSearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid query parameter"
          }
        }
      }
    },
    "/api/public/v1/live/benchmarks": {
      "get": {
        "operationId": "getLiveMunicipalBenchmarks",
        "summary": "Fetch empirical P25/Median/P75 permit valuation quartiles and electrification benchmarks by state",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Optional state filter (AZ, CA, CO, CT, DC, DE, FL, HI, IL, IN, KY, LA, MA, MD, MI, MO, NC, NY, OH, OR, PA, RI, TN, TX, UT, VA, WA)",
            "schema": {
              "type": "string",
              "enum": [
                "AZ",
                "CA",
                "CO",
                "CT",
                "DC",
                "DE",
                "FL",
                "HI",
                "IL",
                "IN",
                "KY",
                "LA",
                "MA",
                "MD",
                "MI",
                "MO",
                "NC",
                "NY",
                "OH",
                "OR",
                "PA",
                "RI",
                "TN",
                "TX",
                "UT",
                "VA",
                "WA"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Empirical municipal construction benchmarks (CC BY 4.0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BenchmarksResponse"
                }
              }
            }
          },
          "404": {
            "description": "Benchmark dataset file not found"
          }
        }
      }
    },
    "/api/public/v1/live/watchlist": {
      "post": {
        "operationId": "subscribePublicRecordWatchlist",
        "summary": "Subscribe to free weekly municipal permit, ZIP code, or contractor license updates",
        "description": "Double opt-in: the subscription only becomes active after the owner of the email address confirms it. POST /api/public/v1/live/watchlist stores the request as pending and emails a confirmation link that expires in 48 hours; the API never returns that link or any token. The owner opens the link (GET /api/public/v1/live/watchlist/confirm shows a Confirm button) and the button (POST /api/public/v1/live/watchlist/confirm) activates the weekly alert. No alert is sent to pending or expired requests. GET /api/public/v1/live/watchlist/unsubscribe (one-click opt-out with the emailed token) cancels at any time. Agents must call the subscribe operation only after the person who owns the email explicitly asks to subscribe.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WatchlistSubscribeRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Request stored as pending; a confirmation link valid for 48 hours was emailed. Nothing is active until the email owner confirms.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistSubscribeResponse"
                }
              }
            }
          },
          "200": {
            "description": "This email already confirmed this alert; it stays active and no new email is sent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WatchlistSubscribeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error on watch_type, watch_target, email, or persona"
          },
          "429": {
            "description": "Rate limit exceeded for IP SHA-256 window"
          }
        }
      }
    },
    "/api/public/v1/live/watchlist/confirm": {
      "get": {
        "operationId": "showWatchlistConfirmation",
        "summary": "HTML page with a Confirm button for the emailed confirmation link (does not change data)",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "description": "Confirmation token sent only by email",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confirmation page",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Malformed token"
          }
        }
      },
      "post": {
        "operationId": "confirmPublicRecordWatchlist",
        "summary": "Email owner confirms the pending alert; only this step makes the subscription active",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Subscription is now active",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "No pending request matches this token"
          },
          "410": {
            "description": "Confirmation link expired after 48 hours; nothing was activated"
          },
          "429": {
            "description": "Rate limit exceeded for IP SHA-256 window"
          }
        }
      }
    },
    "/api/public/v1/live/watchlist/unsubscribe": {
      "get": {
        "operationId": "unsubscribePublicRecordWatchlist",
        "summary": "One-click immediate CAN-SPAM compliant unsubscribe confirmation",
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "description": "Cryptographic URL-safe unsubscribe token",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "HTML confirmation of immediate cancellation",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Token not found"
          }
        }
      }
    },
    "/api/public/v1/statutory-calculator-rules.json": {
      "get": {
        "operationId": "getStatutoryCalculatorRulesJson",
        "summary": "Static statutory deposit cap, retainage, escrow, and plan-check rules across CA, FL, MA, TX, and NY",
        "responses": {
          "200": {
            "description": "Machine-readable statutory rules JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/open-datasets/us-municipal-construction-benchmarks-2026.json": {
      "get": {
        "operationId": "downloadOpenBenchmarksDatasetJson",
        "summary": "Full CC BY 4.0 US Municipal Building Permit, Electrification & Valuation Benchmarks JSON",
        "responses": {
          "200": {
            "description": "Full open benchmark dataset JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BenchmarksResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/live/indexes": {
      "get": {
        "operationId": "getProprietaryConstructionIndexes",
        "summary": "Retrieve the 6 official US Pipeline.AI Proprietary Construction Indexes (UP-CAI, UP-PVI, UP-CI, UP-CDI, UP-MOI, UP-SEI)",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "city",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "index",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "UP-CAI",
                "UP-PVI",
                "UP-CI",
                "UP-CDI",
                "UP-MOI",
                "UP-SEI"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Proprietary construction indexes JSON (CC BY 4.0, NULL != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/live/license-verify": {
      "get": {
        "operationId": "verifyContractorStateLicense",
        "summary": "Verify state contractor license standing, issuing authority, and classification across 2.01M+ state licensing records",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "license",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 15
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Normalized state contractor licensing records",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/live/solutions": {
      "get": {
        "operationId": "getUspipelinePlatformSolutions",
        "summary": "Retrieve contextual US Pipeline.AI platform capabilities and 0%-commission pricing for contractors, homeowners, and realtors",
        "parameters": [
          {
            "name": "audience",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "contractor",
                "homeowner",
                "realtor",
                "all"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Platform capabilities and official pricing JSON",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/v1/live/badge.svg": {
      "get": {
        "operationId": "renderContractorVerificationSealSvg",
        "summary": "Render dynamic SVG public-record license verification seal with issuing authority and UTC check timestamp",
        "parameters": [
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "license",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SVG verification seal",
            "content": {
              "image/svg+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HealthResponse": {
        "type": "object",
        "required": [
          "ok",
          "service",
          "version",
          "readonly_shards",
          "shards_available",
          "timestamp_utc"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "readonly_shards": {
            "type": "boolean"
          },
          "shards_available": {
            "type": "integer"
          },
          "null_policy": {
            "type": "string"
          },
          "pii_policy": {
            "type": "string"
          },
          "timestamp_utc": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PublicShardRecord": {
        "type": "object",
        "required": [
          "record_id",
          "silo",
          "state",
          "city",
          "corridor_100_block",
          "zip_code",
          "discipline",
          "status",
          "declared_valuation_usd",
          "canonical_url",
          "calculator_url"
        ],
        "properties": {
          "record_id": {
            "type": "string"
          },
          "silo": {
            "type": "string",
            "enum": [
              "permits",
              "code-violations",
              "licenses"
            ]
          },
          "state": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "corridor_100_block": {
            "type": "string",
            "description": "100-Block masked street corridor (zero exact door or unit numbers)"
          },
          "zip_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "discipline": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "declared_valuation_usd": {
            "type": [
              "number",
              "null"
            ],
            "description": "Declared valuation in USD, or null when unvalued or non-positive rather than zero"
          },
          "canonical_url": {
            "type": "string",
            "format": "uri"
          },
          "calculator_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "LiveSearchResponse": {
        "type": "object",
        "required": [
          "ok",
          "service",
          "count",
          "results"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "type": "string"
          },
          "query": {
            "type": "object"
          },
          "null_policy": {
            "type": "string"
          },
          "pii_policy": {
            "type": "string"
          },
          "count": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicShardRecord"
            }
          }
        }
      },
      "BenchmarksResponse": {
        "type": "object",
        "required": [
          "jurisdictions"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "dataset_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "license": {
            "type": "string"
          },
          "attribution_required": {
            "type": [
              "string",
              "null"
            ]
          },
          "generated_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "null_policy": {
            "type": "string"
          },
          "state_filter": {
            "type": [
              "string",
              "null"
            ]
          },
          "count": {
            "type": "integer"
          },
          "jurisdictions": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "WatchlistSubscribeRequest": {
        "type": "object",
        "required": [
          "watch_type",
          "watch_target",
          "email",
          "persona"
        ],
        "properties": {
          "watch_type": {
            "type": "string",
            "enum": [
              "zip",
              "city",
              "license"
            ]
          },
          "watch_target": {
            "type": "string",
            "description": "5-digit ZIP code, municipality name, or state contractor license number"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "persona": {
            "type": "string",
            "enum": [
              "homeowner",
              "contractor",
              "realtor"
            ]
          }
        }
      },
      "WatchlistSubscribeResponse": {
        "type": "object",
        "required": [
          "ok",
          "status",
          "watch_type",
          "watch_target",
          "email",
          "confirmation_email_sent",
          "message"
        ],
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "active"
            ],
            "description": "pending until the email owner confirms; active only after confirmation"
          },
          "watch_type": {
            "type": "string"
          },
          "watch_target": {
            "type": "string"
          },
          "persona": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "cadence": {
            "type": "string"
          },
          "confirmation_email_sent": {
            "type": "boolean"
          },
          "confirmation_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}
