{
  "openapi": "3.1.0",
  "info": {
    "title": "Cleaning Hive agent quotes",
    "version": "1.1.0",
    "description": "Server-to-server quote requests and bearer-token status polling. Quotes are not bookings. Browser origins restricted. Never put status tokens in logs. Form vocabulary and pricing bands are documented in booking-fields.json. Automatic residential services: regular, deep, move_in_out, post_renovation and airbnb; other services need team review. Frequencies: one_time, weekly, biweekly, every_3_weeks and every_4_weeks. Prices and taxes are read from the regional Booking Summary; no appointment is booked."
  },
  "servers": [
    {
      "url": "https://cleaninghive.ca"
    }
  ],
  "paths": {
    "/api/agent-quote.php": {
      "post": {
        "operationId": "requestCleaningQuote",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "https://cleaninghive.ca/api/booking-fields.json"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Received; status_token and status_url are private",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "403": {
            "description": "Origin refused"
          },
          "409": {
            "description": "Idempotency conflict"
          },
          "413": {
            "description": "Body too large; limit 16384 bytes"
          },
          "415": {
            "description": "JSON required"
          },
          "429": {
            "description": "Rate limited"
          },
          "503": {
            "description": "Endpoint unavailable"
          }
        }
      },
      "get": {
        "operationId": "getQuoteStatus",
        "parameters": [
          {
            "name": "request_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^chh_[0-9a-f]{12}$"
            }
          },
          {
            "name": "status_token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{32}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status without client data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          },
          "404": {
            "description": "Unknown request or incorrect token"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Receipt": {
        "type": "object",
        "required": [
          "request_id",
          "status",
          "status_token",
          "status_url"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "status": {
            "const": "received"
          },
          "status_token": {
            "type": "string"
          },
          "status_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Status": {
        "type": "object",
        "required": [
          "request_id",
          "status",
          "updated_at"
        ],
        "properties": {
          "request_id": {
            "type": "string"
          },
          "status": {
            "enum": [
              "received",
              "processing",
              "quote_sent",
              "team_review",
              "declined"
            ]
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "message": {
            "type": "string"
          },
          "quote_url": {
            "type": "string",
            "format": "uri"
          },
          "price": {
            "type": "object",
            "properties": {
              "currency": {
                "const": "CAD"
              },
              "total_before_tax": {
                "type": "number"
              },
              "total_first_cleaning": {
                "type": "number"
              },
              "sales_tax": {
                "type": "number"
              },
              "total_next_cleaning": {
                "type": "number"
              }
            }
          }
        }
      }
    }
  }
}
