{
  "openapi": "3.1.0",
  "info": {
    "title": "Brand Studio API",
    "version": "1.0.0",
    "description": "Logos, brand analysis, icon libraries, patterns and brand books. Long operations return a job; poll GET /api/projects/{id}/jobs/{jobId} (or stream /events). MCP: https://icons.customarena.com/mcp"
  },
  "servers": [{ "url": "https://icons.customarena.com" }],
  "security": [{ "bearer": [] }],
  "components": {
    "securitySchemes": { "bearer": { "type": "http", "scheme": "bearer", "description": "Personal API key (bks_…) from the web app, API & MCP." } },
    "parameters": {
      "id": { "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "description": "Project id" },
      "jobId": { "name": "jobId", "in": "path", "required": true, "schema": { "type": "string" } }
    },
    "schemas": {
      "JobStarted": { "type": "object", "properties": { "jobId": { "type": "string" }, "job": { "$ref": "#/components/schemas/Job" } } },
      "Job": {
        "type": "object",
        "properties": {
          "id": { "type": "string" },
          "kind": { "type": "string", "enum": ["preview", "library", "logo", "patterns", "brandbook", "pipeline"] },
          "status": { "type": "string", "enum": ["queued", "running", "done", "failed", "cancelled", "interrupted"] },
          "progress": { "type": "object" },
          "counts": { "type": "object" },
          "result": { "type": "object" },
          "error": { "type": ["string", "null"] }
        }
      },
      "LogoBrief": {
        "type": "object", "required": ["name"],
        "properties": {
          "name": { "type": "string" }, "description": { "type": "string" }, "industry": { "type": "string" },
          "audience": { "type": "string" }, "values": { "type": "string" }, "style": { "type": "string" },
          "colors": { "type": "string" }, "avoid": { "type": "string" },
          "type": { "type": "string", "enum": ["any", "symbol", "wordmark", "combination", "emblem", "monogram"] },
          "count": { "type": "integer", "minimum": 1, "maximum": 6 }
        }
      },
      "PatternItem": {
        "type": "object", "required": ["type"],
        "properties": {
          "type": { "type": "string", "enum": ["seamless", "border", "corner", "divider", "sticker", "banner", "background"] },
          "theme": { "type": "string" }, "note": { "type": "string" }
        }
      }
    }
  },
  "paths": {
    "/api/projects": {
      "get": { "summary": "List projects", "responses": { "200": { "description": "Projects" } } },
      "post": { "summary": "Create a project", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "name": { "type": "string" } } } } } }, "responses": { "200": { "description": "The project" } } }
    },
    "/api/projects/{id}": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "get": { "summary": "Project with assets, logo, spec, icons, patterns, brand book and jobs", "responses": { "200": { "description": "Project" } } },
      "patch": { "summary": "Update name, brief, AI settings", "responses": { "200": { "description": "Project" } } },
      "delete": { "summary": "Delete (moved to trash)", "responses": { "200": { "description": "OK" } } }
    },
    "/api/projects/{id}/assets": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": {
        "summary": "Upload brand assets (multipart)",
        "requestBody": { "content": { "multipart/form-data": { "schema": { "type": "object", "properties": { "kind": { "type": "string", "enum": ["logo", "guide", "reference", "bad"] }, "files": { "type": "array", "items": { "type": "string", "format": "binary" } } } } } } },
        "responses": { "200": { "description": "Project plus skipped[]" } }
      }
    },
    "/api/projects/{id}/logo/concepts": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Generate logo concepts (job)", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "brief": { "$ref": "#/components/schemas/LogoBrief" } } } } } }, "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } } }
    },
    "/api/projects/{id}/logo/choose": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Make a concept the logo", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": ["jobId", "concept"], "properties": { "jobId": { "type": "string" }, "concept": { "type": "integer" } } } } } }, "responses": { "200": { "description": "Project" } } }
    },
    "/api/projects/{id}/analyze": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Analyse the brand into a design specification (synchronous, 10-60 s)", "responses": { "200": { "description": "spec, context, project" } } }
    },
    "/api/projects/{id}/spec": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "put": { "summary": "Replace the design specification", "responses": { "200": { "description": "spec" } } }
    },
    "/api/projects/{id}/preview": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "9-icon style preview (job)", "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } } }
    },
    "/api/projects/{id}/approve": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Approve a preview as style anchor", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "jobId": { "type": "string" } } } } } }, "responses": { "200": { "description": "approval" } } }
    },
    "/api/projects/{id}/generate": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": {
        "summary": "Generate icons (job)",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "required": ["iconList"], "properties": { "iconList": { "type": "string", "description": "One icon per line; 'Label | hint'" }, "mode": { "type": "string", "enum": ["batch", "single"] } } } } } },
        "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } }
      }
    },
    "/api/projects/{id}/patterns": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Generate patterns (job)", "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": { "items": { "type": "array", "items": { "$ref": "#/components/schemas/PatternItem" } } } } } } }, "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } } }
    },
    "/api/projects/{id}/brandbook": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": { "summary": "Write the brand book + design tokens (job)", "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } } }
    },
    "/api/projects/{id}/pipeline": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "post": {
        "summary": "Autopilot: any subset of logo, brand, icons, patterns, brandbook (job)",
        "requestBody": { "content": { "application/json": { "schema": { "type": "object", "properties": {
          "stages": { "type": "array", "items": { "type": "string", "enum": ["logo", "brand", "icons", "patterns", "brandbook"] } },
          "logo": { "$ref": "#/components/schemas/LogoBrief" },
          "iconList": { "type": "string" },
          "patterns": { "type": "array", "items": { "$ref": "#/components/schemas/PatternItem" } }
        } } } } },
        "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/JobStarted" } } } } }
      }
    },
    "/api/projects/{id}/jobs/{jobId}": {
      "parameters": [{ "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/jobId" }],
      "get": { "summary": "Job state", "responses": { "200": { "description": "Job", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Job" } } } } } }
    },
    "/api/projects/{id}/jobs/{jobId}/events": {
      "parameters": [{ "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/jobId" }],
      "get": { "summary": "Live job events (Server-Sent Events)", "responses": { "200": { "description": "text/event-stream" } } }
    },
    "/api/projects/{id}/jobs/{jobId}/cancel": {
      "parameters": [{ "$ref": "#/components/parameters/id" }, { "$ref": "#/components/parameters/jobId" }],
      "post": { "summary": "Stop a job now", "responses": { "200": { "description": "OK" } } }
    },
    "/api/projects/{id}/kit.zip": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "get": { "summary": "Whole brand kit: logo, brand book, tokens, icons, patterns", "responses": { "200": { "description": "application/zip" } } }
    },
    "/api/projects/{id}/library.zip": {
      "parameters": [{ "$ref": "#/components/parameters/id" }],
      "get": { "summary": "Icon library only", "responses": { "200": { "description": "application/zip" } } }
    }
  }
}
