{
  "openapi": "3.1.0",
  "info": {
    "title": "OnLoja Public API",
    "version": "1.0.0",
    "description": "Public, machine-readable API for discovering OnLoja platform status, plans, store availability and store access. Administrative APIs require authenticated store or platform credentials and are documented separately."
  },
  "servers": [{ "url": "https://onloja.com.br/api", "description": "OnLoja production API" }],
  "paths": {
    "/platform/status": {
      "get": {
        "operationId": "getPlatformStatus",
        "summary": "Get platform availability",
        "description": "Returns the current public maintenance state and public social profile metadata for the OnLoja platform.",
        "responses": {
          "200": {
            "description": "Current platform status.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PlatformStatus" } } }
          },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/plans": {
      "get": {
        "operationId": "listPublicPlans",
        "summary": "List available plans",
        "description": "Lists active OnLoja subscription plans, their prices, features and usage limits.",
        "responses": {
          "200": {
            "description": "Active plans ordered by monthly price.",
            "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Plan" } } } }
          },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/billing/slug-availability": {
      "get": {
        "operationId": "checkStoreSlugAvailability",
        "summary": "Check store slug availability",
        "description": "Checks whether a normalized store slug can be registered. Invalid or reserved slugs return available=false.",
        "parameters": [{ "name": "slug", "in": "query", "required": true, "description": "Lowercase store identifier using letters, digits and internal hyphens.", "schema": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$", "maxLength": 63 }, "example": "minha-loja" }],
        "responses": {
          "200": { "description": "Availability result.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Availability" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/store-access": {
      "post": {
        "operationId": "findPublicStoreAccess",
        "summary": "Find an active store",
        "description": "Resolves an active OnLoja store by name, slug or custom domain so a user or agent can navigate to it.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StoreAccessRequest" } } } },
        "responses": {
          "200": { "description": "Matching active store.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/StoreAccessResult" } } } },
          "400": { "description": "The store query is missing or invalid.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "No active store matched the query.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    }
  },
  "components": {
    "responses": { "ServerError": { "description": "Unexpected server error.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } },
    "schemas": {
      "Availability": { "type": "object", "additionalProperties": false, "required": ["available"], "properties": { "available": { "type": "boolean", "description": "Whether the requested identifier is currently available." } } },
      "Error": { "type": "object", "additionalProperties": true, "required": ["message"], "properties": { "message": { "type": "string", "description": "Human-readable error message." }, "code": { "type": "string", "description": "Stable machine-readable error code when available." } } },
      "PlatformStatus": { "type": "object", "additionalProperties": true, "required": ["maintenanceEnabled"], "properties": { "maintenanceEnabled": { "type": "boolean", "description": "Whether the public platform is in maintenance mode." }, "maintenanceTitle": { "type": "string" }, "maintenanceMessage": { "type": "string" }, "maintenanceUntil": { "type": ["string", "null"], "format": "date-time" }, "socialLinks": { "type": "object", "additionalProperties": { "type": "string", "format": "uri" } }, "hasMasterAccess": { "type": "boolean" } } },
      "Plan": { "type": "object", "additionalProperties": true, "required": ["code", "name", "monthly_price_cents", "active"], "properties": { "code": { "type": "string" }, "name": { "type": "string" }, "description": { "type": "string" }, "monthly_price_cents": { "type": "integer", "minimum": 0 }, "setup_price_cents": { "type": "integer", "minimum": 0 }, "features": { "type": "array", "items": { "type": "string" } }, "resources": { "type": "object", "additionalProperties": true }, "product_limit": { "type": ["integer", "null"], "minimum": 0 }, "active": { "type": "boolean" } } },
      "StoreAccessRequest": { "type": "object", "additionalProperties": false, "required": ["store"], "properties": { "store": { "type": "string", "minLength": 1, "maxLength": 120, "description": "Store name, slug or custom domain." } } },
      "StoreAccessResult": { "type": "object", "additionalProperties": false, "required": ["name", "slug", "customDomain"], "properties": { "name": { "type": "string" }, "slug": { "type": "string" }, "customDomain": { "type": ["string", "null"], "description": "Configured custom hostname, if any." } } }
    }
  }
}
