{
  "openapi": "3.1.0",
  "info": {
    "title": "Code-Anything API",
    "version": "1.0.0",
    "summary": "Polymorphic 5-domain deterministic static SDK compiler, GraphQL client generator, SQL DDL migration differ, Python/JS-TS AST auditor, and OpenAPI-to-MCP compiler with SHA-256 attestations and $0 billing on 422/syntax errors.",
    "description": "Pure Python 3 stdlib static code compilation and AST analysis API covering OpenAPI 3.x to 4-language zero-dep SDKs (openapi_sdk), GraphQL SDL typed clients and validators (graphql_client), SQL DDL breaking-change and rollback-safe migration diffs (sql_migration), Python and JS/TS AST dead-code and cyclomatic complexity audits (ast_audit), and REST OpenAPI to Remote MCP bundles (openapi_mcp). Invalid inputs, syntax errors, and SSRF rejections return HTTP 422 with billed_micros = 0. Hard $2.00 (2,000,000 micro-USD) external spend cap. Zero customer code resale or AI model training guarantee.",
    "contact": {
      "name": "Code-Anything Operations",
      "email": "ops@fastmesh.dev",
      "url": "https://code.fastmesh.dev"
    }
  },
  "servers": [
    {
      "url": "https://code.fastmesh.dev",
      "description": "Public HTTPS Gateway Mount"
    },
    {
      "url": "http://127.0.0.1:9012",
      "description": "Local Runtime Server"
    }
  ],
  "tags": [
    { "name": "Health", "description": "Liveness, 5-domain readiness, and ledger health probes" },
    { "name": "Compile", "description": "Single and concurrent batch 5-domain deterministic code compilation and AST audits" },
    { "name": "Export", "description": "JSON, Markdown, CSV, and SARIF 2.1.0 artifact exports" },
    { "name": "MCP", "description": "Native JSON-RPC 2.0 Model Context Protocol endpoint" },
    { "name": "Billing", "description": "Creem fixed prepaid credit packs ($19/$79/$199), balance queries, and HMAC-SHA256 webhook settlement" },
    { "name": "Discovery", "description": "Try-Now console, OpenAPI 3.1, llms.txt, skill.md, and technical guides" }
  ],
  "paths": {
    "/": {
      "get": {
        "operationId": "getTryNowConsole",
        "tags": ["Discovery"],
        "summary": "Serve the 5-second zero-signup Try-Now web microsite",
        "responses": {
          "200": {
            "description": "Interactive HTML Try-Now microsite",
            "content": {
              "text/html": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "getHealth",
        "tags": ["Health"],
        "summary": "Check Code-Anything service liveness and subsystem readiness",
        "responses": {
          "200": {
            "description": "Service is healthy",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/HealthResponse" }
              }
            }
          }
        }
      }
    },
    "/api/v1/try": {
      "post": {
        "operationId": "tryCompileOrAudit",
        "tags": ["Compile"],
        "summary": "5-second Try-Now sandbox compilation or AST audit",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CompileRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SHA-256 attested CodeArtifactEnvelope",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CodeArtifactEnvelope" }
              }
            }
          },
          "422": {
            "description": "Malformed JSON, syntax error, or SSRF rejection ($0 billed, billed_micros = 0)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error422Response" }
              }
            }
          }
        }
      }
    },
    "/api/v1/compile": {
      "post": {
        "operationId": "compileCode",
        "tags": ["Compile"],
        "summary": "Run deterministic compilation or AST analysis across 5 domains or auto mode",
        "parameters": [
          { "name": "X-Tenant-Id", "in": "header", "required": false, "schema": { "type": "string" } },
          { "name": "X-API-Key", "in": "header", "required": false, "schema": { "type": "string" } },
          { "name": "X-Try-Now", "in": "header", "required": false, "schema": { "type": "string" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CompileRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SHA-256 attested CodeArtifactEnvelope",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CodeArtifactEnvelope" }
              }
            }
          },
          "422": {
            "description": "Malformed JSON, syntax error, or SSRF rejection ($0 billed, billed_micros = 0)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error422Response" }
              }
            }
          }
        }
      }
    },
    "/api/v1/audit": {
      "post": {
        "operationId": "auditCode",
        "tags": ["Compile"],
        "summary": "Canonical alias for /api/v1/compile supporting AST and migration audits",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CompileRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SHA-256 attested CodeArtifactEnvelope",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CodeArtifactEnvelope" }
              }
            }
          },
          "422": {
            "description": "Invalid or syntax-error payload ($0 billed)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error422Response" }
              }
            }
          }
        }
      }
    },
    "/api/v1/batch": {
      "post": {
        "operationId": "batchCompile",
        "tags": ["Compile"],
        "summary": "Run concurrent multi-item compilation/audits bounded by max_budget_micros and $2.00 cap",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["items"],
                "properties": {
                  "items": { "type": "array", "items": { "$ref": "#/components/schemas/CompileRequest" } },
                  "max_budget_micros": { "type": "integer", "maximum": 2000000 },
                  "tenant_id": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Batch execution summary and item envelopes" },
          "422": { "description": "Invalid batch request ($0 billed)" }
        }
      }
    },
    "/api/v1/export": {
      "post": {
        "operationId": "exportArtifactPost",
        "tags": ["Export"],
        "summary": "Export compiled artifact dossier as JSON, Markdown, CSV, or SARIF",
        "responses": {
          "200": { "description": "Formatted export payload" }
        }
      },
      "get": {
        "operationId": "exportArtifactGet",
        "tags": ["Export"],
        "summary": "Export compiled artifact dossier by query params",
        "responses": {
          "200": { "description": "Formatted export payload" }
        }
      }
    },
    "/api/billing/packs": {
      "get": {
        "operationId": "getBillingPacks",
        "tags": ["Billing"],
        "summary": "List Creem $19/$79/$199 non-expiring prepaid credit packs and per-domain tolls",
        "responses": {
          "200": { "description": "Prepaid pack catalog and micro-USD schedule" }
        }
      }
    },
    "/api/billing/balance": {
      "get": {
        "operationId": "getBillingBalance",
        "tags": ["Billing"],
        "summary": "Query tenant prepaid credit balance and external spend cap status",
        "parameters": [
          { "name": "tenant_id", "in": "query", "required": false, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Tenant credit balance snapshot" }
        }
      }
    },
    "/webhooks/creem": {
      "post": {
        "operationId": "receiveCreemWebhook",
        "tags": ["Billing"],
        "summary": "Idempotent Creem HMAC-SHA256 webhook settlement endpoint",
        "parameters": [
          { "name": "creem-signature", "in": "header", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "Webhook processed or deduplicated" },
          "401": { "description": "Invalid HMAC-SHA256 signature" }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpJsonRpc",
        "tags": ["MCP"],
        "summary": "Native JSON-RPC 2.0 MCP endpoint (initialize, tools/list, tools/call)",
        "responses": {
          "200": { "description": "JSON-RPC 2.0 response" }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getLlmsTxt",
        "tags": ["Discovery"],
        "summary": "Agent discovery manifest",
        "responses": { "200": { "description": "Plain text discovery index" } }
      }
    },
    "/skill.md": {
      "get": {
        "operationId": "getSkillMd",
        "tags": ["Discovery"],
        "summary": "Agent-executable skill contract",
        "responses": { "200": { "description": "Markdown skill manual" } }
      }
    },
    "/guides": {
      "get": {
        "operationId": "getGuides",
        "tags": ["Discovery"],
        "summary": "Technical guides index",
        "responses": { "200": { "description": "HTML guides index" } }
      }
    }
  },
  "components": {
    "schemas": {
      "CompileRequest": {
        "type": "object",
        "properties": {
          "domain": {
            "type": "string",
            "enum": ["auto", "openapi_sdk", "graphql_client", "sql_migration", "ast_audit", "openapi_mcp"],
            "default": "auto"
          },
          "content": { "description": "Inline OpenAPI JSON, GraphQL SDL, SQL DDL, or Python/JS-TS source" },
          "spec": { "description": "Parsed OpenAPI 3.x object or string" },
          "url": { "type": "string", "description": "Public HTTPS/HTTP OpenAPI spec URL" },
          "old_sql": { "type": "string", "description": "Baseline SQL DDL for migration diffing" },
          "new_sql": { "type": "string", "description": "Target SQL DDL for migration diffing" },
          "languages": {
            "type": "array",
            "items": { "type": "string", "enum": ["python", "typescript", "go", "rust"] }
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": { "type": "string" },
                "content": { "type": "string" }
              }
            }
          },
          "query": { "type": "string", "description": "Optional GraphQL query to validate" },
          "variables": { "type": "object", "description": "Optional GraphQL input variables" },
          "no_cache": { "type": "boolean", "default": false },
          "tenant_id": { "type": "string" }
        }
      },
      "CodeArtifactEnvelope": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "status_code": { "type": "integer" },
          "dossier_id": { "type": "string" },
          "artifact_id": { "type": "string" },
          "domain": { "type": "string" },
          "detected_format": { "type": "string" },
          "score": { "type": "integer" },
          "grade": { "type": "string" },
          "summary": { "type": "string" },
          "findings_count": { "type": "object" },
          "findings": { "type": "array", "items": { "type": "object" } },
          "artifacts": { "type": "object" },
          "metrics": { "type": "object" },
          "cache": { "type": "object" },
          "billing": { "type": "object" },
          "billed_micros": { "type": "integer" },
          "charged_micros": { "type": "integer" },
          "billed": { "type": "boolean" },
          "sha256_attestation": { "type": "string" },
          "zero_data_resale": { "type": "boolean" },
          "disclaimer": { "type": "string" },
          "generated_at_utc": { "type": "string" }
        }
      },
      "Error422Response": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "enum": [false] },
          "status_code": { "type": "integer", "enum": [422] },
          "error_code": { "type": "string" },
          "error": { "type": "string" },
          "billed_micros": { "type": "integer", "enum": [0] },
          "charged_micros": { "type": "integer", "enum": [0] },
          "billed": { "type": "boolean", "enum": [false] }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "status": { "type": "string" },
          "service": { "type": "string" },
          "version": { "type": "string" },
          "public_host": { "type": "string" },
          "port": { "type": "integer" },
          "domains": { "type": "array", "items": { "type": "string" } },
          "pricing": { "type": "object" },
          "cache_stats": { "type": "object" },
          "ledger_enabled": { "type": "boolean" },
          "mcp_enabled": { "type": "boolean" }
        }
      }
    }
  }
}
