{
  "openapi": "3.0.3",
  "info": {
    "title": "PlateHog — Vanity License Plate API",
    "version": "1.0.0",
    "description": "Check vanity license plate availability across 8 US states (California, Florida, Ohio, New York, Maine, West Virginia, Kansas, Tennessee), get plate rules, watch plates for availability changes, and browse rejected plates for inspiration. Requires a PlateHog API token (Bearer) — get one free at platehog.com/connect/muse.",
    "contact": {
      "name": "PlateHog Support",
      "url": "https://platehog.com/contact",
      "email": "support@platehog.com"
    },
    "termsOfService": "https://platehog.com/terms",
    "license": {
      "name": "PlateHog Terms of Service",
      "url": "https://platehog.com/terms"
    }
  },
  "externalDocs": {
    "description": "PlateHog Muse Connector Documentation",
    "url": "https://platehog.com/docs/muse-connector"
  },
  "servers": [
    {
      "url": "https://platehog.com/api/connector/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "BearerToken": []
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "PlateHog API token. Format: `phog_at_<hex>`. Get one free at platehog.com/connect/muse."
      }
    },
    "schemas": {
      "PlateCheckResult": {
        "type": "object",
        "required": ["plate", "state", "state_code", "status", "checked_at", "data_tier", "dmv_url", "checks_remaining_today", "checks_limit"],
        "properties": {
          "plate": {
            "type": "string",
            "example": "MYRIDE",
            "description": "The plate text, uppercased"
          },
          "state": {
            "type": "string",
            "example": "california",
            "description": "Lowercase hyphenated state name"
          },
          "state_code": {
            "type": "string",
            "example": "CA",
            "description": "2-letter USPS state code"
          },
          "status": {
            "type": "string",
            "enum": ["available", "taken", "unknown"],
            "description": "available = plate can be ordered; taken = already registered; unknown = DMV unreachable"
          },
          "checked_at": {
            "type": "string",
            "format": "date-time",
            "description": "ISO timestamp of when the check was made or served from cache"
          },
          "data_tier": {
            "type": "string",
            "enum": ["realtime", "cached", "batch"],
            "description": "realtime = live DMV API; cached = recent stored result; batch = nightly snapshot"
          },
          "dmv_url": {
            "type": "string",
            "format": "uri",
            "description": "PlateHog URL for this plate's detail page with ordering links"
          },
          "checks_remaining_today": {
            "type": "integer",
            "description": "Daily quota remaining (free: 10/day; pro: unlimited)"
          },
          "checks_limit": {
            "type": "integer",
            "description": "Total daily cap for this account tier"
          }
        }
      },
      "MultiCheckResult": {
        "type": "object",
        "required": ["state", "state_code", "results", "checks_used", "checks_remaining_today", "checks_limit"],
        "properties": {
          "state": {
            "type": "string",
            "example": "california"
          },
          "state_code": {
            "type": "string",
            "example": "CA"
          },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["plate", "status", "checked_at", "data_tier", "dmv_url"],
              "properties": {
                "plate": { "type": "string" },
                "status": { "type": "string", "enum": ["available", "taken", "unknown"] },
                "checked_at": { "type": "string", "format": "date-time" },
                "data_tier": { "type": "string" },
                "dmv_url": { "type": "string", "format": "uri" }
              }
            }
          },
          "checks_used": {
            "type": "integer"
          },
          "checks_remaining_today": {
            "type": "integer"
          },
          "checks_limit": {
            "type": "integer"
          }
        }
      },
      "NotSupportedResult": {
        "type": "object",
        "required": ["plate", "state", "status", "message", "supported_states"],
        "properties": {
          "plate": { "type": "string" },
          "state": { "type": "string" },
          "status": { "type": "string", "enum": ["not_supported"] },
          "message": { "type": "string" },
          "dmv_url": { "type": "string", "format": "uri", "nullable": true },
          "notify_url": { "type": "string", "format": "uri" },
          "supported_states": {
            "type": "array",
            "items": { "type": "string" }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["error", "message"],
        "properties": {
          "error": { "type": "string" },
          "code": { "type": "string" },
          "message": { "type": "string" }
        }
      }
    }
  },
  "paths": {
    "/check/{state}/{plate}": {
      "get": {
        "operationId": "check_plate_availability",
        "summary": "Check if a vanity plate is available",
        "description": "Look up whether a specific vanity license plate text is available for registration in a US state. Returns 'available' if the plate can be ordered, 'taken' if already registered, or 'unknown' if the DMV is temporarily unreachable. Supported states: california, florida, ohio, new-york, maine, west-virginia, kansas, tennessee. Use this when someone asks 'is MYPLATE available in California?' or 'can I get TREX on my New York plate?'",
        "parameters": [
          {
            "name": "state",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["california", "florida", "ohio", "new-york", "maine", "west-virginia", "kansas", "tennessee"]
            },
            "example": "california",
            "description": "State name as a lowercase hyphenated slug"
          },
          {
            "name": "plate",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Z0-9]{2,8}$",
              "minLength": 2,
              "maxLength": 8
            },
            "example": "MYRIDE",
            "description": "Plate text: 2–8 uppercase alphanumeric characters, no spaces or punctuation"
          }
        ],
        "responses": {
          "200": {
            "description": "Availability result (includes not_supported for unsupported states)",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/PlateCheckResult" },
                    { "$ref": "#/components/schemas/NotSupportedResult" }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "422": {
            "description": "Invalid plate format",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Daily quota exceeded",
            "headers": {
              "Retry-After": {
                "schema": { "type": "integer" },
                "description": "Seconds until quota resets (86400 = next day)"
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/check/multi": {
      "post": {
        "operationId": "check_plates_multi",
        "summary": "Check multiple plates in one state",
        "description": "Check up to 5 plates at once (free plan) or 20 plates at once (pro plan) in a single US state. More efficient than calling check_plate_availability multiple times. Use this when someone asks 'check MYRIDE, MYVIBE, MYWHEELS in California' or provides a list of plate ideas to compare. All plates in a single call must be for the same state.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["state", "plates"],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": ["california", "florida", "ohio", "new-york", "maine", "west-virginia", "kansas", "tennessee"],
                    "example": "california"
                  },
                  "plates": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "pattern": "^[A-Z0-9]{2,8}$"
                    },
                    "minItems": 1,
                    "maxItems": 20,
                    "example": ["MYRIDE", "MYVIBE", "MYWHEEL"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Availability results for all requested plates",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/MultiCheckResult" }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API token",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "422": {
            "description": "Validation error (too many plates, invalid format, unsupported state)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": {
            "description": "Daily quota exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "503": {
            "description": "Service temporarily unavailable",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/suggest/{state}/{plate}": {
      "get": {
        "operationId": "suggest_plate_alternatives",
        "summary": "Suggest available alternatives when a plate is taken",
        "description": "Generate creative alternative plate suggestions for a state when the user's desired plate is already taken. Returns 5–10 alternatives that are confirmed available, based on character substitutions, common prefixes/suffixes, and abbreviations. Use this when someone asks 'MYRIDE is taken, what else could I try in California?'",
        "parameters": [
          {
            "name": "state",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["california", "florida", "ohio", "new-york", "maine", "west-virginia", "kansas", "tennessee"]
            }
          },
          {
            "name": "plate",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Z0-9]{2,8}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alternative plate suggestions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "original_plate": { "type": "string" },
                    "state": { "type": "string" },
                    "state_code": { "type": "string" },
                    "alternatives": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "plate": { "type": "string" },
                          "status": { "type": "string" },
                          "checked_at": { "type": "string", "format": "date-time" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rules/{state}": {
      "get": {
        "operationId": "get_plate_rules",
        "summary": "Get vanity plate rules and restrictions for a state",
        "description": "Return the official rules for vanity plates in a US state: allowed characters, minimum and maximum length, prohibited words/patterns, and fees. Use this when someone asks 'what are the rules for California vanity plates?' or 'how many characters can a Texas plate have?'",
        "parameters": [
          {
            "name": "state",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["california", "florida", "ohio", "new-york", "maine", "west-virginia", "kansas", "tennessee"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Plate rules for the state",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "state": { "type": "string" },
                    "state_code": { "type": "string" },
                    "min_length": { "type": "integer" },
                    "max_length": { "type": "integer" },
                    "allowed_chars": { "type": "string", "description": "Regex pattern of allowed characters" },
                    "notes": {
                      "type": "array",
                      "items": { "type": "string" }
                    },
                    "dmv_url": { "type": "string", "format": "uri" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/watchlist": {
      "post": {
        "operationId": "add_plate_to_watchlist",
        "summary": "Watch a plate and get notified when it becomes available",
        "description": "Add a vanity plate to the user's watch list. PlateHog will monitor the plate and send an email (or SMS for pro accounts) when it becomes available. Use this when someone asks 'notify me when MYRIDE is available in California' or 'watch TREX for me in New York'. Requires a free PlateHog account. Free accounts can watch up to 5 plates; pro accounts up to 50.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["state", "plate"],
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": ["california", "florida", "ohio", "new-york", "maine", "west-virginia", "kansas", "tennessee"]
                  },
                  "plate": {
                    "type": "string",
                    "pattern": "^[A-Z0-9]{2,8}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Plate added to watchlist (or already watched)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "watchlist_id": { "type": "string" },
                    "plate": { "type": "string" },
                    "state": { "type": "string" },
                    "state_code": { "type": "string" },
                    "already_watched": { "type": "boolean" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/rejected": {
      "get": {
        "operationId": "get_rejected_plates",
        "summary": "Browse rejected vanity plates — humor and inspiration",
        "description": "Browse the Hall of Shame: real vanity plates rejected by state DMVs, sourced from official FOIA requests (19,000+ plates from California and New York). Great for entertainment, creative inspiration for plate ideas, or understanding what DMVs typically reject. Use this when someone asks 'show me funny rejected plates', 'what plates have been banned in California?', or 'give me some creative plate ideas'.",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": { "type": "integer", "minimum": 1, "maximum": 20, "default": 10 },
            "description": "Number of plates to return"
          },
          {
            "name": "state",
            "in": "query",
            "schema": { "type": "string", "enum": ["CA", "NY"] },
            "description": "Filter by state (CA or NY only — FOIA data)"
          },
          {
            "name": "sort",
            "in": "query",
            "schema": { "type": "string", "enum": ["hot", "top", "newest", "random"], "default": "hot" },
            "description": "Sort order: hot = trending, top = most upvoted, newest = most recent, random = random selection"
          }
        ],
        "responses": {
          "200": {
            "description": "List of rejected plates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "plates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "string" },
                          "plate_text": { "type": "string" },
                          "state": { "type": "string" },
                          "reason": { "type": "string", "nullable": true },
                          "vote_count": { "type": "integer" },
                          "url": { "type": "string", "format": "uri" }
                        }
                      }
                    },
                    "total": { "type": "integer" },
                    "next_cursor": { "type": "string", "nullable": true }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
