{
  "openapi": "3.1.0",
  "info": {
    "title": "TokRepo API",
    "version": "1.0.0",
    "description": "API for discovering and publishing reusable AI experiences, workflows, prompts, and skills."
  },
  "servers": [
    {
      "url": "https://tokrepo.com"
    }
  ],
  "paths": {
    "/mcp": {
      "get": {
        "summary": "Discover TokRepo hosted MCP endpoint",
        "responses": {
          "200": {
            "description": "Read-only hosted MCP endpoint metadata"
          }
        }
      },
      "post": {
        "summary": "TokRepo hosted MCP JSON-RPC endpoint",
        "description": "Read-only MCP tools/list and tools/call for tokrepo_discover, tokrepo_search, tokrepo_detail, tokrepo_verify, and tokrepo_install_plan.",
        "responses": {
          "200": {
            "description": "JSON-RPC response"
          }
        }
      }
    },
    "/api/v1/tokenboard/workflows/list": {
      "get": {
        "summary": "List workflows",
        "parameters": [
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } },
          { "name": "page_size", "in": "query", "schema": { "type": "integer", "default": 12 } },
          { "name": "category", "in": "query", "schema": { "type": "string" } },
          { "name": "author_uuid", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Workflow list"
          }
        }
      }
    },
    "/api/v1/tokenboard/workflows/detail": {
      "get": {
        "summary": "Get workflow detail",
        "parameters": [
          { "name": "uuid", "in": "query", "schema": { "type": "string" } },
          { "name": "id", "in": "query", "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": {
            "description": "Workflow detail response"
          }
        }
      }
    },
    "/install-contract/{id}.json": {
      "get": {
        "summary": "Get workflow install contract",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Machine-readable install contract for an installable asset"
          }
        }
      }
    },
    "/api/v1/tokenboard/agent/events": {
      "post": {
        "summary": "Record anonymous aggregate agent funnel event",
        "description": "Records event type, source, version, target, result, dry-run state, and candidate count. Does not accept task text, file contents, tokens, or private asset data.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "event": { "type": "string", "enum": ["init_agent", "agent_check", "agent_handoff", "handoff_plan", "mcp_discover", "mcp_search", "mcp_detail", "verify_asset", "audit_asset", "install_plan", "install_dry_run", "install_apply", "rollback_plan", "push"] },
                  "source": { "type": "string", "enum": ["cli", "mcp", "hosted_mcp", "web", "agent"] },
                  "version": { "type": "string" },
                  "target": { "type": "string" },
                  "kind": { "type": "string" },
                  "policy": { "type": "string" },
                  "result": { "type": "string" },
                  "dry_run": { "type": "boolean" },
                  "candidate_count": { "type": "integer" }
                },
                "required": ["event"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event accepted"
          }
        }
      }
    },
    "/api/v1/tokenboard/agent/funnel": {
      "get": {
        "summary": "Read anonymous aggregate agent funnel counters",
        "parameters": [
          { "name": "days", "in": "query", "schema": { "type": "integer", "default": 7, "maximum": 30 } },
          { "name": "source", "in": "query", "schema": { "type": "string" } },
          { "name": "target", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Per-day event counters"
          }
        }
      }
    },
    "/api/v1/tokenboard/workflows/create": {
      "post": {
        "summary": "Create workflow asset",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": { "type": "string" },
                  "description": { "type": "string" },
                  "content": { "type": "string" },
                  "model_used": { "type": "string" },
                  "token_estimate": { "type": "integer" },
                  "tags": {
                    "type": "array",
                    "items": { "type": "string" }
                  }
                },
                "required": ["title", "description", "content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created workflow asset"
          }
        }
      }
    }
  }
}
