{
  "openapi": "3.1.0",
  "info": {
    "title": "Rifframe API",
    "version": "1.2.0",
    "description": "Public API for Rifframe's catalog of 270+ production-ready website sections. All sections share one semantic token contract — neutral by default, restyled to any brand by overriding a dozen CSS variables.",
    "contact": {
      "name": "Rifframe",
      "url": "https://rifframe.app"
    },
    "license": {
      "name": "Proprietary"
    }
  },
  "servers": [
    {
      "url": "https://rifframe.app",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/v1/sections": {
      "get": {
        "operationId": "listSections",
        "summary": "List or search sections",
        "description": "Search the catalog by free-text query (English) and/or type filter. Without query or type, returns a curated featured set (one section per type). Use `?all=1` for a complete dump.",
        "tags": ["Sections"],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Free-text search query in English (matches id, title, tags, description).",
            "schema": { "type": "string" }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by section type.",
            "schema": {
              "type": "string",
              "enum": [
                "announcement-bar", "nav", "hero", "logos", "features",
                "how-it-works", "stats", "testimonials", "comparison",
                "integrations", "product-grid", "faq", "pricing", "code",
                "team", "contact", "gallery", "video", "manifesto",
                "use-cases", "app-download", "security", "changelog",
                "blog-preview", "press", "careers", "results", "cta",
                "lead-magnet", "footer", "app-shell", "widget", "dashboard"
              ]
            }
          },
          {
            "name": "all",
            "in": "query",
            "description": "Set to `1` or `true` to dump the entire catalog instead of the featured set.",
            "schema": { "type": "string", "enum": ["1", "true"] }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Maximum number of results to return (1-250).",
            "schema": { "type": "integer", "minimum": 1, "maximum": 250 }
          }
        ],
        "responses": {
          "200": {
            "description": "Section list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["count", "sections"],
                  "properties": {
                    "count": {
                      "type": "integer",
                      "description": "Number of sections returned."
                    },
                    "featured": {
                      "type": "boolean",
                      "description": "Present and true when the response is the curated featured set."
                    },
                    "types": {
                      "type": "array",
                      "items": { "type": "string" },
                      "description": "All available section types (only present in featured response)."
                    },
                    "note": {
                      "type": "string",
                      "description": "Usage guidance (only present in featured response)."
                    },
                    "sections": {
                      "type": "array",
                      "items": { "$ref": "#/components/schemas/SectionSummary" }
                    }
                  }
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/v1/sections/{type}/{style}/{name}": {
      "get": {
        "operationId": "getSection",
        "summary": "Get a section as HTML",
        "description": "Fetch one section by its three-part id as Tailwind v4 HTML markup. Neutral by design — colors come from the token contract (see `/api/v1/tokens`).",
        "tags": ["Sections"],
        "parameters": [
          {
            "name": "type",
            "in": "path",
            "required": true,
            "description": "Section type (e.g. `hero`, `pricing`).",
            "schema": { "type": "string" }
          },
          {
            "name": "style",
            "in": "path",
            "required": true,
            "description": "Section style variant (e.g. `split`, `centered`).",
            "schema": { "type": "string" }
          },
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "Section name (e.g. `with-stats`, `default`).",
            "schema": { "type": "string" }
          },
          {
            "name": "surface",
            "in": "query",
            "description": "Background role for page rhythm.",
            "schema": {
              "type": "string",
              "enum": ["light", "muted", "dark"],
              "default": "light"
            }
          },
          {
            "name": "format",
            "in": "query",
            "description": "`json` returns metadata + HTML snippet; `document` returns a full standalone HTML page.",
            "schema": {
              "type": "string",
              "enum": ["json", "document"],
              "default": "json"
            }
          },
          {
            "name": "anchors",
            "in": "query",
            "description": "Keep `data-slot`/`data-aspect` attributes in HTML for deterministic slot filling.",
            "schema": { "type": "boolean", "default": false }
          },
          {
            "name": "items",
            "in": "query",
            "description": "Render with N items in the main repeatable group (1-12). Only works when the main group is scalable.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 12 }
          }
        ],
        "responses": {
          "200": {
            "description": "Section detail (format=json)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SectionDetail" }
              },
              "text/html": {
                "schema": {
                  "type": "string",
                  "description": "Full standalone HTML document (format=document)."
                }
              }
            }
          },
          "400": {
            "description": "Invalid `items` value or section does not support scaling.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "404": {
            "description": "Unknown section id.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/v1/tokens": {
      "get": {
        "operationId": "getTokens",
        "summary": "Get the CSS token contract",
        "description": "Returns the CSS variable block consumed by every Rifframe section. Paste it into your Tailwind v4 CSS entry file and override the values with your brand colors.",
        "tags": ["Tokens"],
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "description": "`json` returns an object with `css` and `usage`; `css` returns raw CSS text.",
            "schema": {
              "type": "string",
              "enum": ["json", "css"],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Token contract",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["css", "usage"],
                  "properties": {
                    "css": {
                      "type": "string",
                      "description": "CSS block with @theme variables and surface role classes."
                    },
                    "usage": {
                      "type": "string",
                      "description": "Instructions for integrating the token contract."
                    }
                  }
                }
              },
              "text/css": {
                "schema": {
                  "type": "string",
                  "description": "Raw CSS token block (format=css)."
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SectionSummary": {
        "type": "object",
        "required": ["id", "type", "title", "description", "tags", "elements", "density", "preview", "thumbnail"],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique section id (e.g. `hero/split/with-stats`)."
          },
          "type": {
            "type": "string",
            "description": "Section type (e.g. `hero`, `pricing`, `faq`)."
          },
          "title": {
            "type": "string",
            "description": "Human-readable title."
          },
          "description": {
            "type": "string",
            "description": "What the section looks like and when to use it."
          },
          "tags": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Searchable tags."
          },
          "elements": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Semantic elements present (e.g. `heading`, `image`, `button`)."
          },
          "density": {
            "type": "string",
            "enum": ["compact", "default", "dense"],
            "description": "Content density."
          },
          "preview": {
            "type": "string",
            "format": "uri",
            "description": "URL to a live browser preview of the section."
          },
          "thumbnail": {
            "type": "string",
            "format": "uri",
            "description": "URL to a JPEG thumbnail."
          },
          "scalable": {
            "type": "boolean",
            "description": "When true, the section supports `?items=N` for parametric rendering."
          },
          "span": {
            "type": "integer",
            "enum": [3, 4, 6, 12],
            "description": "Recommended width on a 12-column grid (widget sections only)."
          },
          "composedOf": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Section ids composing this preset (dashboard presets only)."
          },
          "note": {
            "type": "string",
            "description": "Composition guidance (dashboard/widget sections)."
          }
        }
      },
      "SectionDetail": {
        "type": "object",
        "required": ["id", "type", "title", "description", "tags", "elements", "density", "preview", "thumbnail", "slots", "groups", "surface", "anchors", "html", "usage"],
        "properties": {
          "id": { "type": "string" },
          "type": { "type": "string" },
          "title": { "type": "string" },
          "description": { "type": "string" },
          "tags": {
            "type": "array",
            "items": { "type": "string" }
          },
          "elements": {
            "type": "array",
            "items": { "type": "string" }
          },
          "density": {
            "type": "string",
            "enum": ["compact", "default", "dense"]
          },
          "preview": {
            "type": "string",
            "format": "uri"
          },
          "thumbnail": {
            "type": "string",
            "format": "uri"
          },
          "span": {
            "type": "integer",
            "enum": [3, 4, 6, 12]
          },
          "composedOf": {
            "type": "array",
            "items": { "type": "string" }
          },
          "note": { "type": "string" },
          "slots": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/SlotSpec" },
            "description": "Typed slot specifications for content filling."
          },
          "groups": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/GroupSpec" },
            "description": "Repeatable unit specifications."
          },
          "surface": {
            "type": "string",
            "enum": ["light", "muted", "dark"]
          },
          "anchors": {
            "type": "boolean"
          },
          "items": {
            "type": "integer",
            "description": "Number of items rendered (present when `?items=N` was requested)."
          },
          "html": {
            "type": "string",
            "description": "Tailwind v4 HTML markup of the section."
          },
          "usage": {
            "type": "string",
            "description": "Detailed integration instructions."
          }
        }
      },
      "SlotSpec": {
        "type": "object",
        "required": ["name", "kind"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Slot name (e.g. `heading`, `cta-primary`, `feature-1-title`)."
          },
          "kind": {
            "type": "string",
            "enum": ["text", "image"],
            "description": "`text` for editable copy, `image` for image placeholders."
          },
          "sample": {
            "type": "string",
            "description": "Current sample text (kind: text only)."
          },
          "hint": {
            "type": "string",
            "description": "Writing guidance: length, tone, format (kind: text only)."
          },
          "aspect": {
            "type": "string",
            "description": "Aspect ratio of the placeholder (kind: image only), e.g. `4/3`, `square`, `16/9`."
          }
        }
      },
      "GroupSpec": {
        "type": "object",
        "required": ["name", "unit", "repeatable", "count", "items"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Group name (e.g. `features`, `plans`, `questions`)."
          },
          "unit": {
            "type": "string",
            "enum": ["container", "slot"],
            "description": "`container` = cloneable wrapper element; `slot` = the slot element itself is the unit."
          },
          "repeatable": {
            "type": "boolean",
            "description": "Whether the group has multiple occurrences that can be cloned/removed."
          },
          "count": {
            "type": "integer",
            "description": "Number of occurrences as rendered."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "array",
              "items": { "type": "string" }
            },
            "description": "Slot names per occurrence. The naming pattern guides renumbering when cloning."
          },
          "scalable": {
            "type": "boolean",
            "description": "When true, use `?items=N` to get server-rendered markup with N items."
          },
          "min": {
            "type": "integer",
            "description": "Minimum items for `?items=N` (present when scalable)."
          },
          "max": {
            "type": "integer",
            "description": "Maximum items for `?items=N` (present when scalable)."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message."
          }
        }
      }
    },
    "responses": {
      "RateLimited": {
        "description": "Rate limit exceeded (300 requests/minute per IP).",
        "headers": {
          "X-RateLimit-Limit": {
            "schema": { "type": "integer" },
            "description": "Maximum requests per window."
          },
          "X-RateLimit-Remaining": {
            "schema": { "type": "integer" },
            "description": "Remaining requests in current window."
          },
          "Retry-After": {
            "schema": { "type": "integer" },
            "description": "Seconds until the rate limit resets."
          }
        },
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Sections",
      "description": "Browse and fetch production-ready website sections."
    },
    {
      "name": "Tokens",
      "description": "CSS token contract for consistent theming across sections."
    }
  ]
}
