{"openapi":"3.1.0","info":{"title":"AI Underwriting API","version":"1.0.0","description":"Public API for the AI Underwriting platform. RFC 7807 problem+json error format. Idempotency-Key header required on every mutating request. Rate-limit headers (X-RateLimit-*) on every response. See docs at https://docs.aiunderwriting.net.","contact":{"name":"AI Underwriting","url":"https://aiunderwriting.net","email":"support@aiunderwriting.net"},"license":{"name":"Proprietary"}},"servers":[{"url":"https://api.aiunderwriting.net","description":"Production"},{"url":"https://sandbox.aiunderwriting.net","description":"Sandbox (test data only)"}],"tags":[{"name":"Health"},{"name":"Deals"},{"name":"Engine"},{"name":"Usage"},{"name":"Webhooks"},{"name":"API keys"},{"name":"Reports"},{"name":"Photos"},{"name":"Branding"},{"name":"Billing"},{"name":"AI"},{"name":"Comps"},{"name":"Outcomes"},{"name":"Integrations"},{"name":"Share"},{"name":"User"},{"name":"Security"}],"security":[{"BearerApiKey":[]}],"paths":{"/v1/health":{"get":{"tags":["Health"],"summary":"Service health check","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiHealthResponse"}}}}}}},"/v1/deals":{"post":{"tags":["Deals"],"summary":"Create a deal and run the engine","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealCreateRequest"}}}},"responses":{"201":{"description":"Deal created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealResponse"}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"429":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["Deals"],"summary":"List deals (paginated, filterable)","security":[{"BearerApiKey":[]}],"parameters":[{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":200}},{"name":"status","in":"query","schema":{"type":"string"}},{"name":"propertyType","in":"query","schema":{"type":"string"}},{"name":"q","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealListResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"429":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{id}":{"get":{"tags":["Deals"],"summary":"Fetch a deal","security":[{"BearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealResponse"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"patch":{"tags":["Deals"],"summary":"Partial update + recompute","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealUpdateRequest"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDealResponse"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"delete":{"tags":["Deals"],"summary":"Soft-delete a deal","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Deleted"},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{id}/run":{"post":{"tags":["Engine"],"summary":"Run the engine on stored or override input","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiRunRequest"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiRunResponse"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"429":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{id}/output":{"get":{"tags":["Engine"],"summary":"Fetch latest engine output","security":[{"BearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{id}/output/{runId}":{"get":{"tags":["Engine"],"summary":"Fetch a specific historical run","description":"Currently 501 — pending CTR-D-003 (engine_run history table). Will return DealOutput once the table lands.","security":[{"BearerApiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"runId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"501":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/usage":{"get":{"tags":["Usage"],"summary":"Current period usage and quota","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiUsageResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/webhooks":{"post":{"tags":["Webhooks"],"summary":"Subscribe to event types (Growth+ tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiWebhookSubscribeRequest"}}}},"responses":{"201":{"description":"Subscription created (signing secret returned ONCE)"},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["Webhooks"],"summary":"List subscriptions (Growth+ tier)","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK"},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/webhooks/{id}":{"delete":{"tags":["Webhooks"],"summary":"Unsubscribe (soft delete)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Unsubscribed"},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/api-keys":{"post":{"tags":["API keys"],"summary":"Issue an API key (live keys require Pro+API tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"201":{"description":"Key created (rawKey returned ONCE)"},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["API keys"],"summary":"List API keys for caller organization","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK"}}}},"/v1/api-keys/{id}":{"delete":{"tags":["API keys"],"summary":"Revoke an API key (soft)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Revoked"},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/generate":{"post":{"tags":["Reports"],"summary":"Generate a PDF report for a deal","description":"Builds the ReportPackage from the deal output, renders via the PDF sidecar (ADR-PDF-001), persists to R2, and returns a signed download URL. Returns 501 if PDF_RENDERER_URL/SHARED_SECRET are unset (reports.ts:63-76).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiReportGenerateRequest"}}}},"responses":{"201":{"description":"Report generated; signed download URL returned","content":{"application/json":{"schema":{"type":"object","properties":{"reportId":{"type":"string"},"filename":{"type":"string"},"r2Key":{"type":"string"},"downloadUrl":{"type":"string","format":"uri"},"expiresAt":{"type":"string","format":"date-time"},"engineVersion":{"type":"string"},"reportVersion":{"type":"string"},"profile":{"$ref":"#/components/schemas/ApiReportProfile"}},"required":["reportId","filename","r2Key","downloadUrl","expiresAt","profile"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"500":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"501":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{reportId}/download":{"get":{"tags":["Reports"],"summary":"Public-by-token signed PDF download","description":"Public endpoint validated by HMAC token; used by share links / email recipients (reports.ts:153).","parameters":[{"name":"reportId","in":"path","required":true,"schema":{"type":"string"}},{"name":"token","in":"query","required":true,"schema":{"type":"string"}},{"name":"dealId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"PDF stream","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"410":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/package":{"post":{"tags":["Reports"],"summary":"Build the ReportPackage JSON without rendering a PDF","description":"Used by web preview and AI memo binding inspector (reports.ts:187).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiReportGenerateRequest"}}}},"responses":{"200":{"description":"ReportPackage JSON","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}":{"post":{"tags":["Photos"],"summary":"Upload a photo (multipart or raw)","description":"Accepts image/jpeg|png|webp|heic|heif, max 10 MB (photos.ts:53).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]}},"image/*":{"schema":{"type":"string","format":"binary"}}}},"responses":{"201":{"description":"Photo uploaded","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"r2Key":{"type":"string"},"mimeType":{"type":"string"},"bytes":{"type":"integer"}},"required":["id","dealId","r2Key","mimeType","bytes"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"413":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"415":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["Photos"],"summary":"List photos for a deal","description":"photos.ts:156","security":[{"BearerApiKey":[]}],"parameters":[{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"photos":{"type":"array","items":{"type":"object","additionalProperties":true}}},"required":["photos"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}/{photoId}":{"delete":{"tags":["Photos"],"summary":"Delete a photo","description":"Removes the R2 object and the row (photos.ts:167).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}/{photoId}/cover":{"put":{"tags":["Photos"],"summary":"Mark a photo as the cover photo","description":"photos.ts:113","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"isCover":{"type":"boolean"}},"required":["id","dealId","isCover"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}/{photoId}/order":{"put":{"tags":["Photos"],"summary":"Set display order for a photo","description":"photos.ts:135","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"displayOrder":{"type":"integer","minimum":0,"maximum":9999}},"required":["displayOrder"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"displayOrder":{"type":"integer"}},"required":["id","dealId","displayOrder"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}/{photoId}/url":{"get":{"tags":["Photos"],"summary":"Issue a signed URL for the raw photo","description":"Returns a 1-hour signed URL routed through /v1/photos/raw/... (photos.ts:185).","security":[{"BearerApiKey":[]}],"parameters":[{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"expiresAt":{"type":"string","format":"date-time"}},"required":["url","expiresAt"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/raw/{photoId}/download":{"get":{"tags":["Photos"],"summary":"Public-by-token raw photo fetch","description":"Token-validated raw image stream used by vision API + signed previews (photos.ts:201).","parameters":[{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}},{"name":"token","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Image stream","content":{"image/*":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"410":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/photos/{dealId}/{photoId}/analyze":{"post":{"tags":["Photos"],"summary":"Run vision analysis (Mode 1) on an uploaded photo","description":"Returns OpenRouter vision analysis (photos.ts:230).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"photoId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"photoId":{"type":"string"},"dealId":{"type":"string"},"analysis":{"type":"object","additionalProperties":true},"model":{"type":"string"},"requiresHumanConfirmation":{"type":"boolean"}},"required":["photoId","dealId","analysis","requiresHumanConfirmation"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/parse/rent-roll":{"post":{"tags":["Parse"],"summary":"Parse a rent-roll PDF (Pro+ tier)","description":"Returns RentRollExtraction with per-cell 1-5 confidence dots and source-map references. Client must confirm each cell before staging into a deal draft (DEC-048).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"pageImageUrls":{"type":"array","items":{"type":"string","format":"uri"},"maxItems":50},"r2ObjectKey":{"type":"string"},"dealId":{"type":"string"},"premiumOptIn":{"type":"boolean"}}}},"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"},"dealId":{"type":"string"}}}}}},"responses":{"200":{"description":"Extraction returned. requiresHumanConfirmation = true.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"413":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"415":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"501":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/parse/t12":{"post":{"tags":["Parse"],"summary":"Parse a T-12 operating statement PDF (Pro+ tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"200":{"description":"OK"},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/parse/lease":{"post":{"tags":["Parse"],"summary":"Abstract a lease PDF (Pro+ tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"200":{"description":"OK"},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/parse/om":{"post":{"tags":["Parse"],"summary":"Parse an Offering Memorandum PDF (Pro+ tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"200":{"description":"OK"},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/parse/auto":{"post":{"tags":["Parse"],"summary":"Classify the document, suggest a parser (Pro+ tier)","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"200":{"description":"Classification + suggested route. requiresHumanConfirmation = true.","content":{"application/json":{"schema":{"type":"object","properties":{"classification":{"type":"object","properties":{"type":{"enum":["rent-roll","t12","lease","om","contractor-bid","unknown"]},"confidence":{"type":"integer","minimum":1,"maximum":5},"rationale":{"type":"string"}}},"suggestedRoute":{"type":["string","null"]},"requiresHumanConfirmation":{"const":true}}}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{id}/reconcile":{"post":{"tags":["Parse"],"summary":"Run deterministic cross-document reconciliation","description":"Runs reconcileDocuments() from @aiunderwriting/engine. Returns ReconciliationReport with conflicts, warnings, deltaPercent.","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"rentRoll":{"type":"object","additionalProperties":true},"t12":{"type":"object","additionalProperties":true},"om":{"type":"object","additionalProperties":true},"leases":{"type":"array","items":{"type":"object","additionalProperties":true},"maxItems":50}}}}}},"responses":{"200":{"description":"Reconciliation report.","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/branding":{"get":{"tags":["Branding"],"summary":"Fetch the caller's PDF branding defaults","description":"branding.ts:61","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"put":{"tags":["Branding"],"summary":"Upsert PDF branding defaults","description":"Validates brandColor (#RRGGBB), themePreference enum, and string lengths (branding.ts:73).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"brandColor":{"type":"string","nullable":true,"pattern":"^#[0-9a-fA-F]{6}$"},"companyName":{"type":"string","nullable":true,"maxLength":200},"legalEntityName":{"type":"string","nullable":true,"maxLength":200},"contactName":{"type":"string","nullable":true,"maxLength":200},"contactTitle":{"type":"string","nullable":true,"maxLength":200},"contactPhone":{"type":"string","nullable":true,"maxLength":200},"contactEmail":{"type":"string","nullable":true,"maxLength":200},"themePreference":{"type":"string","nullable":true,"enum":["modern_institutional","warm_premium","bold_contemporary","classic_conservative","minimal_editorial"]},"footerNote":{"type":"string","nullable":true,"maxLength":200}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/branding/logo":{"post":{"tags":["Branding"],"summary":"Upload branding logo (PNG/JPG/WebP/SVG, max 2 MB)","description":"branding.ts:134","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]}},"image/*":{"schema":{"type":"string","format":"binary"}}}},"responses":{"201":{"description":"Logo uploaded","content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string"},"logoR2Key":{"type":"string"},"mimeType":{"type":"string"},"bytes":{"type":"integer"}},"required":["userId","logoR2Key","mimeType","bytes"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"413":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"415":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"delete":{"tags":["Branding"],"summary":"Clear branding logo","description":"Idempotent (returns 204 even when no logo is set) (branding.ts:190).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"204":{"description":"Cleared"},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/billing/checkout":{"post":{"tags":["Billing"],"summary":"Create a Stripe Checkout session for a tier upgrade","description":"Optional withComps attaches the +30% comps add-on; founders coupon auto-applied for the first 25 pro_api signups (billing.ts:49).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"tier":{"type":"string"},"withComps":{"type":"boolean"}},"required":["tier"],"additionalProperties":false}}}},"responses":{"200":{"description":"Checkout session URL","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"sessionId":{"type":"string"},"foundersApplied":{"type":"boolean"},"compsApplied":{"type":"boolean"}},"required":["url","sessionId","foundersApplied","compsApplied"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/billing/founders":{"get":{"tags":["Billing"],"summary":"Founder slot availability (no PII)","description":"Public-ish; returns count-only data for the marketing copy (billing.ts:121).","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}},"/v1/billing/portal":{"post":{"tags":["Billing"],"summary":"Open Stripe Customer Portal for subscription management","description":"billing.ts:128","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"responses":{"200":{"description":"Portal session URL","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/billing/me":{"get":{"tags":["Billing"],"summary":"Caller's subscription summary (tier, caps, period)","description":"billing.ts:148","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"tier":{"type":"string"},"status":{"type":"string"},"dealCap":{"type":"integer"},"apiCallCap":{"type":"integer"},"watermark":{"type":"boolean"},"cancelAtPeriodEnd":{"type":"boolean"},"currentPeriodEnd":{"type":"string","format":"date-time","nullable":true}},"required":["tier","status","dealCap","apiCallCap","watermark"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/billing/webhook":{"post":{"tags":["Billing"],"summary":"Stripe webhook receiver (signature-verified)","description":"Public, signature-verified, mounted before auth middleware. Required raw body for HMAC verification. Idempotent on Stripe event id (billing.ts:171).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"Acknowledged","content":{"application/json":{"schema":{"type":"object","properties":{"received":{"type":"boolean"},"deduplicated":{"type":"boolean"}},"required":["received"]}}}},"400":{"description":"Invalid signature or JSON","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"reason":{"type":"string"}},"required":["error"]}}}}}}},"/v1/reports/{dealId}/memo/generate":{"post":{"tags":["AI"],"summary":"Generate AI memo (two-stage) — Pro+ tier required","description":"ai.ts:91","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"profile":{"$ref":"#/components/schemas/ApiReportProfile"},"skipStage2":{"type":"boolean"},"reportPackage":{"type":"object","additionalProperties":true}},"required":["reportPackage"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/memo/recheck":{"post":{"tags":["AI"],"summary":"Recheck the numbers in a generated memo against the package","description":"ai.ts:135","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reportPackage":{"type":"object","additionalProperties":true},"reportingMemo":{"type":"object","additionalProperties":true},"narrative":{"type":"object","additionalProperties":true}},"required":["reportPackage","reportingMemo"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/memo/findings/{findingId}/action":{"post":{"tags":["AI"],"summary":"Apply a finding action (apply / dismiss / flag / reset)","description":"ai.ts:153","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"findingId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["apply","dismiss","flag_human_review","reset"]},"note":{"type":"string"},"states":{"type":"array","items":{"type":"object","additionalProperties":true}},"actor":{"type":"string"}},"required":["kind"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"states":{"type":"array","items":{"type":"object","additionalProperties":true}}},"required":["states"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/memo/findings/{findingId}/explain":{"post":{"tags":["AI"],"summary":"Build an explain payload for a finding","description":"ai.ts:170","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}},{"name":"findingId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"narrative":{"type":"object","additionalProperties":true},"reportPackage":{"type":"object","properties":{"reportValues":{"type":"object","additionalProperties":true}},"required":["reportValues"]}},"required":["narrative","reportPackage"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/memo/continue-without-ai":{"post":{"tags":["AI"],"summary":"Mark memo as approved without AI narrative","description":"ai.ts:190","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reportPackage":{"type":"object","additionalProperties":true},"actor":{"type":"string"}},"required":["reportPackage"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/reports/{dealId}/memo/findings/init":{"post":{"tags":["AI"],"summary":"Build initial finding state list from a freshly generated narrative","description":"ai.ts:208","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"narrative":{"type":"object","additionalProperties":true}},"required":["narrative"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"states":{"type":"array","items":{"type":"object","additionalProperties":true}}},"required":["states"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{dealId}/bids/normalize":{"post":{"tags":["AI"],"summary":"Normalize a bid PDF (Mode 2 vision) — Pro+ required","description":"ai.ts:221","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"bidText":{"type":"string","minLength":1},"context":{"type":"object","properties":{"propertyType":{"type":"string"},"squareFeet":{"type":"number"},"zip":{"type":"string"}},"additionalProperties":false}},"required":["bidText"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/comps/search":{"post":{"tags":["Comps"],"summary":"Search the comp pool against k-anon + confidence filters — Pro+ required","description":"comps.ts:84","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/comps/contributions":{"post":{"tags":["Comps"],"summary":"Contribute an anonymized comp record to the pool — Pro+ required","description":"orgId is server-derived from the caller (DEFERRED-FIXES D-03); the body must carry only `comp` (comps.ts:143).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"comp":{"type":"object","additionalProperties":true}},"required":["comp"]}}}},"responses":{"201":{"description":"Stored","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"}},"required":["id","orgId"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"402":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/comps/contributions/{orgId}/revoke":{"post":{"tags":["Comps"],"summary":"Revoke comp contributions for an org (caller must be a member)","description":"Cross-tenant attempts collapse to 404 (DEFERRED-FIXES D-03). 30-day delete cron sweeps separately (comps.ts:230).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"orgId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string"},"revokedAt":{"type":"string","format":"date-time"}},"required":["orgId","revokedAt"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/comps/saved-searches":{"post":{"tags":["Comps"],"summary":"Create a saved comp search","description":"organizationId is server-derived from the caller (DEFERRED-FIXES D-03) (comps.ts:269).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"filter":{"type":"object","additionalProperties":true},"alertVia":{"type":"array","items":{"type":"string","enum":["email","slack","webhook"]}}},"required":["name","filter"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"ownerId":{"type":"string"},"organizationId":{"type":"string"}},"required":["id","name","ownerId","organizationId"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["Comps"],"summary":"List the caller's saved comp searches","description":"comps.ts:310","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"savedSearches":{"type":"array","items":{"type":"object","additionalProperties":true}}},"required":["savedSearches"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{dealId}/outcomes":{"post":{"tags":["Outcomes"],"summary":"Capture a 30/60/90 / exit outcome for a deal","description":"Caller must own (or be in the org of) the deal; cross-tenant collapses to 404 (DEFERRED-FIXES D-02) (outcomes.ts:70).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"responses":{"201":{"description":"Captured","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"level":{"type":"string"},"variance":{"type":"object","additionalProperties":true}},"required":["id","dealId","level","variance"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{dealId}/outcomes/dismiss-reminder":{"post":{"tags":["Outcomes"],"summary":"Dismiss a 30/60/90 reminder","description":"outcomes.ts:150","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["day_30","day_60","day_90"]}},"required":["kind"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"dealId":{"type":"string"},"kind":{"type":"string"}},"required":["ok","dealId","kind"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/deals/{dealId}/outcomes/reminders":{"get":{"tags":["Outcomes"],"summary":"List pending outcome reminder jobs for a deal","description":"outcomes.ts:185","security":[{"BearerApiKey":[]}],"parameters":[{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dealId":{"type":"string"},"reminders":{"type":"array","items":{"type":"object","additionalProperties":true}}},"required":["dealId","reminders"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/users/{userId}/outcomes/consent":{"post":{"tags":["Outcomes"],"summary":"Toggle outcome telemetry / reminder consent","description":"userId in path MUST match the authenticated caller (DEFERRED-FIXES D-02); orgId server-derived (outcomes.ts:219).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reminderEmailsAllowed":{"type":"boolean"},"anonymizedOutcomeContribution":{"type":"boolean"},"source":{"type":"string","enum":["settings_toggle","first_capture_prompt","onboarding","api_call"]}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/integrations":{"get":{"tags":["Integrations"],"summary":"List CRM connection status (GHL + HubSpot)","description":"integrations.ts:124","security":[{"BearerApiKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ghl":{"type":"object","additionalProperties":true},"hubspot":{"type":"object","additionalProperties":true}},"required":["ghl","hubspot"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/integrations/{provider}/connect":{"post":{"tags":["Integrations"],"summary":"Begin OAuth flow for a CRM provider; returns an authorize URL","description":"integrations.ts:153","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"provider","in":"path","required":true,"schema":{"type":"string","enum":["ghl","hubspot"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"authorizeUrl":{"type":"string","format":"uri"},"state":{"type":"string"}},"required":["authorizeUrl","state"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/integrations/{provider}/callback":{"get":{"tags":["Integrations"],"summary":"OAuth callback — exchanges code, stores token, redirects to web","description":"integrations.ts:189","parameters":[{"name":"provider","in":"path","required":true,"schema":{"type":"string","enum":["ghl","hubspot"]}},{"name":"code","in":"query","required":true,"schema":{"type":"string"}},{"name":"state","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"302":{"description":"Redirect back to /settings/integrations?connected=…"},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/integrations/{provider}/disconnect":{"post":{"tags":["Integrations"],"summary":"Revoke and soft-delete the CRM token","description":"integrations.ts:236","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"provider","in":"path","required":true,"schema":{"type":"string","enum":["ghl","hubspot"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"alreadyDisconnected":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/share":{"post":{"tags":["Share"],"summary":"Create a share link for a deal","description":"Allocates an immutable report_version snapshot of the current deal output and a share_link bound to it. Raw token returned ONCE (server stores sha256). Optional passcode + recipient allow-list per DEC-038 (share.ts).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiShareLinkCreateRequest"}}}},"responses":{"201":{"description":"Created — raw token returned only here","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiShareLinkCreateResponse"}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"get":{"tags":["Share"],"summary":"List share links owned by the caller's org for a deal","description":"Requires ?dealId= query param (share.ts).","security":[{"BearerApiKey":[]}],"parameters":[{"name":"dealId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiShareLinkListResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/share/{id}":{"delete":{"tags":["Share"],"summary":"Revoke a share link by id","description":"Idempotent. If the link was already revoked, returns 200 with alreadyRevoked: true. Cross-tenant attempts collapse to 404 (share.ts).","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"alreadyRevoked":{"type":"boolean"},"revokedAt":{"type":"string","format":"date-time"}},"required":["ok","alreadyRevoked"]}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/share/by-token/{token}":{"get":{"tags":["Share"],"summary":"PUBLIC — validate a raw token and return the frozen ReportPackage","description":"No auth; the token IS the credential. Optional X-Share-Passcode header (or ?passcode= query) and ?recipient= when configured. Records the view in the share_link.accessLog (share.ts).","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string"}},{"name":"passcode","in":"query","required":false,"schema":{"type":"string"}},{"name":"recipient","in":"query","required":false,"schema":{"type":"string"}},{"name":"X-Share-Passcode","in":"header","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiShareValidateResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"410":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/integrations/{provider}/push/{dealId}":{"post":{"tags":["Integrations"],"summary":"Push a deal to the connected CRM","description":"integrations.ts:269","security":[{"BearerApiKey":[]}],"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"provider","in":"path","required":true,"schema":{"type":"string","enum":["ghl","hubspot"]}},{"name":"dealId","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"trigger":{"type":"string","enum":["manual.push","report.exported","deal.stage_changed","deal.values_updated"]},"payload":{"type":"object","additionalProperties":true},"idempotencyKey":{"type":"string"}},"required":["payload"]}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"dealId":{"type":"string"},"provider":{"type":"string"}},"required":["ok","dealId","provider"]}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"502":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/me":{"get":{"tags":["User"],"summary":"Get current user profile","description":"Returns the authenticated principal's merged user + app_user_profile record. Lazy-creates the profile row on first read for users that pre-date the schema (auth.ts:60).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiUserProfileResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"patch":{"tags":["User"],"summary":"Update current user profile","description":"Partial update. Unknown keys are rejected (422, strict schema). `displayName` propagates to `user.name` so Better-Auth sessions stay in sync. Phase 2 (R5/C migration 0010) accepts company/timezone/preferences; preferences is shallow-merged across the four documented subgroups (aiSettings, exportSettings, notificationPrefs, privacyConsent).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiUserProfileUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiUserProfileResponse"}}}},"400":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"delete":{"tags":["User"],"summary":"Delete current account (GDPR Art. 17 erasure)","description":"Soft-deletes the user and revokes every active session. A scheduled purge cron hard-deletes the user + cascade children 30 days later. Idempotent — calling on an already-deleted account returns the prior deletedAt without re-revoking sessions (auth.ts:736).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiAccountDeleteResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/sessions":{"get":{"tags":["Security"],"summary":"List active sessions","description":"Returns active (non-expired) sessions for the authenticated principal. `isCurrent` is true on the session whose token matches the caller's cookie; API-key authed callers will see false on every row (auth.ts:212).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiSessionListResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}},"delete":{"tags":["Security"],"summary":"Revoke all sessions except current","description":"\"Log out everywhere.\" When called with a session cookie, deletes every active session for the user EXCEPT the caller's current one and returns its id. When called via API key (no cookie), deletes ALL sessions and returns currentSessionId: null (auth.ts:268).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiSessionRevokeAllResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/sessions/{id}":{"delete":{"tags":["Security"],"summary":"Revoke a single session","description":"Revokes the specified session if it belongs to the caller. Returns 404 for both \"does not exist\" and \"belongs to another user\" so existence of other users' sessions does not leak (auth.ts:241).","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Session id (text PK)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiSessionRevokeResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/audit-log":{"get":{"tags":["Security"],"summary":"Get security audit log (last N days)","description":"**Stubbed** until migration 0004 ships `security_audit_event`. Returns an empty array with response header `Aiu-Backed-By: stub` so consumers can detect placeholder data and surface a banner. Once the table lands the same endpoint returns real events without contract changes (auth.ts:317).","parameters":[{"name":"days","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":365,"default":90},"description":"Window in days (1–365). Defaults to 90."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiAuditLogResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"422":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/team":{"get":{"tags":["User"],"summary":"List members of the caller's active organization","description":"Returns members joined to the caller's active organization (read from app_user_profile.organizationId). Returns 404 when the caller has no active organization. Mutating CRUD lives on Better-Auth at /api/auth/organization/* (auth.ts:340).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiTeamListResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/auth/data-export":{"post":{"tags":["User"],"summary":"Export account data (GDPR Art. 20 portability)","description":"Synchronously collects every row owned by the caller (user, profile, deals, reports, audit events, API key metadata) and returns the bundle as a JSON response. Writes an ACCOUNT_DATA_EXPORTED audit event. Async + email + signed-URL path is a planned follow-up if real users hit the response-size ceiling (auth.ts:478).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiDataExportResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}},"/v1/billing/usage":{"get":{"tags":["Billing"],"summary":"Get current-period usage metrics for the settings UI","description":"Per-user usage across 4 metrics: deals, api_calls (both period-scoped + tier-capped), reports (uncapped), team_members (uncapped). Period boundaries match Stripe period when subscribed, otherwise first-of-month UTC (billing.ts:155).","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiBillingUsageResponse"}}}},"401":{"description":"Problem details (RFC 7807)","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}}},"components":{"schemas":{"ProblemDetails":{"type":"object","properties":{"type":{"type":"string","format":"uri"},"title":{"type":"string"},"status":{"type":"integer","minimum":100,"maximum":599},"detail":{"type":"string"},"instance":{"type":"string"},"code":{"type":"string"},"traceId":{"type":"string"},"errors":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"},"code":{"type":"string"}},"required":["path","message"],"additionalProperties":false}}},"required":["type","title","status"],"additionalProperties":false},"PaginationQuery":{"type":"object","properties":{"cursor":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":200,"default":50}},"additionalProperties":false},"ApiDealCreateRequest":{"type":"object","properties":{"propertyType":{"type":"string","enum":["sfr","mfr_2_4","multifamily_5_plus","office","retail","industrial","mixed_use"]},"analysisType":{"type":"string","enum":["residential","commercial","mixed_use"]},"dealName":{"type":"string"},"address":{"type":"object","properties":{"street":{"type":"string"},"city":{"type":"string"},"state":{"type":"string"},"postalCode":{"type":"string"},"country":{"type":"string"}},"additionalProperties":false},"purchasePrice":{"type":"string"},"input":{"type":"object","additionalProperties":{}}},"required":["propertyType","analysisType","purchasePrice"],"additionalProperties":false},"ApiDealRecord":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"},"userId":{"type":"string"},"name":{"type":"string"},"propertyType":{"type":"string"},"analysisType":{"type":"string"},"status":{"type":"string"},"inputHash":{"type":"string"},"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"lastRunAt":{"type":"string","nullable":true},"lastRunId":{"type":"string","nullable":true}},"required":["id","orgId","userId","name","propertyType","analysisType","status","inputHash","engineVersion","schemaVersion","createdAt","updatedAt","lastRunAt","lastRunId"],"additionalProperties":false},"ApiDealResponse":{"type":"object","properties":{"deal":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"},"userId":{"type":"string"},"name":{"type":"string"},"propertyType":{"type":"string"},"analysisType":{"type":"string"},"status":{"type":"string"},"inputHash":{"type":"string"},"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"lastRunAt":{"type":"string","nullable":true},"lastRunId":{"type":"string","nullable":true}},"required":["id","orgId","userId","name","propertyType","analysisType","status","inputHash","engineVersion","schemaVersion","createdAt","updatedAt","lastRunAt","lastRunId"],"additionalProperties":false},"output":{"type":"object","properties":{"meta":{"type":"object","properties":{"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"computedAt":{"type":"string"},"runId":{"type":"string"},"fixtureId":{"type":"string"},"environment":{"type":"string","enum":["test","development","staging","production"]}},"required":["engineVersion","schemaVersion","computedAt","runId"],"additionalProperties":false},"inputEcho":{"type":"object","additionalProperties":{}},"summary":{"type":"object","properties":{"propertyType":{"type":"string","enum":["sfr","mfr_2_4","multifamily_5_plus","office","retail","industrial","mixed_use"]},"analysisType":{"type":"string","enum":["residential","commercial","mixed_use"]},"dealName":{"type":"string"},"address":{"type":"object","additionalProperties":{}},"rentableSF":{"type":"string"},"unitCount":{"type":"string"},"purchasePrice":{"type":"string"},"stabilizedNOI":{"type":"string"},"goingInCapRate":{"type":"string"},"warningCount":{"type":"number"},"criticalWarningCount":{"type":"number"}},"required":["propertyType","analysisType","purchasePrice","stabilizedNOI","goingInCapRate","warningCount","criticalWarningCount"],"additionalProperties":false},"proForma":{"type":"object","properties":{"annual":{"type":"array","items":{"type":"object","properties":{"year":{"type":"number"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"grossPotentialRent":{"type":"string"},"vacancyLoss":{"type":"string"},"effectiveGrossIncome":{"type":"string"},"operatingExpenses":{"type":"string"},"netOperatingIncome":{"type":"string"},"debtService":{"type":"string"},"beforeTaxCashFlow":{"type":"string"},"capitalExpenditures":{"type":"string"},"leasingCosts":{"type":"string"},"terminalValue":{"type":"string"},"netSaleProceeds":{"type":"string"},"totalCashFlow":{"type":"string"},"warnings":{"type":"array","items":{"type":"string"}}},"required":["year","periodStart","periodEnd","grossPotentialRent","vacancyLoss","effectiveGrossIncome","operatingExpenses","netOperatingIncome","totalCashFlow","warnings"],"additionalProperties":false}},"cashFlows":{"type":"object","properties":{"periods":{"type":"array","items":{"type":"object","properties":{"period":{"type":"number"},"label":{"type":"string"},"cashFlow":{"type":"string"},"components":{"type":"object","additionalProperties":{"type":"string"}}},"required":["period","label","cashFlow","components"],"additionalProperties":false}}},"required":["periods"],"additionalProperties":false}},"required":["annual","cashFlows"],"additionalProperties":false},"financing":{"type":"object","properties":{"loanAmount":{"type":"string"},"equityRequired":{"type":"string"},"ltv":{"type":"string"},"interestRate":{"type":"string"},"amortizationYears":{"type":"string"},"termYears":{"type":"string"},"annualDebtService":{"type":"string"},"monthlyDebtService":{"type":"string"},"interestOnlyPeriodMonths":{"type":"string"},"balloonBalance":{"type":"string"},"sourcesAndUses":{"type":"object","properties":{"uses":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string"},"label":{"type":"string"},"amount":{"type":"string"}},"required":["category","label","amount"],"additionalProperties":false}},"sources":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string"},"label":{"type":"string"},"amount":{"type":"string"}},"required":["category","label","amount"],"additionalProperties":false}},"totalUses":{"type":"string"},"totalSources":{"type":"string"},"balanced":{"type":"boolean"},"imbalance":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"},"default":[]}},"required":["uses","sources","totalUses","totalSources","balanced","imbalance"],"additionalProperties":false}},"additionalProperties":false},"returns":{"type":"object","properties":{"noi":{"type":"string"},"capRate":{"type":"string"},"dscr":{"type":"string","nullable":true},"debtYield":{"type":"string","nullable":true},"ltv":{"type":"string","nullable":true},"cashOnCash":{"type":"string","nullable":true},"irr":{"type":"object","properties":{"value":{"type":"string","nullable":true},"status":{"type":"string","enum":["computed","not_computable_no_sign_change","not_computable_solver_failed","computed_low_confidence","ambiguous_multiple_sign_changes"]},"method":{"type":"string","enum":["newton_raphson","brent"]},"iterations":{"type":"number"},"npvResidual":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"}}},"required":["value","status","warningIds"],"additionalProperties":false},"mirr":{"type":"string"},"npvAtTargetReturn":{"type":"string"},"equityMultiple":{"type":"object","properties":{"value":{"type":"string","nullable":true},"status":{"type":"string","enum":["computed","not_computable_zero_equity","not_computable_negative_equity"]},"totalDistributions":{"type":"string"},"totalEquityInvested":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"},"default":[]}},"required":["value","status","totalDistributions","totalEquityInvested"],"additionalProperties":false}},"required":["noi","capRate","dscr","debtYield","ltv","cashOnCash","irr"],"additionalProperties":false},"exit":{"type":"object","properties":{"holdPeriodYears":{"type":"string"},"exitCapRate":{"type":"string"},"terminalNOI":{"type":"string"},"grossTerminalValue":{"type":"string"},"sellingCosts":{"type":"string"},"debtPayoff":{"type":"string"},"netSaleProceeds":{"type":"string"}},"required":["holdPeriodYears","exitCapRate","terminalNOI","grossTerminalValue","sellingCosts","netSaleProceeds"],"additionalProperties":false},"reportRefs":{"type":"object","properties":{"reportablePaths":{"type":"array","items":{"type":"string"}},"keyMetricPaths":{"type":"array","items":{"type":"string"}},"methodologyRefs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"formula":{"type":"string"},"description":{"type":"string"},"inputPaths":{"type":"array","items":{"type":"string"}},"outputPaths":{"type":"array","items":{"type":"string"}},"roundingPolicy":{"type":"string"}},"required":["id","title","formula","description","inputPaths","outputPaths"],"additionalProperties":false}},"assumptionPaths":{"type":"array","items":{"type":"string"}},"warningIds":{"type":"array","items":{"type":"string"}}},"required":["reportablePaths","keyMetricPaths","methodologyRefs","assumptionPaths","warningIds"],"additionalProperties":false},"warnings":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"severity":{"type":"string","enum":["info","warning","critical"]},"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"sourcePath":{"type":"string"},"recommendedAction":{"type":"string"},"reportVisibility":{"type":"string","enum":["internal_only","user_visible","report_visible"]}},"required":["id","severity","code","title","message"],"additionalProperties":false}},"sourceMap":{"type":"object","additionalProperties":{"type":"object","properties":{"formulaName":{"type":"string"},"formula":{"type":"string"},"inputPaths":{"type":"array","items":{"type":"string"}},"methodologyRef":{"type":"string"},"reportLabel":{"type":"string"},"notes":{"type":"string"}},"required":["formulaName","formula","inputPaths"],"additionalProperties":false}}},"required":["meta","inputEcho","summary","proForma","financing","returns","exit","reportRefs","warnings","sourceMap"],"additionalProperties":false,"nullable":true}},"required":["deal","output"],"additionalProperties":false},"ApiDealUpdateRequest":{"type":"object","properties":{"name":{"type":"string"},"status":{"type":"string"},"input":{"type":"object","additionalProperties":{}}},"additionalProperties":false},"ApiDealListQuery":{"type":"object","properties":{"cursor":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":200,"default":50},"status":{"type":"string"},"propertyType":{"type":"string"},"ownerUserId":{"type":"string"},"q":{"type":"string"}},"additionalProperties":false},"ApiDealListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"},"userId":{"type":"string"},"name":{"type":"string"},"propertyType":{"type":"string"},"analysisType":{"type":"string"},"status":{"type":"string"},"inputHash":{"type":"string"},"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"},"lastRunAt":{"type":"string","nullable":true},"lastRunId":{"type":"string","nullable":true}},"required":["id","orgId","userId","name","propertyType","analysisType","status","inputHash","engineVersion","schemaVersion","createdAt","updatedAt","lastRunAt","lastRunId"],"additionalProperties":false}},"nextCursor":{"type":"string","nullable":true},"hasMore":{"type":"boolean"}},"required":["data","nextCursor","hasMore"],"additionalProperties":false},"ApiRunRequest":{"type":"object","properties":{"inputOverrides":{"type":"object","additionalProperties":{}}},"additionalProperties":false},"ApiRunResponse":{"type":"object","properties":{"runId":{"type":"string"},"dealId":{"type":"string"},"output":{"type":"object","properties":{"meta":{"type":"object","properties":{"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"computedAt":{"type":"string"},"runId":{"type":"string"},"fixtureId":{"type":"string"},"environment":{"type":"string","enum":["test","development","staging","production"]}},"required":["engineVersion","schemaVersion","computedAt","runId"],"additionalProperties":false},"inputEcho":{"type":"object","additionalProperties":{}},"summary":{"type":"object","properties":{"propertyType":{"type":"string","enum":["sfr","mfr_2_4","multifamily_5_plus","office","retail","industrial","mixed_use"]},"analysisType":{"type":"string","enum":["residential","commercial","mixed_use"]},"dealName":{"type":"string"},"address":{"type":"object","additionalProperties":{}},"rentableSF":{"type":"string"},"unitCount":{"type":"string"},"purchasePrice":{"type":"string"},"stabilizedNOI":{"type":"string"},"goingInCapRate":{"type":"string"},"warningCount":{"type":"number"},"criticalWarningCount":{"type":"number"}},"required":["propertyType","analysisType","purchasePrice","stabilizedNOI","goingInCapRate","warningCount","criticalWarningCount"],"additionalProperties":false},"proForma":{"type":"object","properties":{"annual":{"type":"array","items":{"type":"object","properties":{"year":{"type":"number"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"grossPotentialRent":{"type":"string"},"vacancyLoss":{"type":"string"},"effectiveGrossIncome":{"type":"string"},"operatingExpenses":{"type":"string"},"netOperatingIncome":{"type":"string"},"debtService":{"type":"string"},"beforeTaxCashFlow":{"type":"string"},"capitalExpenditures":{"type":"string"},"leasingCosts":{"type":"string"},"terminalValue":{"type":"string"},"netSaleProceeds":{"type":"string"},"totalCashFlow":{"type":"string"},"warnings":{"type":"array","items":{"type":"string"}}},"required":["year","periodStart","periodEnd","grossPotentialRent","vacancyLoss","effectiveGrossIncome","operatingExpenses","netOperatingIncome","totalCashFlow","warnings"],"additionalProperties":false}},"cashFlows":{"type":"object","properties":{"periods":{"type":"array","items":{"type":"object","properties":{"period":{"type":"number"},"label":{"type":"string"},"cashFlow":{"type":"string"},"components":{"type":"object","additionalProperties":{"type":"string"}}},"required":["period","label","cashFlow","components"],"additionalProperties":false}}},"required":["periods"],"additionalProperties":false}},"required":["annual","cashFlows"],"additionalProperties":false},"financing":{"type":"object","properties":{"loanAmount":{"type":"string"},"equityRequired":{"type":"string"},"ltv":{"type":"string"},"interestRate":{"type":"string"},"amortizationYears":{"type":"string"},"termYears":{"type":"string"},"annualDebtService":{"type":"string"},"monthlyDebtService":{"type":"string"},"interestOnlyPeriodMonths":{"type":"string"},"balloonBalance":{"type":"string"},"sourcesAndUses":{"type":"object","properties":{"uses":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string"},"label":{"type":"string"},"amount":{"type":"string"}},"required":["category","label","amount"],"additionalProperties":false}},"sources":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string"},"label":{"type":"string"},"amount":{"type":"string"}},"required":["category","label","amount"],"additionalProperties":false}},"totalUses":{"type":"string"},"totalSources":{"type":"string"},"balanced":{"type":"boolean"},"imbalance":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"},"default":[]}},"required":["uses","sources","totalUses","totalSources","balanced","imbalance"],"additionalProperties":false}},"additionalProperties":false},"returns":{"type":"object","properties":{"noi":{"type":"string"},"capRate":{"type":"string"},"dscr":{"type":"string","nullable":true},"debtYield":{"type":"string","nullable":true},"ltv":{"type":"string","nullable":true},"cashOnCash":{"type":"string","nullable":true},"irr":{"type":"object","properties":{"value":{"type":"string","nullable":true},"status":{"type":"string","enum":["computed","not_computable_no_sign_change","not_computable_solver_failed","computed_low_confidence","ambiguous_multiple_sign_changes"]},"method":{"type":"string","enum":["newton_raphson","brent"]},"iterations":{"type":"number"},"npvResidual":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"}}},"required":["value","status","warningIds"],"additionalProperties":false},"mirr":{"type":"string"},"npvAtTargetReturn":{"type":"string"},"equityMultiple":{"type":"object","properties":{"value":{"type":"string","nullable":true},"status":{"type":"string","enum":["computed","not_computable_zero_equity","not_computable_negative_equity"]},"totalDistributions":{"type":"string"},"totalEquityInvested":{"type":"string"},"warningIds":{"type":"array","items":{"type":"string"},"default":[]}},"required":["value","status","totalDistributions","totalEquityInvested"],"additionalProperties":false}},"required":["noi","capRate","dscr","debtYield","ltv","cashOnCash","irr"],"additionalProperties":false},"exit":{"type":"object","properties":{"holdPeriodYears":{"type":"string"},"exitCapRate":{"type":"string"},"terminalNOI":{"type":"string"},"grossTerminalValue":{"type":"string"},"sellingCosts":{"type":"string"},"debtPayoff":{"type":"string"},"netSaleProceeds":{"type":"string"}},"required":["holdPeriodYears","exitCapRate","terminalNOI","grossTerminalValue","sellingCosts","netSaleProceeds"],"additionalProperties":false},"reportRefs":{"type":"object","properties":{"reportablePaths":{"type":"array","items":{"type":"string"}},"keyMetricPaths":{"type":"array","items":{"type":"string"}},"methodologyRefs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"formula":{"type":"string"},"description":{"type":"string"},"inputPaths":{"type":"array","items":{"type":"string"}},"outputPaths":{"type":"array","items":{"type":"string"}},"roundingPolicy":{"type":"string"}},"required":["id","title","formula","description","inputPaths","outputPaths"],"additionalProperties":false}},"assumptionPaths":{"type":"array","items":{"type":"string"}},"warningIds":{"type":"array","items":{"type":"string"}}},"required":["reportablePaths","keyMetricPaths","methodologyRefs","assumptionPaths","warningIds"],"additionalProperties":false},"warnings":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"severity":{"type":"string","enum":["info","warning","critical"]},"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"sourcePath":{"type":"string"},"recommendedAction":{"type":"string"},"reportVisibility":{"type":"string","enum":["internal_only","user_visible","report_visible"]}},"required":["id","severity","code","title","message"],"additionalProperties":false}},"sourceMap":{"type":"object","additionalProperties":{"type":"object","properties":{"formulaName":{"type":"string"},"formula":{"type":"string"},"inputPaths":{"type":"array","items":{"type":"string"}},"methodologyRef":{"type":"string"},"reportLabel":{"type":"string"},"notes":{"type":"string"}},"required":["formulaName","formula","inputPaths"],"additionalProperties":false}}},"required":["meta","inputEcho","summary","proForma","financing","returns","exit","reportRefs","warnings","sourceMap"],"additionalProperties":false}},"required":["runId","dealId","output"],"additionalProperties":false},"ApiReportProfile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"ApiReportGenerateRequest":{"type":"object","properties":{"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"includeAiMemo":{"type":"boolean","default":false},"watermark":{"type":"boolean"}},"required":["profile"],"additionalProperties":false},"ApiReportRecord":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"versionNumber":{"type":"integer","minimum":0},"locked":{"type":"boolean"},"pdfUrl":{"type":"string","format":"uri","nullable":true},"evidencePacketUrl":{"type":"string","format":"uri","nullable":true},"exportedAt":{"type":"string"},"exportedBy":{"type":"string"}},"required":["id","dealId","profile","versionNumber","locked","pdfUrl","evidencePacketUrl","exportedAt","exportedBy"],"additionalProperties":false},"ApiShareLinkCreateRequest":{"type":"object","properties":{"dealId":{"type":"string","minLength":1},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"expiresInDays":{"type":"integer","minimum":1,"maximum":365},"passcode":{"type":"string","minLength":4,"maxLength":128},"recipientEmails":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50}},"required":["dealId"],"additionalProperties":false},"ApiShareLinkCreateResponse":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"reportVersionId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"expiresAt":{"type":"string"},"revokedAt":{"type":"string","nullable":true},"recipientEmails":{"type":"array","items":{"type":"string"},"nullable":true},"hasPasscode":{"type":"boolean"},"viewCount":{"type":"integer","minimum":0},"lastViewedAt":{"type":"string","nullable":true},"createdAt":{"type":"string"},"createdBy":{"type":"string","nullable":true},"token":{"type":"string"},"shareUrl":{"type":"string","format":"uri"}},"required":["id","dealId","reportVersionId","profile","expiresAt","revokedAt","recipientEmails","hasPasscode","viewCount","lastViewedAt","createdAt","createdBy","token","shareUrl"],"additionalProperties":false},"ApiShareLinkRecord":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"reportVersionId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"expiresAt":{"type":"string"},"revokedAt":{"type":"string","nullable":true},"recipientEmails":{"type":"array","items":{"type":"string"},"nullable":true},"hasPasscode":{"type":"boolean"},"viewCount":{"type":"integer","minimum":0},"lastViewedAt":{"type":"string","nullable":true},"createdAt":{"type":"string"},"createdBy":{"type":"string","nullable":true}},"required":["id","dealId","reportVersionId","profile","expiresAt","revokedAt","recipientEmails","hasPasscode","viewCount","lastViewedAt","createdAt","createdBy"],"additionalProperties":false},"ApiShareLinkListResponse":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"dealId":{"type":"string"},"reportVersionId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"expiresAt":{"type":"string"},"revokedAt":{"type":"string","nullable":true},"recipientEmails":{"type":"array","items":{"type":"string"},"nullable":true},"hasPasscode":{"type":"boolean"},"viewCount":{"type":"integer","minimum":0},"lastViewedAt":{"type":"string","nullable":true},"createdAt":{"type":"string"},"createdBy":{"type":"string","nullable":true}},"required":["id","dealId","reportVersionId","profile","expiresAt","revokedAt","recipientEmails","hasPasscode","viewCount","lastViewedAt","createdAt","createdBy"],"additionalProperties":false}}},"required":["data"],"additionalProperties":false},"ApiShareValidateResponse":{"type":"object","properties":{"deal":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"propertyType":{"type":"string"},"dealType":{"type":"string"}},"required":["id","name","propertyType","dealType"],"additionalProperties":false},"reportVersionId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"exportedAt":{"type":"string"},"expiresAt":{"type":"string"},"reportPackage":{"type":"object","additionalProperties":{}},"aiMemo":{"type":"object","additionalProperties":{},"nullable":true}},"required":["deal","reportVersionId","profile","exportedAt","expiresAt","reportPackage","aiMemo"],"additionalProperties":false},"ApiUsageResponse":{"type":"object","properties":{"tier":{"type":"string"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"dealsUsed":{"type":"integer"},"dealsCap":{"type":"integer"},"apiCallsUsed":{"type":"integer"},"apiCallsCap":{"type":"integer"},"rateLimit":{"type":"object","properties":{"perSecondBurst":{"type":"number"},"perMinuteSustained":{"type":"number"},"perDayCap":{"type":"number"}},"required":["perSecondBurst","perMinuteSustained","perDayCap"],"additionalProperties":false}},"required":["tier","periodStart","periodEnd","dealsUsed","dealsCap","apiCallsUsed","apiCallsCap","rateLimit"],"additionalProperties":false},"ApiWebhookEventType":{"type":"string","enum":["deal.created","deal.updated","deal.deleted","run.completed","run.failed","report.generated","comp.added"]},"ApiWebhookSubscribeRequest":{"type":"object","properties":{"targetUrl":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string","enum":["deal.created","deal.updated","deal.deleted","run.completed","run.failed","report.generated","comp.added"]},"minItems":1}},"required":["targetUrl","events"],"additionalProperties":false},"ApiWebhookSubscription":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"},"targetUrl":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string","enum":["deal.created","deal.updated","deal.deleted","run.completed","run.failed","report.generated","comp.added"]}},"active":{"type":"boolean"},"createdAt":{"type":"string"},"lastDeliveryAt":{"type":"string","nullable":true},"lastFailureAt":{"type":"string","nullable":true}},"required":["id","orgId","targetUrl","events","active","createdAt","lastDeliveryAt","lastFailureAt"],"additionalProperties":false},"ApiDealCreatedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["deal.created"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"dealId":{"type":"string"},"createdBy":{"type":"string"}},"required":["dealId","createdBy"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiDealUpdatedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["deal.updated"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"dealId":{"type":"string"},"updatedBy":{"type":"string"},"significantFields":{"type":"array","items":{"type":"string"}}},"required":["dealId","updatedBy","significantFields"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiDealDeletedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["deal.deleted"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"dealId":{"type":"string"},"deletedBy":{"type":"string"}},"required":["dealId","deletedBy"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiRunCompletedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["run.completed"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"runId":{"type":"string"},"dealId":{"type":"string"},"engineVersion":{"type":"string"}},"required":["runId","dealId","engineVersion"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiRunFailedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["run.failed"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"runId":{"type":"string"},"dealId":{"type":"string"},"errorCode":{"type":"string"},"warnings":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"severity":{"type":"string","enum":["info","warning","critical"]},"code":{"type":"string"},"title":{"type":"string"},"message":{"type":"string"},"sourcePath":{"type":"string"},"recommendedAction":{"type":"string"},"reportVisibility":{"type":"string","enum":["internal_only","user_visible","report_visible"]}},"required":["id","severity","code","title","message"],"additionalProperties":false}}},"required":["runId","dealId","errorCode","warnings"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiReportGeneratedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["report.generated"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"reportId":{"type":"string"},"dealId":{"type":"string"},"profile":{"type":"string","enum":["investor_memo","lender_package","agency_readiness_view","lease_abstract_appendix","committee_memo"]},"pdfUrl":{"type":"string","format":"uri"}},"required":["reportId","dealId","profile","pdfUrl"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiCompAddedEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["comp.added"]},"createdAt":{"type":"string"},"orgId":{"type":"string"},"payload":{"type":"object","properties":{"compId":{"type":"string"},"savedSearchId":{"type":"string","nullable":true}},"required":["compId","savedSearchId"],"additionalProperties":false}},"required":["id","type","createdAt","orgId","payload"],"additionalProperties":false},"ApiHealthResponse":{"type":"object","properties":{"ok":{"type":"boolean"},"engineVersion":{"type":"string"},"schemaVersion":{"type":"string"},"apiVersion":{"type":"string"},"region":{"type":"string"}},"required":["ok","engineVersion","schemaVersion","apiVersion"],"additionalProperties":false},"ApiUserProfile":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string","format":"email"},"emailVerified":{"type":"boolean"},"name":{"type":"string","nullable":true},"displayName":{"type":"string","nullable":true},"tier":{"type":"string","enum":["free","pro","pro_api","enterprise","admin"]},"organizationId":{"type":"string","nullable":true},"defaultRole":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"preferredUnits":{"type":"string","enum":["imperial","metric"]},"onboardedAt":{"type":"string","nullable":true},"telemetryConsent":{"type":"boolean"},"aiTrainingConsent":{"type":"boolean"},"compsOptin":{"type":"boolean"},"company":{"type":"string","nullable":true},"timezone":{"type":"string","nullable":true},"preferences":{"type":"object","properties":{"aiSettings":{"type":"object","additionalProperties":{}},"exportSettings":{"type":"object","additionalProperties":{}},"notificationPrefs":{"type":"object","additionalProperties":{}},"privacyConsent":{"type":"object","additionalProperties":{}}},"additionalProperties":false,"nullable":true},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","email","emailVerified","name","displayName","tier","organizationId","defaultRole","preferredUnits","onboardedAt","telemetryConsent","aiTrainingConsent","compsOptin","company","timezone","preferences","createdAt","updatedAt"],"additionalProperties":false},"ApiUserProfileUpdate":{"type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":120},"defaultRole":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"preferredUnits":{"type":"string","enum":["imperial","metric"]},"onboardedAt":{"type":"string","format":"date-time"},"telemetryConsent":{"type":"boolean"},"aiTrainingConsent":{"type":"boolean"},"compsOptin":{"type":"boolean"},"company":{"type":"string","maxLength":200,"nullable":true},"timezone":{"type":"string","maxLength":64,"nullable":true},"preferences":{"type":"object","properties":{"aiSettings":{"type":"object","additionalProperties":{}},"exportSettings":{"type":"object","additionalProperties":{}},"notificationPrefs":{"type":"object","additionalProperties":{}},"privacyConsent":{"type":"object","additionalProperties":{}}},"additionalProperties":false}},"additionalProperties":false},"ApiUserProfileResponse":{"type":"object","properties":{"profile":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string","format":"email"},"emailVerified":{"type":"boolean"},"name":{"type":"string","nullable":true},"displayName":{"type":"string","nullable":true},"tier":{"type":"string","enum":["free","pro","pro_api","enterprise","admin"]},"organizationId":{"type":"string","nullable":true},"defaultRole":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"preferredUnits":{"type":"string","enum":["imperial","metric"]},"onboardedAt":{"type":"string","nullable":true},"telemetryConsent":{"type":"boolean"},"aiTrainingConsent":{"type":"boolean"},"compsOptin":{"type":"boolean"},"company":{"type":"string","nullable":true},"timezone":{"type":"string","nullable":true},"preferences":{"type":"object","properties":{"aiSettings":{"type":"object","additionalProperties":{}},"exportSettings":{"type":"object","additionalProperties":{}},"notificationPrefs":{"type":"object","additionalProperties":{}},"privacyConsent":{"type":"object","additionalProperties":{}}},"additionalProperties":false,"nullable":true},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","email","emailVerified","name","displayName","tier","organizationId","defaultRole","preferredUnits","onboardedAt","telemetryConsent","aiTrainingConsent","compsOptin","company","timezone","preferences","createdAt","updatedAt"],"additionalProperties":false}},"required":["profile"],"additionalProperties":false},"ApiSessionRecord":{"type":"object","properties":{"id":{"type":"string"},"userAgent":{"type":"string","nullable":true},"ipAddress":{"type":"string","nullable":true},"createdAt":{"type":"string"},"expiresAt":{"type":"string"},"isCurrent":{"type":"boolean"}},"required":["id","userAgent","ipAddress","createdAt","expiresAt","isCurrent"],"additionalProperties":false},"ApiSessionListResponse":{"type":"object","properties":{"sessions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userAgent":{"type":"string","nullable":true},"ipAddress":{"type":"string","nullable":true},"createdAt":{"type":"string"},"expiresAt":{"type":"string"},"isCurrent":{"type":"boolean"}},"required":["id","userAgent","ipAddress","createdAt","expiresAt","isCurrent"],"additionalProperties":false}}},"required":["sessions"],"additionalProperties":false},"ApiSessionRevokeResponse":{"type":"object","properties":{"id":{"type":"string"},"revokedAt":{"type":"string"}},"required":["id","revokedAt"],"additionalProperties":false},"ApiSessionRevokeAllResponse":{"type":"object","properties":{"revokedCount":{"type":"integer","minimum":0},"currentSessionId":{"type":"string","nullable":true}},"required":["revokedCount","currentSessionId"],"additionalProperties":false},"ApiAuditLogEvent":{"type":"object","properties":{"id":{"type":"string"},"action":{"type":"string"},"organizationId":{"type":"string","nullable":true},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"payload":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","action","organizationId","ipAddress","userAgent","payload","createdAt"],"additionalProperties":false},"ApiAuditLogResponse":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"action":{"type":"string"},"organizationId":{"type":"string","nullable":true},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"payload":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","action","organizationId","ipAddress","userAgent","payload","createdAt"],"additionalProperties":false}},"days":{"type":"integer","minimum":1,"maximum":365},"hasMore":{"type":"boolean"}},"required":["events","days","hasMore"],"additionalProperties":false},"ApiTeamMember":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string","nullable":true},"role":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"invitedBy":{"type":"string","nullable":true},"invitedAt":{"type":"string","nullable":true},"acceptedAt":{"type":"string","nullable":true},"joinedAt":{"type":"string"}},"required":["id","userId","email","name","role","invitedBy","invitedAt","acceptedAt","joinedAt"],"additionalProperties":false},"ApiTeamListResponse":{"type":"object","properties":{"organizationId":{"type":"string"},"organizationName":{"type":"string"},"members":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string","nullable":true},"role":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"invitedBy":{"type":"string","nullable":true},"invitedAt":{"type":"string","nullable":true},"acceptedAt":{"type":"string","nullable":true},"joinedAt":{"type":"string"}},"required":["id","userId","email","name","role","invitedBy","invitedAt","acceptedAt","joinedAt"],"additionalProperties":false}}},"required":["organizationId","organizationName","members"],"additionalProperties":false},"ApiBillingUsageMetric":{"type":"object","properties":{"key":{"type":"string","enum":["deals","api_calls","reports","team_members"]},"label":{"type":"string"},"used":{"type":"integer","minimum":0},"limit":{"type":"integer","minimum":0,"nullable":true},"unit":{"type":"string"}},"required":["key","label","used","limit","unit"],"additionalProperties":false},"ApiBillingUsageResponse":{"type":"object","properties":{"tier":{"type":"string","enum":["free","pro","pro_api","enterprise","admin"]},"planLabel":{"type":"string"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"metrics":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","enum":["deals","api_calls","reports","team_members"]},"label":{"type":"string"},"used":{"type":"integer","minimum":0},"limit":{"type":"integer","minimum":0,"nullable":true},"unit":{"type":"string"}},"required":["key","label","used","limit","unit"],"additionalProperties":false}}},"required":["tier","planLabel","periodStart","periodEnd","metrics"],"additionalProperties":false},"ApiDataExportRequest":{"type":"object","properties":{},"additionalProperties":false},"ApiDataExportResponse":{"type":"object","properties":{"exportedAt":{"type":"string"},"schemaVersion":{"type":"string"},"user":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string","format":"email"},"name":{"type":"string","nullable":true},"emailVerified":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","email","name","emailVerified","createdAt"],"additionalProperties":false},"profile":{"type":"object","properties":{"id":{"type":"string"},"userId":{"type":"string"},"email":{"type":"string","format":"email"},"emailVerified":{"type":"boolean"},"name":{"type":"string","nullable":true},"displayName":{"type":"string","nullable":true},"tier":{"type":"string","enum":["free","pro","pro_api","enterprise","admin"]},"organizationId":{"type":"string","nullable":true},"defaultRole":{"type":"string","enum":["Owner","Admin","Analyst","Reviewer","Viewer","Billing"]},"preferredUnits":{"type":"string","enum":["imperial","metric"]},"onboardedAt":{"type":"string","nullable":true},"telemetryConsent":{"type":"boolean"},"aiTrainingConsent":{"type":"boolean"},"compsOptin":{"type":"boolean"},"company":{"type":"string","nullable":true},"timezone":{"type":"string","nullable":true},"preferences":{"type":"object","properties":{"aiSettings":{"type":"object","additionalProperties":{}},"exportSettings":{"type":"object","additionalProperties":{}},"notificationPrefs":{"type":"object","additionalProperties":{}},"privacyConsent":{"type":"object","additionalProperties":{}}},"additionalProperties":false,"nullable":true},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","email","emailVerified","name","displayName","tier","organizationId","defaultRole","preferredUnits","onboardedAt","telemetryConsent","aiTrainingConsent","compsOptin","company","timezone","preferences","createdAt","updatedAt"],"additionalProperties":false},"deals":{"type":"array","items":{"type":"object","additionalProperties":{}}},"reports":{"type":"array","items":{"type":"object","additionalProperties":{}}},"auditEvents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"action":{"type":"string"},"organizationId":{"type":"string","nullable":true},"ipAddress":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"payload":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","action","organizationId","ipAddress","userAgent","payload","createdAt"],"additionalProperties":false}},"apiKeys":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string","nullable":true},"keyPrefix":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string"},"lastUsedAt":{"type":"string","nullable":true},"revokedAt":{"type":"string","nullable":true}},"required":["id","name","keyPrefix","scopes","createdAt","lastUsedAt","revokedAt"],"additionalProperties":false}}},"required":["exportedAt","schemaVersion","user","profile","deals","reports","auditEvents","apiKeys"],"additionalProperties":false},"ApiAccountDeleteResponse":{"type":"object","properties":{"id":{"type":"string"},"deletedAt":{"type":"string"},"purgeScheduledFor":{"type":"string"},"sessionsRevoked":{"type":"integer","minimum":0}},"required":["id","deletedAt","purgeScheduledFor","sessionsRevoked"],"additionalProperties":false}},"securitySchemes":{"BearerApiKey":{"type":"http","scheme":"bearer","bearerFormat":"aiu_(live|test)_<base32>","description":"API key issued via the dashboard. Send as `Authorization: Bearer aiu_live_<...>`. Sandbox keys (`aiu_test_*`) accepted only at sandbox.aiunderwriting.net."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","minLength":8,"maxLength":255},"description":"Required on every POST/PATCH/DELETE/PUT. Same key + same body = cached response. Same key + different body = 409."}}}}