{
 "openapi": "3.1.0",
 "info": {
  "title": "Sovereign Foundry API",
  "version": "2.0.0",
  "description": "Prove it. Build it. Compile it. Browser sessions use `Authorization: Bearer ss_\u2026` plus `X-Device`; agents use an API key `Authorization: Bearer sf_\u2026` (Pro and Studio). Plan limits return HTTP 402. Errors are JSON: {error: {code, message}}. AI work is metered per workspace per UTC day (prove 3, build 3, compile 2, kit 6, teardown 1, chat 1, image 1, voice 1)."
 },
 "servers": [
  {
   "url": "/"
  }
 ],
 "components": {
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Workspace access key (sf_...)"
   }
  }
 },
 "paths": {
  "/api/health": {
   "get": {
    "summary": "Service health and active model",
    "tags": [
     "Meta"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "security": []
   }
  },
  "/api/meta": {
   "get": {
    "summary": "Scoring dimensions, weights, unit costs and MCP tools",
    "tags": [
     "Meta"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "security": []
   }
  },
  "/api/me": {
   "get": {
    "summary": "Workspace info and today's AI usage",
    "tags": [
     "Workspace"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects": {
   "get": {
    "summary": "List projects",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "post": {
    "summary": "Create a project",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "idea"
        ],
        "properties": {
         "idea": {
          "type": "string",
          "maxLength": 2000
         },
         "name": {
          "type": "string",
          "maxLength": 80
         },
         "context": {
          "type": "object",
          "properties": {
           "customer": {
            "type": "string"
           },
           "problem": {
            "type": "string"
           },
           "region": {
            "type": "string"
           },
           "model": {
            "type": "string"
           },
           "kind": {
            "type": "string"
           },
           "edge": {
            "type": "string"
           },
           "stage": {
            "type": "string"
           },
           "budget": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}": {
   "get": {
    "summary": "Project with latest Proof (live-rescored), Build, Compile, teardowns, site and signal",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "patch": {
    "summary": "Update name, idea or context",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "delete": {
    "summary": "Delete project, site and waitlist",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/prove": {
   "post": {
    "summary": "Run Prove (validation)",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "description": "Returns the full project payload.",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/build": {
   "post": {
    "summary": "Run Build (brand, landing page, GTM)",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/compile": {
   "post": {
    "summary": "Run Compile (buildable spec)",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/teardowns": {
   "post": {
    "summary": "Reverse engineer a competitor site",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "url"
        ],
        "properties": {
         "url": {
          "type": "string"
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/chat": {
   "get": {
    "summary": "Cofounder conversation",
    "tags": [
     "Cofounder"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "post": {
    "summary": "Send a message to the cofounder",
    "tags": [
     "Cofounder"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "message"
        ],
        "properties": {
         "message": {
          "type": "string",
          "maxLength": 4000
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "delete": {
    "summary": "Clear the conversation",
    "tags": [
     "Cofounder"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/site": {
   "get": {
    "summary": "Landing page data and live signal",
    "tags": [
     "Launch"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   },
   "patch": {
    "summary": "Edit hero copy or brand, publish or unpublish",
    "tags": [
     "Launch"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "published": {
          "type": "boolean"
         },
         "hero": {
          "type": "object"
         },
         "brand": {
          "type": "object"
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/site/preview": {
   "get": {
    "summary": "Rendered landing page HTML (preview)",
    "tags": [
     "Launch"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/signups.csv": {
   "get": {
    "summary": "Waitlist as CSV",
    "tags": [
     "Launch"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/share": {
   "post": {
    "summary": "Enable or disable a public read-only report",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "enabled": {
          "type": "boolean"
         }
        }
       }
      }
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/export.md": {
   "get": {
    "summary": "Full report as Markdown",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/export.json": {
   "get": {
    "summary": "Full project payload as JSON",
    "tags": [
     "Projects"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Project id"
     }
    ],
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/public/reports/{id}": {
   "get": {
    "summary": "Public read-only report",
    "tags": [
     "Meta"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Share id"
     }
    ],
    "security": []
   }
  },
  "/mcp": {
   "post": {
    "summary": "Model Context Protocol endpoint (JSON-RPC 2.0, Streamable HTTP)",
    "tags": [
     "Agents"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error: {error: {code, message}}"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/plans": {
   "get": {
    "summary": "Plans, prices and founding offer",
    "tags": [
     "Billing"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": []
   }
  },
  "/api/auth/start": {
   "post": {
    "summary": "Email a sign-in code",
    "tags": [
     "Auth"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "email",
         "device"
        ],
        "properties": {
         "email": {
          "type": "string"
         },
         "device": {
          "type": "object",
          "properties": {
           "id": {
            "type": "string"
           },
           "fp": {
            "type": "string"
           }
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/auth/verify": {
   "post": {
    "summary": "Verify the code and receive a device-bound session",
    "tags": [
     "Auth"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "email",
         "code",
         "device"
        ],
        "properties": {
         "email": {
          "type": "string"
         },
         "code": {
          "type": "string"
         },
         "device": {
          "type": "object"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/auth/logout": {
   "post": {
    "summary": "Sign out this device",
    "tags": [
     "Auth"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/api-key": {
   "post": {
    "summary": "Create (rotate) the API/MCP key (Pro, Studio)",
    "tags": [
     "Auth"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/billing/checkout": {
   "post": {
    "summary": "Start Stripe Checkout",
    "tags": [
     "Billing"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "plan": {
          "type": "string",
          "enum": [
           "founder",
           "pro",
           "studio"
          ]
         },
         "interval": {
          "type": "string",
          "enum": [
           "month",
           "year"
          ]
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/billing/portal": {
   "post": {
    "summary": "Open the Stripe customer portal",
    "tags": [
     "Billing"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/kit": {
   "post": {
    "summary": "Generate the Launch Kit content",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  },
  "/api/projects/{id}/media": {
   "post": {
    "summary": "Generate an AI image (FLUX) or voiceover",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "kind": {
          "type": "string",
          "enum": [
           "image",
           "voice"
          ]
         },
         "prompt": {
          "type": "string"
         },
         "use": {
          "type": "string"
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/transcribe": {
   "post": {
    "summary": "Transcribe recorded audio (Whisper)",
    "tags": [
     "Engines"
    ],
    "responses": {
     "200": {
      "description": "OK"
     },
     "4XX": {
      "description": "Error"
     }
    },
    "security": [
     {
      "bearer": []
     }
    ]
   }
  }
 }
}