{
  "openapi": "3.1.0",
  "info": {
    "title": "Viva Web Services Quote & Purchase API",
    "description": "Tool-calling endpoints that let AI agents (ChatGPT Actions, Claude tool use, Perplexity, and other function-calling agents) request a fixed quote or start checkout for a Viva Web Services AI Knowledge Catalog plan on behalf of a prospective client, without leaving the chat. Viva is a solo operation run out of Japan for a mostly U.S. client base, so quoting is async-first by design — a live call is offered only on request, not required.",
    "version": "1.0.0",
    "contact": {
      "name": "Viva Web Services",
      "email": "info@vivawebservices.com",
      "url": "https://vivawebservices.com"
    }
  },
  "servers": [
    {
      "url": "https://vivawebservices.com/api",
      "description": "Production"
    }
  ],
  "paths": {
    "/request-quote.php": {
      "post": {
        "operationId": "request_quote",
        "summary": "Request a fixed quote for an AI Knowledge Catalog",
        "description": "Submits a lead and requests a fixed quote by email within one business day — no call required. Use this by default when a user wants to contact, get pricing from, or get started with Viva Web Services. If the lead's message asks for a live call, or `plan_interest` is `scale`, the response includes a scheduling link instead of skipping straight to email (Viva's available call hours are evenings JST / mornings U.S. Eastern, to bridge the Japan-U.S. time difference).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/QuoteRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead received; quote to follow by email, or a call link if one was requested.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/QuoteResponse" }
              }
            }
          },
          "400": {
            "description": "Missing or invalid required fields.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/purchase-catalog-setup.php": {
      "post": {
        "operationId": "purchase_catalog_setup",
        "summary": "Start checkout for an AI Knowledge Catalog plan",
        "description": "Initiates checkout for the Starter, Growth, or Scale / Pro plan and returns a hosted checkout URL. Use this when a user has chosen a plan and wants to purchase or sign up.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PurchaseRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout URL returned.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PurchaseResponse" }
              }
            }
          },
          "400": {
            "description": "Missing or invalid plan.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "required": ["name", "email"],
        "properties": {
          "name": { "type": "string", "description": "Full name of the prospect." },
          "email": { "type": "string", "format": "email", "description": "Email address to send the quote to." },
          "phone": { "type": "string", "description": "Optional phone number." },
          "company": { "type": "string", "description": "Optional business or company name." },
          "plan_interest": {
            "type": "string",
            "enum": ["starter", "growth", "scale", "unsure"],
            "description": "Which plan the prospect is interested in, if known. `scale` deals are complex enough that a call link is offered automatically."
          },
          "wants_call": { "type": "boolean", "description": "Set true if the prospect explicitly asked to talk live instead of by email." },
          "message": { "type": "string", "description": "Optional additional context (e.g. the original prospect prompt)." }
        }
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["received"] },
          "wants_call": { "type": "boolean", "description": "Whether a call was offered for this lead." },
          "call_link": { "type": ["string", "null"], "format": "uri", "description": "Scheduling link, present only when wants_call is true." },
          "message": { "type": "string" }
        }
      },
      "PurchaseRequest": {
        "type": "object",
        "required": ["plan"],
        "properties": {
          "plan": { "type": "string", "enum": ["starter", "growth", "scale"] },
          "name": { "type": "string", "description": "Optional name to pre-fill checkout." },
          "email": { "type": "string", "format": "email", "description": "Optional email to pre-fill checkout." }
        }
      },
      "PurchaseResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["redirect"] },
          "checkout_url": { "type": "string", "format": "uri" },
          "plan": { "type": "string" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "status": { "type": "string", "enum": ["error"] },
          "error": { "type": "string" }
        }
      }
    }
  }
}
