{
  "openapi": "3.1.0",
  "info": {
    "title": "Sovereign Schema API",
    "version": "2.0.0",
    "description": "Prove it. Build it. Compile it. Browser sessions use `Authorization: Bearer ss_…` plus `X-Device`; agents use an API key `Authorization: Bearer sf_…` (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": "Message the AI operator; it may act on the account and returns the actions taken",
        "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": []
          }
        ]
      }
    },
    "/api/projects/{id}/website": {
      "post": {
        "summary": "Write the complete multi-page website",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/docs": {
      "post": {
        "summary": "Write a custom document on request",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "request": {
                    "type": "string",
                    "maxLength": 1500
                  }
                },
                "required": [
                  "request"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/interview/{step}": {
      "get": {
        "summary": "Personalisation questions for a step",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "step",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "prove",
                "build",
                "kit",
                "website",
                "app"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Save answers for a step",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "step",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answers": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "answers"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm": {
      "get": {
        "summary": "CRM state: stages, contacts, deals, tasks, activities, invoices, stats",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/contacts": {
      "post": {
        "summary": "Create or update a contact",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "company": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/import": {
      "post": {
        "summary": "Import up to 1,000 contacts",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contacts": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                },
                "required": [
                  "contacts"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/deals": {
      "post": {
        "summary": "Create or update a deal (stage moves are logged)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "stage": {
                    "type": "string"
                  },
                  "value": {
                    "type": "number"
                  },
                  "close_date": {
                    "type": "string",
                    "format": "date"
                  },
                  "contact_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/tasks": {
      "post": {
        "summary": "Create, complete or update a task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "due": {
                    "type": "string",
                    "format": "date"
                  },
                  "done": {
                    "type": "boolean"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/notes": {
      "post": {
        "summary": "Log a note, call or email on the timeline",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "note",
                      "call",
                      "email"
                    ]
                  },
                  "contact_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "body"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/invoices": {
      "post": {
        "summary": "Create or update an invoice (paid plans)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string"
                        },
                        "qty": {
                          "type": "number"
                        },
                        "price": {
                          "type": "number"
                        }
                      }
                    }
                  },
                  "tax_pct": {
                    "type": "number"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "due": {
                    "type": "string",
                    "format": "date"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "draft",
                      "sent",
                      "paid",
                      "overdue",
                      "void"
                    ]
                  },
                  "pay_url": {
                    "type": "string"
                  }
                },
                "required": []
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/pipeline": {
      "post": {
        "summary": "Set custom pipeline stages (2-10)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stages": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "stages"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/crm/calendar": {
      "post": {
        "summary": "Create a private calendar feed URL (ICS)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/account/sign-out-others": {
      "post": {
        "summary": "Sign out every other device",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/account": {
      "delete": {
        "summary": "Delete the account permanently",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirm": {
                    "type": "string",
                    "description": "The account email"
                  }
                },
                "required": [
                  "confirm"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/growth": {
      "post": {
        "summary": "Social & Ads Studio: platforms, 30-day calendar, ad campaigns, Google RSA set, scored video ideas",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/webhooks": {
      "get": {
        "summary": "List webhooks, available events and recent deliveries",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Add a signed webhook (secret returned once)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "url",
                  "events"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/webhooks/{hook}": {
      "delete": {
        "summary": "Remove a webhook",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/webhooks/{hook}/test": {
      "post": {
        "summary": "Send a signed ping",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/memory": {
      "put": {
        "summary": "Replace the AI operator memory (up to 30 facts)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "facts": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "facts"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/rehearse": {
      "post": {
        "summary": "Market rehearsal: a simulated panel of 16 invented personas meets the launch over three rounds; report, segments, objections, real-world tests. Simulated, not evidence. 40 credits.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "question": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "seed": {
                    "type": "string",
                    "maxLength": 4000,
                    "description": "News, notes or a competitor's launch."
                  },
                  "scenario": {
                    "type": "string",
                    "maxLength": 300,
                    "description": "A what-if injected mid-run."
                  },
                  "scenario_round": {
                    "type": "integer",
                    "enum": [
                      2,
                      3
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/projects/{id}/rehearsal/ask": {
      "post": {
        "summary": "Ask one persona from the latest rehearsal a question; answered in character, fictional. 1 chat unit.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "persona",
                  "question"
                ],
                "properties": {
                  "persona": {
                    "type": "string",
                    "description": "e.g. P3"
                  },
                  "question": {
                    "type": "string",
                    "maxLength": 600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "persona": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "answer": {
                      "type": "string"
                    },
                    "simulated": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
