{
  "openapi": "3.1.0",
  "info": {
    "title": "Summit Peak Plumbing (Demo) service-request API",
    "version": "2.0.0",
    "summary": "Submit a plumbing service request to Summit Peak Plumbing (Demo). DEMO business: nothing is sent to a business or charged.",
    "description": "Validates and stores a service request for Summit Peak Plumbing (Demo) and returns a request_id and the customer's status_url. Always include \"business\": \"summit-peak\". Deposits are never taken through this API: any deposit is sent to the customer as a separate link that the customer must approve themselves. Submit only with the customer's consent. DEMO business: nothing is sent to a business or charged.",
    "contact": {
      "name": "Atlas AG",
      "url": "https://atlasag.co"
    }
  },
  "servers": [
    {
      "url": "https://demo.atlasag.co",
      "description": "This host"
    },
    {
      "url": "https://trades-request-demo.vercel.app",
      "description": "Canonical host"
    }
  ],
  "externalDocs": {
    "description": "Plain-language summary for AI assistants",
    "url": "https://demo.atlasag.co/llms.txt"
  },
  "paths": {
    "/api/service-request": {
      "get": {
        "operationId": "describeServiceRequestEndpoint",
        "summary": "Describe the endpoint for this business",
        "parameters": [
          {
            "name": "business",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "summit-peak"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Short JSON description, allowed values and an example.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Unknown business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createServiceRequest",
        "summary": "Submit a service request",
        "description": "Submit on the customer's behalf only with their consent. The business confirms by text/email. deposit_required is always false here.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceRequest"
              },
              "example": {
                "business": "summit-peak",
                "name": "Jordan Example",
                "phone": "(555) 555-0123",
                "email": "jordan@example.com",
                "address": "123 Sample St, Sample City",
                "zip": "80000",
                "service": "leak",
                "urgency": "today",
                "description": "Short description of the problem.",
                "preferred_time": "Tomorrow morning"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Request received.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Received"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or field errors.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "options": {
        "operationId": "corsPreflight",
        "summary": "CORS preflight",
        "responses": {
          "204": {
            "description": "CORS headers; any origin may call GET/POST with Content-Type."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ServiceRequest": {
        "type": "object",
        "required": [
          "business",
          "name",
          "phone",
          "address",
          "service",
          "urgency",
          "description"
        ],
        "additionalProperties": true,
        "properties": {
          "business": {
            "type": "string",
            "const": "summit-peak",
            "description": "Which business the request is for."
          },
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 100,
            "description": "Customer's name."
          },
          "phone": {
            "type": "string",
            "description": "10-digit US phone number.",
            "examples": [
              "(555) 555-0123"
            ]
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 200,
            "description": "Optional, for a confirmation email."
          },
          "address": {
            "type": "string",
            "minLength": 5,
            "maxLength": 200,
            "description": "Street address where the work is."
          },
          "zip": {
            "type": "string",
            "pattern": "^\\d{5}(-\\d{4})?$"
          },
          "service": {
            "type": "string",
            "enum": [
              "leak",
              "drain_clog",
              "water_heater",
              "toilet",
              "faucet_fixtures",
              "sewer_line",
              "emergency",
              "estimate",
              "other"
            ],
            "description": "Closest match: leak (Leak), drain_clog (Drain clog), water_heater (Water heater), toilet (Toilet), faucet_fixtures (Faucet & fixtures), sewer_line (Sewer line), emergency (Emergency), estimate (Free estimate), other (Other)."
          },
          "urgency": {
            "type": "string",
            "enum": [
              "emergency",
              "today",
              "this_week",
              "flexible"
            ]
          },
          "description": {
            "type": "string",
            "minLength": 3,
            "maxLength": 2000,
            "description": "What's happening, plus useful details."
          },
          "preferred_time": {
            "type": "string",
            "maxLength": 100,
            "description": "Free text, e.g. \"2026-10-02 morning\". Windows: morning 8–12, afternoon 12–4, evening 4–7. Hours: Mon–Sat, 7am–7pm."
          }
        }
      },
      "Received": {
        "type": "object",
        "required": [
          "status",
          "request_id",
          "status_url",
          "business",
          "next_steps",
          "deposit_required"
        ],
        "properties": {
          "status": {
            "const": "received"
          },
          "request_id": {
            "type": "string",
            "examples": [
              "SPP-4821K"
            ]
          },
          "business": {
            "type": "string",
            "const": "summit-peak"
          },
          "status_url": {
            "type": "string",
            "format": "uri",
            "description": "The customer's private status page for this request. Share it only with the customer."
          },
          "demo": {
            "type": "boolean",
            "description": "true for the demo business."
          },
          "test": {
            "type": "boolean",
            "description": "true for test businesses."
          },
          "summary": {
            "type": "object",
            "properties": {
              "service": {
                "type": "string"
              },
              "urgency": {
                "type": "string"
              },
              "preferred_time": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "next_steps": {
            "type": "string"
          },
          "deposit_required": {
            "type": "boolean",
            "const": false
          }
        }
      },
      "ValidationError": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Error"
          },
          {
            "type": "object",
            "properties": {
              "errors": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                },
                "description": "Field name to error message."
              }
            }
          }
        ]
      },
      "Error": {
        "type": "object",
        "required": [
          "status",
          "error"
        ],
        "properties": {
          "status": {
            "const": "error"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "retry_after_seconds": {
            "type": "integer"
          }
        }
      }
    }
  }
}
