{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentQuoteReady Checkout API",
    "version": "1.0.0",
    "description": "Creates a secure Stripe Checkout URL for the fixed-price Agent Quote-Ready Sprint. This endpoint never receives card data. A human must complete payment on Stripe.",
    "contact": {
      "name": "AgentQuoteReady",
      "email": "contact@agentquoteready.com",
      "url": "https://agentquoteready.com/"
    },
    "termsOfService": "https://agentquoteready.com/terms/"
  },
  "servers": [
    { "url": "https://agentquoteready.com" }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getCheckoutHealth",
        "summary": "Check checkout service availability",
        "responses": {
          "200": {
            "description": "Checkout bridge is available",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["ok", "service"],
                  "properties": {
                    "ok": { "type": "boolean", "const": true },
                    "service": { "type": "string" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "operationId": "createAgentQuoteReadyCheckout",
        "summary": "Create a €990 one-time Stripe Checkout URL",
        "description": "For professional buyers only. The caller supplies order identity and confirms the fixed-scope terms. The response URL must be opened for a human to complete card payment on Stripe.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CheckoutRequest" },
              "examples": {
                "professionalOrder": {
                  "value": {
                    "company": "Acme Supply Ltd",
                    "website": "https://example.com",
                    "contact": "Ada Lovelace",
                    "email": "ada@example.com",
                    "professionalBuyer": true,
                    "acceptedTerms": true,
                    "source": "ai-agent"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Secure Stripe Checkout URL created; no payment has yet been taken",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CheckoutResponse" }
              }
            }
          },
          "422": {
            "description": "Missing or invalid order information",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded"
          },
          "502": {
            "description": "Stripe Checkout could not be created; no payment was taken"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CheckoutRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": ["company", "website", "contact", "email", "professionalBuyer", "acceptedTerms"],
        "properties": {
          "company": { "type": "string", "minLength": 2, "maxLength": 120 },
          "website": { "type": "string", "format": "uri", "maxLength": 240 },
          "contact": { "type": "string", "minLength": 2, "maxLength": 120 },
          "email": { "type": "string", "format": "email", "maxLength": 160 },
          "professionalBuyer": { "type": "boolean", "const": true },
          "acceptedTerms": { "type": "boolean", "const": true, "description": "Confirms acceptance of https://agentquoteready.com/terms/ version 2026-08-24" },
          "source": { "type": "string", "maxLength": 120 }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "required": ["checkoutUrl", "orderReference"],
        "properties": {
          "checkoutUrl": { "type": "string", "format": "uri", "description": "Stripe-hosted payment URL" },
          "orderReference": { "type": "string", "format": "uuid" }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": { "error": { "type": "string" } }
      }
    }
  }
}
