{
  "openapi": "3.1.0",
  "info": {
    "title": "FUSIONHUB REST API",
    "version": "1.0.0",
    "description": "Official machine-readable OpenAPI 3.1.0 REST API specification for FUSIONHUB (https://www.fusionhub.in) - the premier custom website building and software engineering agency.\n\n### API Versioning & Deprecation Policy\n- **Current Version**: `v1` (Base path: `/api/v1/` or unversioned `/api/`).\n- **Stability Guarantee**: Breaking changes will always result in a new major version path (e.g., `/api/v2/`).\n- **Deprecation Schedule**: In accordance with RFC 8594, deprecated endpoints will return `Sunset` and `Deprecation` HTTP response headers at least 6 months prior to retirement.\n- **Rate Limiting**: Compliant with IETF `RateLimit-*` draft standards with RFC 9457 `application/problem+json` error responses.",
    "contact": {
      "name": "FUSIONHUB Engineering Support",
      "url": "https://www.fusionhub.in/contact",
      "email": "support@fusionhub.in"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://www.fusionhub.in/terms"
    }
  },
  "servers": [
    {
      "url": "https://www.fusionhub.in",
      "description": "Production Edge Server"
    }
  ],
  "paths": {
    "/api/v1/services": {
      "get": {
        "summary": "List All Engineering Services & Pricing",
        "description": "Retrieves the full catalog of FUSIONHUB services, including tier deliverables and starting prices.",
        "operationId": "getServicesCatalog",
        "responses": {
          "200": {
            "description": "Services catalog payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServicesCatalogResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      }
    },
    "/api/v1/reviews": {
      "get": {
        "summary": "Fetch Customer Reviews & Ratings",
        "description": "Retrieves verified customer reviews from Xata PostgreSQL, returning real-time average rating and total count.",
        "operationId": "listCustomerReviews",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of reviews to retrieve",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 10,
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful reviews payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReviewsListResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Submit a Customer Review",
        "description": "Submits a client review. If email matches a completed order, automatically awards VERIFIED BUYER badge.",
        "operationId": "createCustomerReview",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SubmitReviewRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Review submitted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SubmitReviewResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request - invalid review data",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      }
    },
    "/api/v1/tickets": {
      "post": {
        "summary": "Create Customer Support Ticket",
        "description": "Opens a new support ticket and dispatches email confirmation via Resend.",
        "operationId": "createSupportTicket",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTicketRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ticket created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateTicketResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid ticket parameters",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Update Support Ticket Status",
        "description": "Updates the status of an existing ticket.",
        "operationId": "updateSupportTicketStatus",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTicketRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ticket status updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateTicketResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid ticket status update",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ProblemDetails": {
        "type": "object",
        "description": "RFC 9457 Problem Details for HTTP APIs",
        "required": ["type", "title", "status", "detail", "code"],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "example": "https://www.fusionhub.in/docs/errors#NOT_FOUND"
          },
          "title": {
            "type": "string",
            "example": "Resource Not Found"
          },
          "status": {
            "type": "integer",
            "example": 404
          },
          "detail": {
            "type": "string",
            "example": "The requested API endpoint does not exist."
          },
          "code": {
            "type": "string",
            "example": "ENDPOINT_NOT_FOUND"
          },
          "resolution": {
            "type": "string",
            "example": "Consult the OpenAPI 3.1.0 specification at https://www.fusionhub.in/openapi.json."
          }
        }
      },
      "ServicesCatalogResponse": {
        "type": "object",
        "required": ["version", "services"],
        "properties": {
          "version": { "type": "string", "example": "1.0.0" },
          "services": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["slug", "name", "startingPriceInr", "startingPriceFormatted"],
              "properties": {
                "slug": { "type": "string", "example": "portfolio" },
                "name": { "type": "string", "example": "Business & Portfolio Websites" },
                "startingPriceInr": { "type": "integer", "example": 1499 },
                "startingPriceFormatted": { "type": "string", "example": "₹1,499" }
              }
            }
          }
        }
      },
      "ReviewsListResponse": {
        "type": "object",
        "required": ["averageRating", "totalReviews", "ratingFormatted", "reviews"],
        "properties": {
          "averageRating": { "type": "number", "example": 4.9 },
          "totalReviews": { "type": "integer", "example": 128 },
          "ratingFormatted": { "type": "string", "example": "4.9/5 Rating" },
          "reviews": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["id", "name", "rating", "content"],
              "properties": {
                "id": { "type": "string", "example": "1" },
                "name": { "type": "string", "example": "Alex Rivera" },
                "rating": { "type": "integer", "example": 5 },
                "title": { "type": "string", "example": "Incredible Speed" },
                "content": { "type": "string", "example": "Delivered with 0.38s LCP." },
                "is_verified_buyer": { "type": "boolean", "example": true },
                "created_at": { "type": "string", "format": "date-time" }
              }
            }
          }
        }
      },
      "SubmitReviewRequest": {
        "type": "object",
        "required": ["content", "rating"],
        "properties": {
          "name": { "type": "string", "example": "Vikram Mehta" },
          "email": { "type": "string", "format": "email", "example": "vikram@example.com" },
          "rating": { "type": "integer", "minimum": 1, "maximum": 5, "example": 5 },
          "title": { "type": "string", "example": "Great Experience" },
          "content": { "type": "string", "example": "Super fast delivery and clean Next.js code." },
          "dateOfExperience": { "type": "string", "format": "date", "example": "2026-08-23" },
          "serviceTag": { "type": "string", "example": "E-Commerce" }
        }
      },
      "SubmitReviewResponse": {
        "type": "object",
        "required": ["success", "isVerifiedBuyer", "message"],
        "properties": {
          "success": { "type": "boolean", "example": true },
          "isVerifiedBuyer": { "type": "boolean", "example": true },
          "message": { "type": "string", "example": "Review published successfully." }
        }
      },
      "CreateTicketRequest": {
        "type": "object",
        "required": ["email", "subject", "description"],
        "properties": {
          "email": { "type": "string", "format": "email", "example": "client@example.com" },
          "subject": { "type": "string", "example": "Custom Domain Configuration" },
          "category": { "type": "string", "example": "Technical" },
          "description": { "type": "string", "example": "Need help connecting custom DNS records." }
        }
      },
      "CreateTicketResponse": {
        "type": "object",
        "required": ["success", "ticketId", "message"],
        "properties": {
          "success": { "type": "boolean", "example": true },
          "ticketId": { "type": "string", "example": "TICK-84920" },
          "message": { "type": "string", "example": "Ticket created. Check your email for tracking." }
        }
      },
      "UpdateTicketRequest": {
        "type": "object",
        "required": ["ticketId", "status"],
        "properties": {
          "ticketId": { "type": "string", "example": "TICK-84920" },
          "status": {
            "type": "string",
            "enum": ["open", "in_progress", "resolved", "closed"],
            "example": "resolved"
          }
        }
      },
      "UpdateTicketResponse": {
        "type": "object",
        "required": ["success", "status"],
        "properties": {
          "success": { "type": "boolean", "example": true },
          "status": { "type": "string", "example": "resolved" }
        }
      }
    }
  }
}
