{"openapi":"3.1.0","info":{"title":"AI CMO API","version":"1.0.0","description":"Headless backend for AI CMO — AI-native marketing operations SaaS. All business endpoints live under /api/v1/* and require a Supabase bearer token. This spec is the source of truth for the frontend typed client."},"servers":[{"url":"/","description":"Same-origin (relative)."}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"cronSecret":{"type":"apiKey","in":"header","name":"x-cron-secret"}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"string","example":"unauthorized"},"message":{"type":"string","example":"Missing bearer token."},"details":{"type":"object","additionalProperties":{}}},"required":["error"]},"Me":{"type":"object","properties":{"userId":{"type":"string","example":"user_2abc..."},"email":{"type":["string","null"]},"orgId":{"type":["string","null"],"example":"org_abc123"},"role":{"type":["string","null"],"example":"admin"},"scopes":{"type":"array","items":{"type":"string"},"example":["full"]},"issuedAt":{"type":["number","null"]}},"required":["userId","email","orgId","role","scopes"]},"Profile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"name":{"type":["string","null"]},"businessType":{"type":["string","null"]},"onboardingCompleted":{"type":"boolean"},"email":{"type":["string","null"]},"role":{"type":["string","null"]},"plan":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId"]},"Organization":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"ownerId":{"type":"string"},"logoUrl":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"customDomain":{"type":["string","null"]},"clerkOrgId":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","ownerId"]},"Brand":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"workspaceId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"vertical":{"type":"string"},"status":{"type":"string"},"promise":{"type":"string"},"position":{"type":["string","null"]},"icp":{"type":["string","null"]},"pain":{"type":["string","null"]},"tone":{"type":["string","null"]},"proof":{"type":["string","null"]},"channels":{"type":"array","items":{"type":"string"}},"pillars":{"type":"array","items":{"type":"string"}},"offers":{"type":"array","items":{"type":"string"}},"objections":{"type":"array","items":{"type":"string"}},"doList":{"type":"array","items":{"type":"string"}},"dontList":{"type":"array","items":{"type":"string"}},"funnelFocus":{"type":"string"},"riskLevel":{"type":["string","null"]},"northStar":{"type":["string","null"]},"websiteUrl":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name"]},"WorkspaceMember":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"userId":{"type":"string"},"role":{"type":"string"},"status":{"type":"string"},"joinedAt":{"type":"string"},"email":{"type":["string","null"]},"name":{"type":["string","null"]}},"required":["id","organizationId","userId","role","status"]},"TeamMember":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"orgUserId":{"type":"string"},"invitedBy":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"role":{"type":"string"},"status":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","orgUserId","invitedBy","role","status"]},"TeamInvitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"},"email":{"type":"string"},"role":{"type":"string"},"inviteToken":{"type":"string"},"invitedBy":{"type":"string"},"status":{"type":"string"},"expiresAt":{"type":"string"},"createdAt":{"type":"string"},"acceptedAt":{"type":["string","null"]}},"required":["id","organizationId","email","role","inviteToken","invitedBy","status"]},"UserSettings":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"preferredModel":{"type":["string","null"]},"slackWebhook":{"type":["string","null"],"description":"Masked webhook hint — returned as \"••••…<last4>\" when set, null otherwise. The real webhook URL is write-only. A value starting with \"•\" is rejected on save."},"slackWebhookConfigured":{"type":"boolean","description":"True when a Slack webhook URL is stored; false/absent when none is configured."},"slackAutoPost":{"type":"boolean"},"anthropicApiKey":{"type":["string","null"],"description":"Presence indicator only — always returned as \"********\" when set, null otherwise."},"openaiApiKey":{"type":["string","null"],"description":"Presence indicator only — always returned as \"********\" when set, null otherwise."},"autoPublish":{"type":"boolean"},"notificationSlackEnabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId"]},"WorkspaceLink":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"clerkOrgId":{"type":"string"},"externalProduct":{"type":"string"},"externalWorkspaceId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"}},"required":["id","organizationId","clerkOrgId","externalProduct"]},"AnnualPlan":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"year":{"type":"integer"},"northStarMetric":{"type":["string","null"]},"northStarTarget":{"type":["string","null"]},"totalBudget":{"type":["string","null"]},"growthPillars":{},"notes":{"type":["string","null"]},"committedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId"]},"QuarterlyPlan":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"annualPlanId":{"type":["string","null"],"format":"uuid"},"quarter":{"type":"string"},"funnelFocus":{"type":["string","null"]},"channelMix":{},"budgetPercent":{"type":["string","null"]},"priorities":{"type":"array","items":{"type":"string"}},"kpiTargets":{"type":"object","additionalProperties":{}},"targetBudget":{"type":["string","null"]},"targetLeads":{"type":["integer","null"]},"targetRevenue":{"type":["string","null"]},"targetMeetings":{"type":["integer","null"]},"actualsLastSyncedAt":{"type":["string","null"]},"status":{"type":["string","null"]},"aiGeneratedMemo":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","quarter"]},"Plan":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"title":{"type":"string"},"periodType":{"type":"string"},"periodStart":{"type":["string","null"]},"periodEnd":{"type":["string","null"]},"goals":{"type":"array","items":{}},"themes":{"type":"array","items":{"type":"string"}},"channelMix":{"type":"object","additionalProperties":{}},"sourceMarkdown":{"type":"string"},"sourceRunId":{"type":["string","null"],"format":"uuid"},"sourceChatMessageId":{"type":["string","null"],"format":"uuid"},"parentPlanId":{"type":["string","null"],"format":"uuid"},"version":{"type":"integer"},"status":{"type":"string"},"signalRelevanceKeywords":{"type":"array","items":{"type":"string"}},"createdByUserId":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","title","periodType","createdByUserId"]},"PlanTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"content":{"type":"string"},"fileName":{"type":["string","null"]},"structure":{"type":"object","additionalProperties":{}},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name"]},"PivotSuggestion":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"planId":{"type":"string","format":"uuid"},"triggeredBySignalType":{"type":"string"},"triggeredBySignalId":{"type":["string","null"],"format":"uuid"},"severity":{"type":"string","enum":["low","medium","high","critical"]},"summary":{"type":"string"},"rationale":{"type":"string"},"suggestedDeltas":{"type":"array","items":{}},"status":{"type":"string"},"inboxItemId":{"type":["string","null"],"format":"uuid"},"expiresAt":{"type":["string","null"]},"acceptedAt":{"type":["string","null"]},"rejectedAt":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","organizationId","brandId","planId","triggeredBySignalType","severity","summary","rationale","suggestedDeltas","status"]},"KpiEntry":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"quarterlyPlanId":{"type":["string","null"],"format":"uuid"},"metricName":{"type":"string"},"targetValue":{"type":["string","null"]},"actualValue":{"type":["string","null"]},"weekOf":{"type":["string","null"]},"channel":{"type":["string","null"]},"notes":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","metricName"]},"HubKpiTarget":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"hubId":{"type":"string","enum":["content","paid","seo","pr","creative","lifecycle"]},"goalText":{"type":"string"},"mappedMetric":{"type":["string","null"]},"isQualitative":{"type":"boolean"},"proxyMetrics":{"type":"array","items":{"type":"string"}},"targetValue":{"type":["string","null"]},"targetWindow":{"type":["string","null"],"enum":["week","month","quarter","year"]},"automationPolicy":{"type":"string","enum":["recommend","suggest","auto-act"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","hubId","goalText"]},"KpiTermAlias":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"teamTerm":{"type":"string"},"canonicalMetricKey":{"type":"string"},"mappingConfidence":{"type":["string","null"]},"approvedAt":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","organizationId","brandId","teamTerm","canonicalMetricKey"]},"OrgBaseline":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"teamHeadcount":{"type":["integer","null"]},"teamRoles":{"type":"array","items":{"type":"string"}},"executionMode":{"type":["string","null"]},"monthlyBudget":{"type":["string","null"]},"annualBudget":{"type":["string","null"]},"channelBudgetCaps":{"type":"object","additionalProperties":{}},"committedSpend":{"type":["string","null"]},"pctNewCustomers":{"type":["integer","null"]},"pctExpansion":{"type":["integer","null"]},"cpl":{"type":["string","null"]},"cac":{"type":["string","null"]},"ltv":{"type":["string","null"]},"ltvCacRatio":{"type":["string","null"]},"leadToMqlCvr":{"type":["string","null"]},"mqlToSqlCvr":{"type":["string","null"]},"sqlToCloseCvr":{"type":["string","null"]},"avgDealSize":{"type":["string","null"]},"avgSalesCycle":{"type":["string","null"]},"funnelLeakStage":{"type":["string","null"]},"priorGoals":{"type":["string","null"]},"priorExecutionGap":{"type":["string","null"]},"priorWeakSpots":{"type":["string","null"]},"priorWins":{"type":["string","null"]},"salesObjections":{"type":"array","items":{"type":"string"}},"winReasons":{"type":"array","items":{"type":"string"}},"icpFitScore":{"type":["string","null"]},"dealVelocityTrend":{"type":["string","null"]},"complianceConstraints":{"type":["string","null"]},"excludedChannels":{"type":"array","items":{"type":"string"}},"previousPlanContent":{"type":["string","null"]},"previousPlanAnalysis":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId"]},"AgentRun":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"agentId":{"type":"string"},"agentName":{"type":"string"},"modelUsed":{"type":"string"},"prompt":{"type":["string","null"]},"output":{"type":"string"},"sentToSlack":{"type":"boolean"},"briefType":{"type":["string","null"]},"chainRunId":{"type":["string","null"],"format":"uuid"},"stepIndex":{"type":["integer","null"]},"createdAt":{"type":"string"}},"required":["id","userId","agentId","agentName","modelUsed","output"]},"ChainRun":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"templateId":{"type":"string"},"status":{"type":"string"},"startedAt":{"type":["string","null"]},"completedAt":{"type":["string","null"]},"inputs":{"type":"object","additionalProperties":{}},"outputs":{"type":"object","additionalProperties":{}},"error":{"type":"string"},"triggeredBy":{"type":"string"},"actorUserId":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","templateId","status"]},"ChainTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"createdByUserId":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"agentId":{"type":"string"},"priority":{"type":"integer"},"contextNotes":{"type":"string"},"modelTier":{"type":"string","enum":["fast","standard","pro"]}},"required":["agentId","priority"]}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","createdByUserId","name","steps"]},"OutcomeRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"agentId":{"type":"string"},"agentRunId":{"type":["string","null"],"format":"uuid"},"inputSummary":{"type":"string"},"outputSummary":{"type":"string"},"outcome":{"type":"string","enum":["accepted","edited","rejected","ignored"]},"feedback":{"type":["string","null"]},"qualityScore":{"type":["integer","null"]},"model":{"type":"string"},"promptTokens":{"type":["integer","null"]},"outputTokens":{"type":["integer","null"]},"createdAt":{"type":"string"}},"required":["id","userId","organizationId","brandId","agentId","outcome","model"]},"OAuthExchangeBody":{"type":"object","properties":{"provider":{"type":"string","enum":["google","meta","notion","hubspot","shopify","linkedin","tiktok","twitter"]},"code":{"type":"string","minLength":1},"redirect_uri":{"type":"string","format":"uri"},"brand_id":{"type":"string","format":"uuid","description":"Brand this connection belongs to — must be owned by the caller's org."},"shop":{"type":"string","description":"Required for Shopify only (*.myshopify.com host)."},"code_verifier":{"type":"string","description":"Required for Twitter PKCE only."}},"required":["provider","code","redirect_uri","brand_id"]},"OAuthExchangeResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"provider":{"type":"string"},"integrations":{"type":"array","items":{"type":"string"}}},"required":["success","provider","integrations"]},"AgentQualityScore":{"type":"object","properties":{"agentId":{"type":"string","example":"creative_generator"},"score":{"type":"number","minimum":0,"maximum":5,"description":"Blended quality score 0–5, 2 decimals."},"explicitAvg":{"type":["number","null"],"description":"Avg of explicit quality ratings (1–5), null if none."},"explicitCount":{"type":"integer","description":"Count of runs with an explicit quality rating."},"acceptRate":{"type":"number","minimum":0,"maximum":1,"description":"(accepted + edited) / total runs, 0–1."},"runCount":{"type":"integer","description":"Total runs in the window."},"windowDays":{"type":"integer","description":"Rolling window in days (1–90)."}},"required":["agentId","score","explicitAvg","explicitCount","acceptRate","runCount","windowDays"]},"Campaign":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"quarterlyPlanId":{"type":["string","null"],"format":"uuid"},"planId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"type":{"type":["string","null"]},"funnelStage":{"type":["string","null"]},"channels":{"type":"array","items":{"type":"string"}},"startDate":{"type":["string","null"]},"endDate":{"type":["string","null"]},"budget":{"type":["string","null"]},"brief":{"type":["string","null"]},"campaignType":{"type":["string","null"]},"status":{"type":"string"},"color":{"type":["string","null"]},"tags":{"type":"array","items":{"type":"string"}},"externalCampaignIds":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name"]},"ContentCalendarItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":"string","format":"uuid"},"date":{"type":"string"},"topic":{"type":"string"},"channel":{"type":"string"},"format":{"type":"string"},"priority":{"type":"string"},"status":{"type":"string"},"notes":{"type":["string","null"]},"content":{"type":["string","null"]},"imageUrl":{"type":["string","null"]},"scheduledTime":{"type":["string","null"]},"platformPostId":{"type":["string","null"]},"publishStatus":{"type":["string","null"]},"campaignId":{"type":["string","null"],"format":"uuid"},"planId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","brandId","date","topic","channel"]},"Artifact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"agentRunId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"content":{"type":"string"},"format":{"type":"string"},"agentId":{"type":["string","null"]},"agentName":{"type":["string","null"]},"modelUsed":{"type":["string","null"]},"status":{"type":"string"},"pinned":{"type":"boolean"},"tags":{"type":"array","items":{"type":"string"}},"cloudUrl":{"type":["string","null"]},"cloudSyncedAt":{"type":["string","null"]},"campaignId":{"type":["string","null"],"format":"uuid"},"planId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","title"]},"CreativeItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"description":{"type":["string","null"]},"content":{"type":["string","null"]},"status":{"type":"string"},"assetType":{"type":"string"},"assignee":{"type":["string","null"]},"assigneeName":{"type":["string","null"]},"partnerName":{"type":["string","null"]},"dueDate":{"type":["string","null"]},"priority":{"type":["string","null"]},"thumbnailUrl":{"type":["string","null"]},"attachmentUrls":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}},"sourceAgentId":{"type":["string","null"]},"sourceDeliverableId":{"type":["string","null"],"format":"uuid"},"outputDeliverableId":{"type":["string","null"],"format":"uuid"},"comments":{},"campaignId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","title"]},"BrandMemory":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":"string","format":"uuid"},"type":{"type":"string"},"content":{"type":"string"},"status":{"type":"string"},"sourceAgentRunId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","brandId","type","content"]},"BrandVoiceProfile":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"voiceDescription":{"type":"string"},"toneKeywords":{"type":"array","items":{"type":"string"}},"vocabulary":{"type":"object","additionalProperties":{}},"sampleCount":{"type":"integer"},"lastTrainedAt":{"type":["string","null"]},"trainingStatus":{"type":"string","enum":["untrained","training","ready","stale"]},"approvedByUserId":{"type":["string","null"]},"approvedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId"]},"BrandVoiceExample":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"sourceType":{"type":"string"},"sourceUrl":{"type":["string","null"]},"content":{"type":"string"},"contentType":{"type":"string"},"includedInProfile":{"type":"boolean"},"createdAt":{"type":"string"}},"required":["id","organizationId","brandId","content"]},"Competitor":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"url":{"type":["string","null"]},"notes":{"type":["string","null"]},"tags":{"type":["array","null"],"items":{"type":"string"}},"monitoringEnabled":{"type":"boolean"},"lastScrapedAt":{"type":["string","null"]},"scrapeFailureCount":{"type":"number"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name"]},"CompetitorUpdate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"competitorId":{"type":"string","format":"uuid"},"snapshotAt":{"type":"string"},"sourceKind":{"type":"string"},"title":{"type":["string","null"]},"summary":{"type":["string","null"]},"changeType":{"type":"string"},"confidence":{"type":["string","null"]},"rawDiff":{"type":["string","null"]},"evaluatedAt":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","organizationId","brandId","competitorId"]},"CompetitorSnapshot":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"competitorId":{"type":"string","format":"uuid"},"scrapedHtmlSummary":{"type":["string","null"]},"pricingSignals":{"type":"object","additionalProperties":{}},"scrapedAt":{"type":"string"}},"required":["id","competitorId"]},"SignalInput":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"signalType":{"type":"string"},"title":{"type":"string"},"excerpt":{"type":["string","null"]},"sourceUrl":{"type":["string","null"]},"processed":{"type":"boolean"},"rawText":{"type":["string","null"]},"confidence":{"type":["string","null"]},"evaluatedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","title"]},"MetricsSnapshot":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"source":{"type":"string"},"periodStart":{"type":["string","null"]},"periodEnd":{"type":["string","null"]},"data":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","userId","source"]},"AgentKnowledge":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":"string","format":"uuid"},"agentId":{"type":"string"},"type":{"type":"string"},"title":{"type":"string"},"content":{"type":"string"},"fileName":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","brandId","agentId","title"]},"Skill":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"description":{"type":["string","null"]},"layer":{"type":"string"},"content":{"type":"string"},"version":{"type":"number"},"agentIds":{"type":"array","items":{"type":"string"}},"category":{"type":["string","null"]},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","slug","name"]},"SkillVersion":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"skillId":{"type":"string","format":"uuid"},"version":{"type":"number"},"content":{"type":"string"},"changedBy":{"type":["string","null"]},"changeNote":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","skillId","version","content"]},"VerticalKnowledge":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"vertical":{"type":"string"},"content":{"type":"string"},"version":{"type":"number"},"updatedAt":{"type":"string"}},"required":["id","vertical"]},"Project":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"description":{"type":["string","null"]},"content":{"type":["string","null"]},"status":{"type":"string"},"ownerType":{"type":["string","null"]},"ownerName":{"type":["string","null"]},"ownerAgentId":{"type":["string","null"]},"ownerUserId":{"type":["string","null"]},"taskType":{"type":["string","null"]},"priority":{"type":["string","null"]},"dueDate":{"type":["string","null"]},"sourceAgentId":{"type":["string","null"]},"sourceAgentRunId":{"type":["string","null"],"format":"uuid"},"customFields":{"type":"object","additionalProperties":{}},"campaignId":{"type":["string","null"],"format":"uuid"},"parentProjectId":{"type":["string","null"],"format":"uuid"},"quarterlyPlanId":{"type":["string","null"],"format":"uuid"},"isPriority":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","title"]},"ProjectCustomFieldDef":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"options":{"type":"array","items":{}},"position":{"type":"integer"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name","type"]},"Automation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":["string","null"],"format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"triggerType":{"type":"string"},"triggerConfig":{"type":"object","additionalProperties":{}},"conditions":{"type":"array","items":{}},"steps":{"type":"array","items":{}},"actions":{"type":"array","items":{}},"status":{"type":"string"},"templateId":{"type":["string","null"]},"lastRunAt":{"type":["string","null"]},"nextRunAt":{"type":["string","null"]},"runCount":{"type":"integer"},"nextChainId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","name"]},"OpsTask":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"agentRunId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"description":{"type":["string","null"]},"assignee":{"type":["string","null"]},"status":{"type":"string"},"priority":{"type":"string"},"dueDate":{"type":["string","null"]},"type":{"type":"string"},"done":{"type":"boolean"},"assigneeId":{"type":["string","null"],"format":"uuid"},"assigneeName":{"type":["string","null"]},"assignmentStatus":{"type":"string"},"suggestedAssignee":{"type":["string","null"],"format":"uuid"},"routingStatus":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","title"]},"TaskRoutingRule":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"taskType":{"type":"string"},"assignedRole":{"type":["string","null"]},"assignedUserId":{"type":["string","null"]},"priority":{"type":["integer","null"]},"createdAt":{"type":"string"}},"required":["id","userId","taskType"]},"HandoffQueueItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"agentId":{"type":"string"},"type":{"type":"string"},"urgency":{"type":"string"},"title":{"type":"string"},"context":{"type":["string","null"]},"recommendation":{"type":["string","null"]},"actionNeeded":{"type":["string","null"]},"assignedRole":{"type":["string","null"]},"assignedUserId":{"type":["string","null"]},"status":{"type":"string"},"response":{"type":["string","null"]},"sourceAgentRunId":{"type":["string","null"],"format":"uuid"},"createdAt":{"type":"string"},"resolvedAt":{"type":["string","null"]}},"required":["id","userId","agentId","type","title"]},"ApprovalQueueItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"approverUserId":{"type":["string","null"]},"brandId":{"type":["string","null"],"format":"uuid"},"itemType":{"type":"string"},"itemId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string"},"reviewedAt":{"type":["string","null"]},"reviewNotes":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","itemType","title"]},"ReviewQueueItem":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"sourceAgentRunId":{"type":["string","null"],"format":"uuid"},"type":{"type":"string"},"content":{"type":"string"},"status":{"type":"string"},"chainName":{"type":["string","null"]},"chainId":{"type":["string","null"]},"stepOutputs":{"type":"array","items":{}},"editedOutput":{"type":["string","null"]},"reviewedAt":{"type":["string","null"]},"reviewedBy":{"type":["string","null"],"format":"uuid"},"reviewNotes":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","content"]},"ScheduledChain":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"chainTemplate":{"type":"string"},"schedule":{"type":"string"},"runOnDay":{"type":"string"},"enabled":{"type":"boolean"},"lastRunAt":{"type":["string","null"]},"nextRunAt":{"type":["string","null"]},"runAtHour":{"type":"integer"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId"]},"AuditLogEntry":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"action":{"type":"string"},"entityType":{"type":["string","null"]},"entityId":{"type":["string","null"],"format":"uuid"},"metadata":{"type":"object","additionalProperties":{}},"details":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","action"]},"ActivityLogEntry":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"organizationId":{"type":"string","format":"uuid"},"entityType":{"type":"string"},"entityId":{"type":"string"},"activityType":{"type":"string"},"body":{"type":["string","null"]},"changeField":{"type":["string","null"]},"changeFrom":{"type":["string","null"]},"changeTo":{"type":["string","null"]},"mentionedUserIds":{"type":"array","items":{}},"createdAt":{"type":"string"}},"required":["id","userId","organizationId","entityType","entityId","activityType"]},"Lead":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"company":{"type":["string","null"]},"jobTitle":{"type":["string","null"]},"source":{"type":"string"},"sourceFormId":{"type":["string","null"]},"sourceUrl":{"type":["string","null"]},"utm":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string"},"score":{"type":"integer"},"assignedToUserId":{"type":["string","null"]},"lastActivityAt":{"type":["string","null"]},"notes":{"type":"string"},"customFields":{"type":"object","additionalProperties":{}},"externalId":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId"]},"LeadActivity":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"leadId":{"type":"string","format":"uuid"},"activityType":{"type":"string"},"title":{"type":"string"},"body":{"type":"string"},"actorId":{"type":["string","null"]},"actorType":{"type":"string"},"metadata":{"type":"object","additionalProperties":{}},"occurredAt":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","organizationId","leadId","activityType","title","actorType"]},"PrTarget":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"journalistName":{"type":"string"},"journalistEmail":{"type":["string","null"]},"journalistTwitter":{"type":["string","null"]},"outlet":{"type":"string"},"outletTier":{"type":"string"},"beat":{"type":["string","null"]},"relevanceScore":{"type":"integer"},"stage":{"type":"string"},"assignedToUserId":{"type":["string","null"]},"notes":{"type":"string"},"lastActivityAt":{"type":["string","null"]},"lastActivitySummary":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","journalistName","outlet"]},"PrActivity":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"prTargetId":{"type":"string","format":"uuid"},"activityType":{"type":"string"},"title":{"type":"string"},"body":{"type":"string"},"artifactId":{"type":["string","null"],"format":"uuid"},"actorId":{"type":["string","null"]},"actorType":{"type":"string"},"metadata":{"type":"object","additionalProperties":{}},"occurredAt":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","organizationId","prTargetId","activityType","title","actorType"]},"LifecycleFlow":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"provider":{"type":"string"},"externalFlowId":{"type":"string"},"name":{"type":"string"},"flowType":{"type":"string"},"typeClassifiedBy":{"type":"string"},"status":{"type":"string"},"lastSyncedAt":{"type":["string","null"]},"rawMetadata":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","provider","externalFlowId","name"]},"LifecycleFlowMetric":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"flowId":{"type":"string","format":"uuid"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"sends":{"type":"integer"},"opens":{"type":"integer"},"clicks":{"type":"integer"},"attributedRevenueCents":{"type":"integer"},"attributedOrders":{"type":"integer"},"attributionWindowDays":{"type":"integer"},"rawMetadata":{"type":"object","additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","organizationId","flowId","periodStart","periodEnd"]},"StrategicBrief":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"periodStart":{"type":"string"},"periodEnd":{"type":"string"},"generatedAt":{"type":"string"},"status":{"type":"string"},"sections":{"type":"object","additionalProperties":{}},"summary":{"type":"string"},"pdfUrl":{"type":["string","null"]},"editedSummary":{"type":["string","null"]},"editedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","periodStart","periodEnd"]},"AttributionRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"agentRunId":{"type":["string","null"],"format":"uuid"},"subjectType":{"type":"string"},"subjectId":{"type":"string","format":"uuid"},"metricName":{"type":"string"},"metricValue":{"type":"string"},"metricUnit":{"type":"string"},"provider":{"type":"string"},"measuredAt":{"type":"string"},"measurementWindowDays":{"type":"integer"},"confidence":{"type":"string"},"notes":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","organizationId","brandId","subjectType","subjectId","metricName","metricValue","metricUnit","provider","measuredAt"]},"BusinessEvent":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"},"entityType":{"type":"string"},"entityId":{"type":"string"},"eventType":{"type":"string"},"actorId":{"type":["string","null"]},"actorType":{"type":"string"},"idempotencyKey":{"type":["string","null"]},"payloadJson":{"type":"object","additionalProperties":{}},"occurredAt":{"type":"string"},"createdAt":{"type":"string"}},"required":["id","organizationId","entityType","entityId","eventType","actorType"]},"EventDispatch":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"eventId":{"type":"string","format":"uuid"},"handlerName":{"type":"string"},"status":{"type":"string"},"attemptCount":{"type":"integer"},"maxAttempts":{"type":"integer"},"nextRetryAt":{"type":["string","null"]},"errorMessage":{"type":["string","null"]},"completedAt":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","organizationId","eventId","handlerName","status"]},"IntegrationCredential":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"provider":{"type":"string"},"scopes":{"type":["array","null"],"items":{"type":"string"}},"status":{"type":["string","null"]},"lastRefreshedAt":{"type":["string","null"]},"metadata":{"type":["object","null"],"additionalProperties":{}},"connectedAt":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"enabled":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","userId","provider"]},"IntegrationDelivery":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"},"integrationId":{"type":["string","null"],"format":"uuid"},"sourceEventType":{"type":"string"},"eventId":{"type":"string"},"payload":{"type":"object","additionalProperties":{}},"status":{"type":"string"},"skipReason":{"type":["string","null"]},"attempts":{"type":"integer"},"nextRetryAt":{"type":["string","null"]},"deliveredAt":{"type":["string","null"]},"error":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","organizationId","sourceEventType","eventId","status"]},"MarketingEventSubscription":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"},"integrationId":{"type":"string","format":"uuid"},"eventType":{"type":"string"},"enabled":{"type":"boolean"},"config":{"type":"object","additionalProperties":{}},"createdByUserId":{"type":"string"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","integrationId","eventType","createdByUserId"]},"ChatMessage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"role":{"type":"string"},"content":{"type":"string"},"mode":{"type":["string","null"]},"metadata":{"type":["object","null"],"additionalProperties":{}},"attachments":{"type":["array","null"],"items":{}},"createdAt":{"type":"string"}},"required":["id","userId","role","content"]},"Notification":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"organizationId":{"type":"string","format":"uuid"},"kind":{"type":"string"},"sourceEntityType":{"type":["string","null"]},"sourceEntityId":{"type":["string","null"]},"sourceActivityId":{"type":["string","null"],"format":"uuid"},"actorUserId":{"type":["string","null"]},"body":{"type":["string","null"]},"readAt":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","organizationId","kind"]},"PublishLog":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"contentId":{"type":["string","null"],"format":"uuid"},"platform":{"type":"string"},"contentSnapshot":{"type":["string","null"]},"status":{"type":"string"},"errorMessage":{"type":["string","null"]},"approvedAt":{"type":"string"},"approvedBy":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","userId","platform","status"]},"WorkspaceBilling":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":["string","null"],"format":"uuid"},"userId":{"type":["string","null"]},"agentId":{"type":["string","null"]},"model":{"type":["string","null"]},"tokens":{"type":["integer","null"]},"costIndex":{"type":["integer","null"]},"period":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id"]},"Subscription":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"userId":{"type":"string"},"stripeCustomerId":{"type":"string"},"stripeSubscriptionId":{"type":"string"},"status":{"type":"string"},"planId":{"type":"string"},"currentPeriodEnd":{"type":"string"},"trialEnd":{"type":["string","null"]},"cancelAtPeriodEnd":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","userId","stripeCustomerId","stripeSubscriptionId","status","planId","currentPeriodEnd"]},"StripeEvent":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"receivedAt":{"type":"string"}},"required":["id","type"]},"UserTodo":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"organizationId":{"type":["string","null"],"format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"body":{"type":["string","null"]},"source":{"type":"string"},"sourceEntityType":{"type":["string","null"]},"sourceEntityId":{"type":["string","null"],"format":"uuid"},"status":{"type":"string"},"priority":{"type":"integer"},"snoozedUntil":{"type":["string","null"]},"completedAt":{"type":["string","null"]},"generatedAt":{"type":["string","null"]},"updatedAt":{"type":["string","null"]}},"required":["id","userId","title","source"]},"FederatedQueryResponse":{"type":"object","properties":{"answer":{"type":"string","example":"Found 42 runs from agent_runs in the last 30 days."},"data":{"type":"array","items":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"null"},{"type":"null"}]}},"example":[{"agentId":"creative_generator","agentName":"Creative Generator","count":12}]},"widget":{"type":"object","properties":{"type":{"type":"string","enum":["table","bar_chart","metric_card","unsupported"]},"columns":{"type":"array","items":{"type":"string"}},"series":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","example":"creative_generator"},"value":{"type":"number","example":12}},"required":["label","value"]}},"value":{"type":"number"},"label":{"type":"string"}},"required":["type"]},"sources":{"type":"array","items":{"type":"string"},"example":["agent_runs"]},"plan":{"type":"object","properties":{"unsupported":{"type":"boolean"},"unsupportedReason":{"type":"string"}},"required":["unsupported"]},"truncated":{"type":"boolean","description":"True when results were capped at the MAX_ROWS limit."}},"required":["answer","data","widget","sources","plan","truncated"]},"CredentialDeleteBody":{"type":"object","properties":{"provider":{"type":"string","example":"posthog"},"credential_id":{"type":"string","format":"uuid"},"brand_id":{"type":"string","format":"uuid","description":"Disambiguates which brand's credential to revoke when the same provider is connected for more than one brand."}}},"CredentialUpdateMetadataBody":{"type":"object","properties":{"provider":{"type":"string","example":"posthog"},"metadata":{"type":"object","additionalProperties":{}},"last_synced_at":{"type":"string","example":"2026-01-01T00:00:00Z"},"status":{"type":"string","enum":["active","revoked","expired"]},"enabled":{"type":"boolean"},"brand_id":{"type":"string","format":"uuid","description":"Disambiguates which brand's credential to update when the same provider is connected for more than one brand."}},"required":["provider"]},"SlackPostBody":{"type":"object","properties":{"brandId":{"type":"string","format":"uuid"},"text":{"type":"string","example":"Agent completed campaign analysis."},"agentName":{"type":"string"},"brandName":{"type":"string"},"webhookId":{"type":"string"},"blocks":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["brandId","text"]},"SlackPostResponse":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]},"IntegrationActionBody":{"type":"object","properties":{"action":{"type":"string","enum":["test","sync","capture_event","create_feature_flag"]}},"required":["action"]},"IntegrationSuccessResponse":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]},"IntegrationErrorResponse":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}},"required":["error"]},"CredentialRecord":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"provider":{"type":"string"},"brand_id":{"type":["string","null"],"format":"uuid"},"connected":{"type":"boolean","enum":[true]},"status":{"type":"string"},"apiKeyMasked":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}},"last_synced_at":{"type":["string","null"]},"connected_at":{"type":["string","null"]}},"required":["id","provider","brand_id","connected","status","apiKeyMasked","metadata","last_synced_at","connected_at"]},"CredentialsListResponse":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"credentials":{"type":"array","items":{"$ref":"#/components/schemas/CredentialRecord"}}},"required":["success","credentials"]},"CredentialCreateBody":{"type":"object","properties":{"provider":{"type":"string","minLength":1,"example":"posthog"},"api_key":{"type":"string","minLength":1},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","api_key"]},"Strategy":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"userId":{"type":"string"},"name":{"type":"string"},"northStar":{"type":["string","null"]},"positioning":{"type":["string","null"]},"icp":{"type":["string","null"]},"pillars":{"type":"array","items":{"type":"string"}},"status":{"type":"string","enum":["draft","active","archived"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId"]},"FunnelStage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"strategyId":{"type":["string","null"],"format":"uuid"},"stageKey":{"type":"string","enum":["awareness","consideration","conversion","retention","advocacy"]},"conversionDef":{"type":["string","null"]},"orderIndex":{"type":"integer"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","stageKey"]},"KpiDef":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"funnelStageId":{"type":["string","null"],"format":"uuid"},"metric":{"type":"string"},"target":{"type":["string","null"]},"unit":{"type":["string","null"]},"direction":{"type":"string","enum":["up","down"]},"isKeyConversion":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","metric"]},"ChannelStrategy":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"strategyId":{"type":["string","null"],"format":"uuid"},"funnelStageId":{"type":["string","null"],"format":"uuid"},"channel":{"type":"string"},"strategyText":{"type":["string","null"]},"status":{"type":"string","enum":["draft","approved"]},"aiDrafted":{"type":"boolean"},"approvedByUserId":{"type":["string","null"]},"approvedAt":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","channel"]},"Tactic":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"channelStrategyId":{"type":["string","null"],"format":"uuid"},"funnelStageId":{"type":["string","null"],"format":"uuid"},"title":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["planned","active","done"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","title"]},"Insight":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organizationId":{"type":"string","format":"uuid"},"brandId":{"type":"string","format":"uuid"},"title":{"type":"string"},"body":{"type":["string","null"]},"channel":{"type":["string","null"]},"severity":{"type":"string","enum":["info","warning","critical"]},"status":{"type":"string","enum":["new","read","actioned","dismissed"]},"sourceSignalId":{"type":["string","null"],"format":"uuid"},"funnelStageId":{"type":["string","null"],"format":"uuid"},"kpiDefId":{"type":["string","null"],"format":"uuid"},"actionType":{"type":["string","null"]},"sourceAgentId":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","organizationId","brandId","title"]}},"parameters":{}},"paths":{"/api/v1/me":{"get":{"summary":"The authenticated principal derived from the Supabase JWT.","tags":["identity"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Principal info.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/profiles/me":{"get":{"summary":"Get own profile.","tags":["profiles"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Profile row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/Profile"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update own profile.","tags":["profiles"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":["string","null"]},"businessType":{"type":["string","null"]},"onboardingCompleted":{"type":"boolean"},"email":{"type":["string","null"],"format":"email"}}}}}},"responses":{"200":{"description":"Updated profile.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Profile"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/profiles/upsert":{"post":{"summary":"Upsert own profile.","tags":["profiles"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":["string","null"]},"businessType":{"type":["string","null"]},"onboardingCompleted":{"type":"boolean"},"email":{"type":["string","null"],"format":"email"}}}}}},"responses":{"200":{"description":"Upserted profile.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Profile"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/organizations":{"get":{"summary":"List organizations the caller belongs to.","tags":["organizations"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Org list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Organization"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an organization.","tags":["organizations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1},"logoUrl":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"customDomain":{"type":["string","null"]}},"required":["name"]}}}},"responses":{"201":{"description":"Created org.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Organization"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/organizations/by-domain":{"get":{"summary":"Lookup org by custom domain.","tags":["organizations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"domain","in":"query"}],"responses":{"200":{"description":"Org (or minimal public shape).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Organization"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/organizations/{id}":{"get":{"summary":"Get an organization by id (membership required).","tags":["organizations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Org row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Organization"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an organization (admin only).","tags":["organizations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}}},"responses":{"200":{"description":"Updated org.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Organization"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an organization (admin only).","tags":["organizations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brands":{"get":{"summary":"List brands for the caller's organization.","tags":["brands"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Brand list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Brand"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a brand.","tags":["brands"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Brand"},{"required":["name"]}]}}}},"responses":{"201":{"description":"Created brand.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Brand"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brands/{id}":{"get":{"summary":"Get a brand by id.","tags":["brands"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Brand row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Brand"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a brand.","tags":["brands"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Brand"}}}},"responses":{"200":{"description":"Updated brand.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Brand"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a brand.","tags":["brands"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brands/assign-workspace":{"patch":{"summary":"Bulk-assign unlinked brands to this org.","tags":["brands"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-members":{"get":{"summary":"List workspace members (with profiles).","tags":["workspace-members"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Member list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceMember"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Add a member to the workspace (admin only).","tags":["workspace-members"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"userId":{"type":"string"},"role":{"type":"string","enum":["admin","strategist","client"]},"status":{"type":"string"}},"required":["userId"]}}}},"responses":{"201":{"description":"Created member.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceMember"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-members/{id}":{"get":{"summary":"Get a workspace member.","tags":["workspace-members"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Member row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceMember"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a member's role or status (admin only).","tags":["workspace-members"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string","enum":["admin","strategist","client"]},"status":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated member.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceMember"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Remove a workspace member (admin only).","tags":["workspace-members"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Removed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-members":{"get":{"summary":"List team members for the caller (invited or member-of).","tags":["team-members"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Team member list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TeamMember"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-members/me":{"get":{"summary":"List active team memberships for the caller.","tags":["team-members"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Active memberships.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TeamMember"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-members/brand/{brandId}":{"get":{"summary":"List team members for a brand.","tags":["team-members"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brandId","in":"path"}],"responses":{"200":{"description":"Brand team members.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TeamMember"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-members/{id}":{"delete":{"summary":"Remove a team member (inviter only).","tags":["team-members"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Removed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-invitations":{"get":{"summary":"List team invitations for the org (filter by ?brand_id=X).","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Invitation list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TeamInvitation"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a team invitation.","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","strategist","client"]},"brandId":{"type":["string","null"],"format":"uuid"}},"required":["email","role"]}}}},"responses":{"201":{"description":"Created invitation.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TeamInvitation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-invitations/{id}":{"get":{"summary":"Get a team invitation.","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Invitation row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TeamInvitation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Revoke a team invitation.","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TeamInvitation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/team-invitations/{id}/resend":{"post":{"summary":"Resend a team invitation (extends expiry by 7 days).","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Updated invitation.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TeamInvitation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-settings":{"get":{"summary":"Get own user settings.","tags":["user-settings"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Settings row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/UserSettings"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-settings/me":{"get":{"summary":"Get own user settings (alias).","tags":["user-settings"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Settings row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/UserSettings"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-settings/upsert":{"post":{"summary":"Upsert own user settings.","tags":["user-settings"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSettings"}}}},"responses":{"200":{"description":"Upserted settings.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UserSettings"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-links":{"get":{"summary":"List cross-product workspace links for the org.","tags":["workspace-links"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Link list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceLink"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a workspace link (manage_integrations required).","tags":["workspace-links"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"externalProduct":{"type":"string"},"externalWorkspaceId":{"type":["string","null"],"format":"uuid"},"clerkOrgId":{"type":"string"}},"required":["externalProduct","clerkOrgId"]}}}},"responses":{"201":{"description":"Upserted link.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceLink"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-links/{id}":{"get":{"summary":"Get a workspace link.","tags":["workspace-links"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Link row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceLink"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a workspace link.","tags":["workspace-links"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/annual-plans":{"get":{"summary":"List annual plans for the org.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Annual plan list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AnnualPlan"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an annual plan.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"year":{"type":"integer"},"northStarMetric":{"type":["string","null"]},"northStarTarget":{"type":["string","null"]},"totalBudget":{"type":["string","null"]},"growthPillars":{},"notes":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AnnualPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/annual-plans/{id}":{"get":{"summary":"Get an annual plan.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Annual plan row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AnnualPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an annual plan. Editing content demotes a committed plan back to draft.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"userId":{"type":"string"},"brandId":{"type":["string","null"],"format":"uuid"},"year":{"type":"integer"},"northStarMetric":{"type":["string","null"]},"northStarTarget":{"type":["string","null"]},"totalBudget":{"type":["string","null"]},"growthPillars":{},"notes":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}}}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AnnualPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an annual plan.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/annual-plans/{id}/commit":{"post":{"summary":"Commit an annual plan (draft → committed) — only committed plans feed agents.","tags":["annual-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Committed.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AnnualPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/quarterly-plans":{"get":{"summary":"List quarterly plans for the org.","tags":["quarterly-plans"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Quarterly plan list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/QuarterlyPlan"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a quarterly plan.","tags":["quarterly-plans"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuarterlyPlan"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/QuarterlyPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/quarterly-plans/{id}":{"get":{"summary":"Get a quarterly plan.","tags":["quarterly-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Quarterly plan row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/QuarterlyPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a quarterly plan.","tags":["quarterly-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuarterlyPlan"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/QuarterlyPlan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a quarterly plan.","tags":["quarterly-plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/plans":{"get":{"summary":"List plans for the org.","tags":["plans"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Plan list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Plan"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a plan.","tags":["plans"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Plan"},{"required":["organizationId","brandId","title","periodType","createdByUserId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Plan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/plans/{id}":{"get":{"summary":"Get a plan.","tags":["plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Plan row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Plan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a plan.","tags":["plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Plan"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Plan"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a plan.","tags":["plans"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/plan-templates":{"get":{"summary":"List plan templates for the org.","tags":["plan-templates"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Template list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PlanTemplate"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a plan template.","tags":["plan-templates"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PlanTemplate"},{"required":["userId","name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PlanTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/plan-templates/{id}":{"get":{"summary":"Get a plan template.","tags":["plan-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Template row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PlanTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a plan template.","tags":["plan-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanTemplate"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PlanTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a plan template.","tags":["plan-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pivot-suggestions":{"get":{"summary":"List pivot suggestions for the org.","tags":["pivot-suggestions"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Pivot suggestion list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PivotSuggestion"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a pivot suggestion (manual).","tags":["pivot-suggestions"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PivotSuggestion"},{"required":["organizationId","brandId","planId","triggeredBySignalType","severity","summary","rationale","suggestedDeltas"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PivotSuggestion"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pivot-suggestions/{id}":{"get":{"summary":"Get a pivot suggestion.","tags":["pivot-suggestions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Pivot suggestion row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PivotSuggestion"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update pivot suggestion status.","tags":["pivot-suggestions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PivotSuggestion"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PivotSuggestion"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a pivot suggestion.","tags":["pivot-suggestions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-entries":{"get":{"summary":"List KPI entries for the org.","tags":["kpi-entries"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"KPI entry list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/KpiEntry"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a KPI entry.","tags":["kpi-entries"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/KpiEntry"},{"required":["userId","metricName"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-entries/{id}":{"get":{"summary":"Get a KPI entry.","tags":["kpi-entries"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"KPI entry row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a KPI entry.","tags":["kpi-entries"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KpiEntry"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a KPI entry.","tags":["kpi-entries"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/hub-kpi-targets":{"get":{"summary":"List hub KPI targets for the org.","tags":["hub-kpi-targets"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Hub KPI target list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/HubKpiTarget"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a hub KPI target (brandId + hubId).","tags":["hub-kpi-targets"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/HubKpiTarget"},{"required":["organizationId","brandId","hubId","goalText"]}]}}}},"responses":{"201":{"description":"Created/updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HubKpiTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/hub-kpi-targets/{id}":{"get":{"summary":"Get a hub KPI target.","tags":["hub-kpi-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Hub KPI target row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HubKpiTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a hub KPI target.","tags":["hub-kpi-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HubKpiTarget"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HubKpiTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a hub KPI target.","tags":["hub-kpi-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-term-aliases":{"get":{"summary":"List KPI term aliases for the org.","tags":["kpi-term-aliases"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Alias list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/KpiTermAlias"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a KPI term alias (brandId + teamTerm).","tags":["kpi-term-aliases"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/KpiTermAlias"},{"required":["organizationId","brandId","teamTerm","canonicalMetricKey"]}]}}}},"responses":{"201":{"description":"Created/updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiTermAlias"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-term-aliases/{id}":{"get":{"summary":"Get a KPI term alias.","tags":["kpi-term-aliases"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Alias row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiTermAlias"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a KPI term alias.","tags":["kpi-term-aliases"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/org-baseline":{"get":{"summary":"Get or list org baseline(s).","tags":["org-baseline"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Baseline row or list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/OrgBaseline"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert org baseline (userId + brandId).","tags":["org-baseline"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/OrgBaseline"},{"required":["userId","brandId"]}]}}}},"responses":{"200":{"description":"Upserted baseline.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OrgBaseline"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/org-baseline/{id}":{"delete":{"summary":"Delete an org baseline row.","tags":["org-baseline"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/run":{"post":{"summary":"Run a single agent against a brand context.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid","example":"uuid"},"agent_id":{"type":"string","example":"creative_generator"},"user_message":{"type":"string","example":"Generate 5 ad hooks for our spring campaign."},"chain_run_id":{"type":"string","format":"uuid"},"step_index":{"type":"integer"}},"required":["brand_id","agent_id","user_message"]}}}},"responses":{"200":{"description":"Agent run result.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"agentRunId":{"type":"string","format":"uuid"},"agentId":{"type":"string"},"output":{"type":"string"},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"},"cache_creation_input_tokens":{"type":["integer","null"]},"cache_read_input_tokens":{"type":["integer","null"]}},"required":["input_tokens","output_tokens","cache_creation_input_tokens","cache_read_input_tokens"]},"model":{"type":"string"},"brandId":{"type":"string","format":"uuid"},"createdAt":{"type":"string"}},"required":["agentRunId","agentId","output","usage","model","brandId","createdAt"]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand or agent not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"AI provider unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/run-async":{"post":{"summary":"Run a heavy agent in the background (Netlify Background Function, avoids the 26s sync cap). Poll GET /api/v1/data/agent-runs/{id} for completion.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid","example":"uuid"},"agent_id":{"type":"string","example":"marketing_plan"},"system_prompt":{"type":"string"},"user_message":{"type":"string","example":"Build a 90-day plan."},"model":{"type":"string"},"chain_run_id":{"type":"string","format":"uuid"},"step_index":{"type":"integer"},"max_tokens":{"type":"integer","minimum":256,"maximum":16384}},"required":["brand_id","user_message"]}}}},"responses":{"202":{"description":"Agent run accepted — dispatched to background, status is running.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"agentRunId":{"type":"string","format":"uuid"},"agentId":{"type":"string"},"status":{"type":"string","enum":["running"]},"brandId":{"type":"string","format":"uuid"},"createdAt":{"type":"string"}},"required":["agentRunId","agentId","status","brandId","createdAt"]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand or agent not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/run-chain":{"post":{"summary":"Execute a chain template (sequential multi-step agent run).","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"template_id":{"type":"string","example":"daily_performance"},"inputs":{"type":"object","additionalProperties":{}}},"required":["brand_id","template_id"]}}}},"responses":{"200":{"description":"Chain run result.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"chainRunId":{"type":"string","format":"uuid"},"templateId":{"type":"string"},"brandId":{"type":"string","format":"uuid"},"status":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"agentId":{"type":"string"},"priority":{"type":"integer"},"status":{"type":"string"},"output":{"type":["string","null"]},"error":{"type":["string","null"]},"startedAt":{"type":["string","null"]},"completedAt":{"type":["string","null"]}},"required":["agentId","priority","status","output","error","startedAt","completedAt"]}},"outputs":{"type":"object","additionalProperties":{}},"error":{"type":["string","null"]}},"required":["chainRunId","templateId","brandId","status","steps","outputs","error"]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand or template not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/runs/{id}/feedback":{"post":{"summary":"Record an outcome for an agent run (learning loop).","tags":["agents"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"outcome":{"type":"string","enum":["accepted","edited","rejected","ignored"]},"feedback":{"type":"string"},"quality_score":{"type":"integer","minimum":1,"maximum":5}},"required":["outcome"]}}}},"responses":{"200":{"description":"Outcome record written.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OutcomeRecord"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Agent run not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/oauth-exchange":{"post":{"summary":"Exchange a provider OAuth authorization code for tokens, scoped to one brand.","description":"Server-side half of the popup OAuth flow. Persists per (userId, brandId, provider) — connecting the same provider for two brands no longer clobbers each other.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthExchangeBody"}}}},"responses":{"200":{"description":"Exchanged and stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OAuthExchangeResponse"}}}},"400":{"description":"Validation failed / token exchange rejected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Body validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Provider OAuth not configured on the server.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/quality-scores":{"get":{"summary":"Per-agent rolling quality score derived from outcome records.","description":"Aggregates outcome_records within the given window. Blended score = 0.7 × explicit_avg + 0.3 × (accept_rate × 5). Falls back to implicit-only when no explicit ratings exist. Sorted ascending (worst first) — intended as a REFINE-trigger surface.","tags":["agents"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Filter by brand (org scope is still the auth boundary)."},"required":false,"name":"brand_id","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":90,"description":"Rolling window in days, default 14, clamped 1–90."},"required":false,"name":"window_days","in":"query"}],"responses":{"200":{"description":"Quality score list (sorted score asc).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"$ref":"#/components/schemas/AgentQualityScore"}}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error (e.g. malformed brand_id).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/brand-audit":{"post":{"summary":"Create or update a brand and run an AI brand audit (onboarding \"Analyze My Brand\").","description":"Accepts a brand name + website URL (and optionally an existing brand_id). Creates the brand row if brand_id is absent, then runs the brand-audit AI job. Returns 202 always — if the LLM quota is capped the brand is still created and auditStatus is set to \"failed\" so onboarding can proceed.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_name":{"type":"string","minLength":1,"maxLength":200,"example":"Acme Corp"},"url":{"type":"string","minLength":1,"maxLength":2000,"example":"https://acme.com"},"brand_id":{"type":"string","format":"uuid","description":"Existing brand UUID. Omit to create a new brand."},"documents":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"content":{"type":"string"}},"required":["name","content"]}}},"required":["brand_name","url"]}}}},"responses":{"202":{"description":"Audit queued or completed (or gracefully degraded on LLM quota cap).","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"brand_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["completed","failed","queued"]},"message":{"type":"string"}},"required":["success","brand_id","status"]}}}},"400":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"brand_id not found in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/scrape":{"post":{"summary":"Scrape a public URL and return extracted text content.","description":"SSRF-guarded: rejects private/internal IPs and metadata endpoints with 400. Uses Firecrawl when FIRECRAWL_API_KEY is configured; otherwise falls back to plain fetch. Returns 502/504 on upstream failure — never 500.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","minLength":1,"maxLength":2000,"example":"https://example.com"}},"required":["url"]}}}},"responses":{"200":{"description":"Scraped content.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"url":{"type":"string"},"title":{"type":["string","null"]},"excerpt":{"type":["string","null"]},"markdown":{"type":"string"}},"required":["success","url","title","excerpt","markdown"]}}}},"400":{"description":"Validation error or SSRF-blocked URL.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Upstream scrape service error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"504":{"description":"Upstream scrape timed out.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/classify-signal":{"post":{"summary":"Classify a signal_inputs row using an LLM (degrades gracefully on quota).","description":"Resolves the signal row (org-scoped via brand), calls the AI to classify it as one of: trend, objection, angle, competitor_move, market_shift. Falls back to rule-based classification if the LLM quota is capped. Persists signal_type + confidence back to the row and returns 202 — never 500 on LLM failure.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"signal_id":{"type":"string","format":"uuid","description":"UUID of the signal_inputs row to classify."}},"required":["signal_id"]}}}},"responses":{"202":{"description":"Classification completed or gracefully degraded.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"signal_id":{"type":"string","format":"uuid"},"signal_type":{"type":"string","enum":["trend","objection","angle","competitor_move","market_shift"]},"confidence":{"type":"integer","minimum":0,"maximum":100},"degraded":{"type":"boolean","description":"true when LLM quota capped — rule-based fallback was used."},"row":{"type":"object","additionalProperties":{}}},"required":["success","signal_id","signal_type","confidence"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Signal not found in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/todo-generate":{"post":{"summary":"Generate AI todos for the caller × brand (degrades gracefully on quota).","description":"Fetches brand context (approvals, agent runs, plans, signals, dismissed todos), calls the LLM (haiku) to generate 3-5 prioritized to-dos, then upserts them. Returns 202 always — on LLM quota failure returns degraded:true with an empty todos array so the FE can show a \"try again\" state without receiving a 500.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid","description":"Brand UUID. Must belong to the caller's org."}},"required":["brand_id"]}}}},"responses":{"202":{"description":"Todos generated (or gracefully degraded on quota cap).","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"brand_id":{"type":"string","format":"uuid"},"todos":{"type":"array","items":{"type":"object","additionalProperties":{}}},"generated_count":{"type":"integer"},"degraded":{"type":"boolean"},"message":{"type":"string"}},"required":["success","brand_id","todos","generated_count"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/send-notification":{"post":{"summary":"Send an in-app + optional Slack/email notification (best-effort delivery).","description":"Always persists an in-app notifications inbox row. Slack delivery is attempted when the recipient has a webhook configured in their settings. Email is attempted when the email integration key is set and to_email is provided. Slack/email failures are logged but never cause a 500 — the endpoint returns 200 with a delivery summary.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to_user_id":{"type":"string","minLength":1,"description":"User ID of the notification recipient."},"kind":{"type":"string","enum":["approval_needed","chain_complete","task_assigned","event_trigger"]},"body":{"type":"string","minLength":1,"maxLength":10000},"subject":{"type":"string","maxLength":200},"to_email":{"type":"string","format":"email","description":"If set and the email integration is configured, sends an email."},"source_entity_type":{"type":"string"},"source_entity_id":{"type":"string"}},"required":["to_user_id","body"]}}}},"responses":{"200":{"description":"Notification dispatched (with best-effort delivery summary).","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"delivery":{"type":"object","properties":{"inbox":{"type":"boolean"},"slack":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["skipped"]}]},"email":{"anyOf":[{"type":"boolean"},{"type":"string","enum":["skipped"]}]},"errors":{"type":"array","items":{"type":"string"}}},"required":["inbox","slack","email","errors"]}},"required":["success","delivery"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/team/invite":{"post":{"summary":"Create a team invitation (org-scoped, manage_team required).","description":"Creates a team_invitations row scoped to the caller's org. Generates a unique invite token and optionally sends an email via Resend (best-effort — skipped when the email integration key is absent). Returns the created invitation row.","tags":["team-invitations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"role":{"type":"string","enum":["admin","strategist","copywriter","client"]},"brand_id":{"type":"string","format":"uuid"}},"required":["email","role"]}}}},"responses":{"201":{"description":"Invitation created.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/TeamInvitation"}},"required":["success","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/agent-runs":{"get":{"summary":"List agent runs for the org.","tags":["agent-runs"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Agent run list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AgentRun"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/agent-runs/{id}":{"get":{"summary":"Get an agent run.","tags":["agent-runs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Agent run row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AgentRun"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chain-runs":{"get":{"summary":"List chain runs for the org.","tags":["chain-runs"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Chain run list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ChainRun"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chain-runs/{id}":{"get":{"summary":"Get a chain run.","tags":["chain-runs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Chain run row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChainRun"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chain-templates":{"get":{"summary":"List user-defined chain templates for the org.","tags":["chain-templates"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Template list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ChainTemplate"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a user-defined chain template.","tags":["chain-templates"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ChainTemplate"},{"required":["name","steps"]}]}}}},"responses":{"201":{"description":"Created template.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChainTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chain-templates/{id}":{"get":{"summary":"Get a chain template.","tags":["chain-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Template row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChainTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a chain template.","tags":["chain-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChainTemplate"}}}},"responses":{"200":{"description":"Updated template.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChainTemplate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a chain template.","tags":["chain-templates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/campaigns":{"get":{"summary":"List campaigns for the org.","tags":["campaigns"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Campaign list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a campaign.","tags":["campaigns"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Campaign"},{"required":["name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Campaign"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/campaigns/{id}":{"get":{"summary":"Get a campaign.","tags":["campaigns"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Campaign row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Campaign"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a campaign.","tags":["campaigns"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Campaign"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a campaign.","tags":["campaigns"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/content-calendar":{"get":{"summary":"List content calendar items for the org.","tags":["content-calendar"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Item list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ContentCalendarItem"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a content calendar item.","tags":["content-calendar"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ContentCalendarItem"},{"required":["brandId","date","topic","channel"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ContentCalendarItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/content-calendar/{id}":{"get":{"summary":"Get a content calendar item.","tags":["content-calendar"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Item row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ContentCalendarItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a content calendar item.","tags":["content-calendar"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContentCalendarItem"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ContentCalendarItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a content calendar item.","tags":["content-calendar"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/artifacts":{"get":{"summary":"List artifacts for the org.","tags":["artifacts"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Artifact list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Artifact"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an artifact.","tags":["artifacts"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Artifact"},{"required":["title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Artifact"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/artifacts/{id}":{"get":{"summary":"Get an artifact.","tags":["artifacts"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Artifact row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Artifact"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an artifact.","tags":["artifacts"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Artifact"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Artifact"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an artifact.","tags":["artifacts"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/creative-items":{"get":{"summary":"List creative items for the org.","tags":["creative-items"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Creative item list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CreativeItem"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a creative item.","tags":["creative-items"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CreativeItem"},{"required":["title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CreativeItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/creative-items/{id}":{"get":{"summary":"Get a creative item.","tags":["creative-items"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Creative item row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CreativeItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a creative item.","tags":["creative-items"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreativeItem"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CreativeItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a creative item.","tags":["creative-items"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-memory":{"get":{"summary":"List brand memory entries for the org.","tags":["brand-memory"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Brand memory list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BrandMemory"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a brand memory entry.","tags":["brand-memory"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BrandMemory"},{"required":["brandId","type","content"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandMemory"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-memory/{id}":{"get":{"summary":"Get a brand memory entry.","tags":["brand-memory"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Brand memory row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandMemory"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a brand memory entry.","tags":["brand-memory"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandMemory"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandMemory"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a brand memory entry.","tags":["brand-memory"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-voice-profiles":{"get":{"summary":"List brand voice profiles for the org.","tags":["brand-voice-profiles"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Profile list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BrandVoiceProfile"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-voice-profiles/by-brand/{brandId}":{"get":{"summary":"Get a brand voice profile by brandId.","tags":["brand-voice-profiles"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brandId","in":"path"}],"responses":{"200":{"description":"Profile row or null.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/BrandVoiceProfile"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Upsert brand voice profile by brandId.","tags":["brand-voice-profiles"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brandId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandVoiceProfile"}}}},"responses":{"200":{"description":"Upserted profile.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/BrandVoiceProfile"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-voice-profiles/{id}":{"get":{"summary":"Get a brand voice profile by id.","tags":["brand-voice-profiles"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Profile row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandVoiceProfile"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a brand voice profile by id.","tags":["brand-voice-profiles"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BrandVoiceProfile"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandVoiceProfile"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-voice-examples":{"get":{"summary":"List brand voice examples for the org (filter ?brand_id=X).","tags":["brand-voice-examples"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Example list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BrandVoiceExample"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a brand voice example (also updates profile sample_count).","tags":["brand-voice-examples"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BrandVoiceExample"},{"required":["brandId","content"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandVoiceExample"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/brand-voice-examples/{id}":{"get":{"summary":"Get a brand voice example.","tags":["brand-voice-examples"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Example row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BrandVoiceExample"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a brand voice example (also decrements profile sample_count).","tags":["brand-voice-examples"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitors":{"get":{"summary":"List competitors for the org.","tags":["competitors"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Competitor list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Competitor"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a competitor.","tags":["competitors"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Competitor"},{"required":["name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Competitor"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitors/{id}":{"get":{"summary":"Get a competitor.","tags":["competitors"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Competitor row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Competitor"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a competitor.","tags":["competitors"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Competitor"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Competitor"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a competitor.","tags":["competitors"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitor-updates":{"get":{"summary":"List competitor updates for the org.","tags":["competitor-updates"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Update list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CompetitorUpdate"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a competitor update.","tags":["competitor-updates"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CompetitorUpdate"},{"required":["brandId","competitorId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CompetitorUpdate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitor-updates/{id}":{"get":{"summary":"Get a competitor update.","tags":["competitor-updates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Update row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CompetitorUpdate"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a competitor update.","tags":["competitor-updates"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitor-snapshots":{"get":{"summary":"List competitor snapshots for the org.","tags":["competitor-snapshots"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Snapshot list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CompetitorSnapshot"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a competitor snapshot.","tags":["competitor-snapshots"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CompetitorSnapshot"},{"required":["competitorId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CompetitorSnapshot"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitor-snapshots/{id}":{"get":{"summary":"Get a competitor snapshot.","tags":["competitor-snapshots"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Snapshot row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/CompetitorSnapshot"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a competitor snapshot.","tags":["competitor-snapshots"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/signal-inputs":{"get":{"summary":"List signal inputs for the org.","tags":["signal-inputs"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Signal input list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SignalInput"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a signal input.","tags":["signal-inputs"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SignalInput"},{"required":["title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SignalInput"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/signal-inputs/{id}":{"get":{"summary":"Get a signal input.","tags":["signal-inputs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Signal input row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SignalInput"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a signal input.","tags":["signal-inputs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SignalInput"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SignalInput"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a signal input.","tags":["signal-inputs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/gap-analysis":{"get":{"summary":"Run a gap-analysis pass for a brand and return ranked findings + receipt.","tags":["intelligence"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Brand UUID to analyze."},"required":true,"name":"brand_id","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4,20}$","description":"GA4 numeric property id."},"required":false,"name":"ga4_property_id","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":2048,"description":"Google Search Console site URL."},"required":false,"name":"gsc_site_url","in":"query"}],"responses":{"200":{"description":"Gap-analysis result: ranked findings + per-pass receipt.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"findings":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"title":{"type":"string"},"severity":{"type":"string","enum":["critical","warning","info"]},"signalType":{"type":"string"},"recommendation":{"type":"string"},"weight":{"type":"number"}},"required":["key","title","severity","signalType","recommendation","weight"]}},"receipt":{"type":"object","properties":{"receiptId":{"type":"string"},"startedAt":{"type":"string"},"durationMs":{"type":"number"},"signalCount":{"type":"integer"},"findingCount":{"type":"integer"},"criticalCount":{"type":"integer"},"warningCount":{"type":"integer"},"infoCount":{"type":"integer"},"topRecommendation":{"type":["string","null"]}},"required":["receiptId","startedAt","durationMs","signalCount","findingCount","criticalCount","warningCount","infoCount","topRecommendation"]}},"required":["findings","receipt"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/metrics-snapshots":{"get":{"summary":"List metrics snapshots for the org.","tags":["metrics-snapshots"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Metrics snapshot list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MetricsSnapshot"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a metrics snapshot.","tags":["metrics-snapshots"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/MetricsSnapshot"},{"required":["source"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MetricsSnapshot"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/metrics-snapshots/{id}":{"get":{"summary":"Get a metrics snapshot.","tags":["metrics-snapshots"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Metrics snapshot row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MetricsSnapshot"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a metrics snapshot.","tags":["metrics-snapshots"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/agent-knowledge":{"get":{"summary":"List agent knowledge entries for the org.","tags":["agent-knowledge"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Agent knowledge list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AgentKnowledge"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an agent knowledge entry.","tags":["agent-knowledge"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AgentKnowledge"},{"required":["brandId","agentId","title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AgentKnowledge"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/agent-knowledge/{id}":{"get":{"summary":"Get an agent knowledge entry.","tags":["agent-knowledge"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Agent knowledge row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AgentKnowledge"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an agent knowledge entry.","tags":["agent-knowledge"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentKnowledge"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AgentKnowledge"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an agent knowledge entry.","tags":["agent-knowledge"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/skills":{"get":{"summary":"List all skills (global).","tags":["skills"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Skill list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Skill"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a skill.","tags":["skills"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Skill"},{"required":["slug","name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Skill"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/skills/{id}":{"get":{"summary":"Get a skill.","tags":["skills"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Skill row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Skill"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a skill.","tags":["skills"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Skill"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Skill"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a skill.","tags":["skills"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/skill-versions":{"get":{"summary":"List skill versions (global).","tags":["skill-versions"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Skill version list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SkillVersion"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a skill version.","tags":["skill-versions"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/SkillVersion"},{"required":["skillId","version","content"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SkillVersion"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/skill-versions/{id}":{"get":{"summary":"Get a skill version.","tags":["skill-versions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Skill version row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/SkillVersion"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a skill version.","tags":["skill-versions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/vertical-knowledge":{"get":{"summary":"List all vertical knowledge entries (global).","tags":["vertical-knowledge"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Vertical knowledge list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/VerticalKnowledge"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a vertical knowledge entry.","tags":["vertical-knowledge"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/VerticalKnowledge"},{"required":["vertical"]}]}}}},"responses":{"201":{"description":"Upserted.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"allOf":[{"$ref":"#/components/schemas/VerticalKnowledge"},{"type":["object","null"]}]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/vertical-knowledge/{id}":{"get":{"summary":"Get a vertical knowledge entry.","tags":["vertical-knowledge"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Vertical knowledge row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/VerticalKnowledge"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a vertical knowledge entry.","tags":["vertical-knowledge"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/projects":{"get":{"summary":"List projects for the org.","tags":["projects"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Project list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Project"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a project.","tags":["projects"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Project"},{"required":["title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Project"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/projects/{id}":{"get":{"summary":"Get a project.","tags":["projects"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Project row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Project"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a project.","tags":["projects"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Project"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a project.","tags":["projects"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/project-custom-fields":{"get":{"summary":"List project custom field defs for caller.","tags":["project-custom-fields"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Custom field def list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ProjectCustomFieldDef"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a project custom field def.","tags":["project-custom-fields"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ProjectCustomFieldDef"},{"required":["name","type"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProjectCustomFieldDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/project-custom-fields/{id}":{"get":{"summary":"Get a project custom field def.","tags":["project-custom-fields"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Custom field def row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProjectCustomFieldDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a project custom field def.","tags":["project-custom-fields"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectCustomFieldDef"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ProjectCustomFieldDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a project custom field def.","tags":["project-custom-fields"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/automations":{"get":{"summary":"List automations for the org.","tags":["automations"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Automation list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Automation"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an automation.","tags":["automations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Automation"},{"required":["name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Automation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/automations/{id}":{"get":{"summary":"Get an automation.","tags":["automations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Automation row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Automation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an automation.","tags":["automations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Automation"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Automation"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an automation.","tags":["automations"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/ops-tasks":{"get":{"summary":"List ops tasks for the org.","tags":["ops-tasks"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Ops task list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/OpsTask"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an ops task.","tags":["ops-tasks"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/OpsTask"},{"required":["title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OpsTask"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/ops-tasks/{id}":{"get":{"summary":"Get an ops task.","tags":["ops-tasks"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Ops task row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OpsTask"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an ops task.","tags":["ops-tasks"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpsTask"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/OpsTask"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an ops task.","tags":["ops-tasks"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/task-routing-rules":{"get":{"summary":"List task routing rules for the org.","tags":["task-routing-rules"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Task routing rule list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/TaskRoutingRule"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a task routing rule.","tags":["task-routing-rules"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/TaskRoutingRule"},{"required":["taskType"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TaskRoutingRule"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/task-routing-rules/{id}":{"get":{"summary":"Get a task routing rule.","tags":["task-routing-rules"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Task routing rule row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TaskRoutingRule"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a task routing rule.","tags":["task-routing-rules"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskRoutingRule"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/TaskRoutingRule"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a task routing rule.","tags":["task-routing-rules"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/handoff-queue":{"get":{"summary":"List handoff queue items for the org.","tags":["handoff-queue"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Handoff queue list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/HandoffQueueItem"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a handoff queue item.","tags":["handoff-queue"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/HandoffQueueItem"},{"required":["agentId","type","title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HandoffQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/handoff-queue/{id}":{"get":{"summary":"Get a handoff queue item.","tags":["handoff-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Handoff queue item.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HandoffQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Resolve/update a handoff queue item.","tags":["handoff-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/HandoffQueueItem"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/HandoffQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a handoff queue item.","tags":["handoff-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/approval-queue":{"get":{"summary":"List approval queue items for the org.","tags":["approval-queue"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Approval queue list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ApprovalQueueItem"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an approval queue item.","tags":["approval-queue"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ApprovalQueueItem"},{"required":["itemType","title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ApprovalQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/approval-queue/{id}":{"get":{"summary":"Get an approval queue item.","tags":["approval-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Approval queue item.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ApprovalQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Resolve/update an approval queue item.","tags":["approval-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApprovalQueueItem"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ApprovalQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an approval queue item.","tags":["approval-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/review-queue":{"get":{"summary":"List review queue items for the org.","tags":["review-queue"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Review queue list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ReviewQueueItem"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a review queue item.","tags":["review-queue"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ReviewQueueItem"},{"required":["content"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ReviewQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/review-queue/{id}":{"get":{"summary":"Get a review queue item.","tags":["review-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Review queue item.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ReviewQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Resolve/update a review queue item.","tags":["review-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReviewQueueItem"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ReviewQueueItem"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a review queue item.","tags":["review-queue"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/scheduled-chains":{"get":{"summary":"List scheduled chains for the org.","tags":["scheduled-chains"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Scheduled chains list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ScheduledChain"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a scheduled chain.","tags":["scheduled-chains"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScheduledChain"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ScheduledChain"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/scheduled-chains/{id}":{"get":{"summary":"Get a scheduled chain.","tags":["scheduled-chains"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Scheduled chain row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ScheduledChain"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a scheduled chain.","tags":["scheduled-chains"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ScheduledChain"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ScheduledChain"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a scheduled chain.","tags":["scheduled-chains"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/audit-log":{"get":{"summary":"List audit log entries for the org.","tags":["audit-log"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Audit log list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AuditLogEntry"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Append an audit log entry.","tags":["audit-log"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AuditLogEntry"},{"required":["action"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AuditLogEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/audit-log/{id}":{"get":{"summary":"Get an audit log entry.","tags":["audit-log"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Audit log entry.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AuditLogEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/activity-log":{"get":{"summary":"List activity log entries for the org.","tags":["activity-log"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Activity log list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ActivityLogEntry"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Append an activity log entry.","tags":["activity-log"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ActivityLogEntry"},{"required":["entityType","entityId","activityType"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActivityLogEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/activity-log/{id}":{"get":{"summary":"Get an activity log entry.","tags":["activity-log"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Activity log entry.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ActivityLogEntry"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/leads":{"get":{"summary":"List leads for the org.","tags":["leads"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Leads list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Lead"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a lead.","tags":["leads"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Lead"},{"required":["brandId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Lead"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/leads/{id}":{"get":{"summary":"Get a lead.","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Lead row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Lead"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a lead.","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Lead"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a lead.","tags":["leads"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lead-activities":{"get":{"summary":"List lead activities (filtered by leadId query param).","tags":["lead-activities"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"leadId","in":"query"}],"responses":{"200":{"description":"Lead activities list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LeadActivity"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a lead activity.","tags":["lead-activities"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/LeadActivity"},{"required":["leadId","activityType","title","actorType"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LeadActivity"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lead-activities/{id}":{"get":{"summary":"Get a lead activity.","tags":["lead-activities"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Lead activity row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LeadActivity"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pr-targets":{"get":{"summary":"List PR targets for the org.","tags":["pr-targets"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"PR targets list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PrTarget"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a PR target.","tags":["pr-targets"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PrTarget"},{"required":["brandId","journalistName","outlet"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pr-targets/{id}":{"get":{"summary":"Get a PR target.","tags":["pr-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"PR target row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a PR target.","tags":["pr-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrTarget"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrTarget"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a PR target.","tags":["pr-targets"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pr-activities":{"get":{"summary":"List PR activities (filtered by prTargetId query param).","tags":["pr-activities"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"prTargetId","in":"query"}],"responses":{"200":{"description":"PR activities list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PrActivity"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a PR activity.","tags":["pr-activities"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PrActivity"},{"required":["prTargetId","activityType","title","actorType"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrActivity"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/pr-activities/{id}":{"get":{"summary":"Get a PR activity.","tags":["pr-activities"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"PR activity row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PrActivity"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lifecycle-flows":{"get":{"summary":"List lifecycle flows for the org.","tags":["lifecycle-flows"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Lifecycle flows list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LifecycleFlow"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a lifecycle flow.","tags":["lifecycle-flows"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/LifecycleFlow"},{"required":["brandId","provider","externalFlowId","name"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LifecycleFlow"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lifecycle-flows/{id}":{"get":{"summary":"Get a lifecycle flow.","tags":["lifecycle-flows"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Lifecycle flow row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LifecycleFlow"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a lifecycle flow.","tags":["lifecycle-flows"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LifecycleFlow"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LifecycleFlow"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a lifecycle flow.","tags":["lifecycle-flows"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lifecycle-flow-metrics":{"get":{"summary":"List lifecycle flow metrics (filtered by flowId query param).","tags":["lifecycle-flow-metrics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"flowId","in":"query"}],"responses":{"200":{"description":"Lifecycle flow metrics list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LifecycleFlowMetric"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a lifecycle flow metric row.","tags":["lifecycle-flow-metrics"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/LifecycleFlowMetric"},{"required":["flowId","periodStart","periodEnd"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LifecycleFlowMetric"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lifecycle-flow-metrics/{id}":{"get":{"summary":"Get a lifecycle flow metric row.","tags":["lifecycle-flow-metrics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Lifecycle flow metric row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/LifecycleFlowMetric"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/strategic-briefs":{"get":{"summary":"List strategic briefs for the org.","tags":["strategic-briefs"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Strategic briefs list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StrategicBrief"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a strategic brief.","tags":["strategic-briefs"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/StrategicBrief"},{"required":["brandId","periodStart","periodEnd"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StrategicBrief"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/strategic-briefs/{id}":{"get":{"summary":"Get a strategic brief.","tags":["strategic-briefs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Strategic brief row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StrategicBrief"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a strategic brief (edit summary, status, etc.).","tags":["strategic-briefs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StrategicBrief"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StrategicBrief"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a strategic brief.","tags":["strategic-briefs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/attribution-records":{"get":{"summary":"List attribution records for the org.","tags":["attribution-records"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Attribution records list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AttributionRecord"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an attribution record.","tags":["attribution-records"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/AttributionRecord"},{"required":["brandId","subjectType","subjectId","metricName","metricValue","metricUnit","provider","measuredAt"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AttributionRecord"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/attribution-records/{id}":{"get":{"summary":"Get an attribution record.","tags":["attribution-records"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Attribution record row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/AttributionRecord"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an attribution record.","tags":["attribution-records"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/recent-agent-activity":{"get":{"summary":"Ran-while-you-were-away: terminal chain_runs since `since` for this org.","tags":["computed"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"since","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"},{"schema":{"type":"string"},"required":false,"name":"agent_ids","in":"query"}],"responses":{"200":{"description":"Recent agent activity.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"array","items":{"type":"object","additionalProperties":{}}},"summary":{"type":"object","properties":{"total":{"type":"integer"},"succeeded":{"type":"integer"},"failed":{"type":"integer"},"partial":{"type":"integer"},"awaiting_approval":{"type":"integer"}},"required":["total","succeeded","failed","partial","awaiting_approval"]}},"required":["ok","data","summary"]}}}},"400":{"description":"Missing since param.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/since-last-visit":{"get":{"summary":"Delta activity counts since `since` — homepage stat strip.","tags":["computed"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"since","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Activity delta counts.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"chainRuns":{"type":"integer"},"approvalsPending":{"type":"integer"},"agentRuns":{"type":"integer"},"newAssets":{"type":"integer"}},"required":["chainRuns","approvalsPending","agentRuns","newAssets"]}},"required":["ok","data"]}}}},"400":{"description":"Missing since param.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/calendar-timeline":{"get":{"summary":"5-lane dataset for CalendarTimeline widget (campaigns, chains, content, pivots, briefs).","tags":["computed"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brand_id","in":"query"},{"schema":{"type":"string"},"required":true,"name":"start","in":"query"},{"schema":{"type":"string"},"required":true,"name":"end","in":"query"}],"responses":{"200":{"description":"Calendar timeline lanes.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"campaigns":{"type":"array","items":{"type":"object","additionalProperties":{}}},"chains":{"type":"array","items":{"type":"object","additionalProperties":{}}},"content":{"type":"array","items":{"type":"object","additionalProperties":{}}},"pivots":{"type":"array","items":{"type":"object","additionalProperties":{}}},"briefs":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["campaigns","chains","content","pivots","briefs"]}},"required":["ok","data"]}}}},"400":{"description":"Invalid params.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/seo-portfolio":{"get":{"summary":"SEO keyword × page portfolio with GSC data. Returns empty shape when Search Console not connected.","tags":["computed"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brand_id","in":"query"},{"schema":{"type":"string","enum":["7d","28d","90d"]},"required":false,"name":"period","in":"query"}],"responses":{"200":{"description":"SEO portfolio data (or not-connected shape).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"rows":{"type":"array","items":{"type":"object","additionalProperties":{}}},"quickWins":{"type":"object","properties":{"ranking_4_15":{"type":"array","items":{"type":"object","additionalProperties":{}}},"decay_candidates":{"type":"array","items":{"type":"object","additionalProperties":{}}},"cluster_gaps":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["ranking_4_15","decay_candidates","cluster_gaps"]},"totals":{"type":"object","properties":{"clicks":{"type":"number"},"impressions":{"type":"number"},"indexed_pages":{"type":"number"}},"required":["clicks","impressions","indexed_pages"]}},"required":["connected","rows","quickWins","totals"]}}}},"400":{"description":"Missing brand_id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/business-events":{"get":{"summary":"List business events for the org.","tags":["business-events"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Business events list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/BusinessEvent"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Append a business event.","tags":["business-events"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BusinessEvent"},{"required":["entityType","entityId","eventType","actorType"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BusinessEvent"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/business-events/{id}":{"get":{"summary":"Get a business event.","tags":["business-events"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Business event row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/BusinessEvent"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/event-dispatches":{"get":{"summary":"List event dispatches for the org.","tags":["event-dispatches"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Event dispatches list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/EventDispatch"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an event dispatch.","tags":["event-dispatches"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/EventDispatch"},{"required":["eventId","handlerName"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/EventDispatch"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/event-dispatches/{id}":{"get":{"summary":"Get an event dispatch.","tags":["event-dispatches"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Event dispatch row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/EventDispatch"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an event dispatch (status, retry, result).","tags":["event-dispatches"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventDispatch"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/EventDispatch"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/integration-credentials":{"get":{"summary":"List caller's integration credentials (secrets masked).","description":"Optional ?brand_id= narrows to one brand's credentials; omitted lists across every brand visible to the caller.","tags":["integration-credentials"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"provider","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Credentials list (no secret fields).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/IntegrationCredential"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an integration credential (secrets accepted on write, never returned).","description":"brandId is required (2026-07-11) — credentials are per-brand; the brand must belong to the caller's org.","tags":["integration-credentials"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/IntegrationCredential"},{"required":["brandId","provider"]}]}}}},"responses":{"201":{"description":"Created (no secret fields in response).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/IntegrationCredential"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/integration-credentials/{id}":{"get":{"summary":"Get one integration credential (secrets masked).","tags":["integration-credentials"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Credential row (no secret fields).","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/IntegrationCredential"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an integration credential.","tags":["integration-credentials"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/integration-deliveries":{"get":{"summary":"List integration deliveries for the org.","tags":["integration-deliveries"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Deliveries list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/IntegrationDelivery"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an integration delivery record.","tags":["integration-deliveries"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/IntegrationDelivery"},{"required":["sourceEventType","eventId","status"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/IntegrationDelivery"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/integration-deliveries/{id}":{"get":{"summary":"Get an integration delivery.","tags":["integration-deliveries"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Delivery row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/IntegrationDelivery"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/marketing-event-subscriptions":{"get":{"summary":"List marketing event subscriptions for the org.","tags":["marketing-event-subscriptions"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Subscriptions list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/MarketingEventSubscription"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a marketing event subscription.","tags":["marketing-event-subscriptions"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/MarketingEventSubscription"},{"required":["integrationId","eventType","createdByUserId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MarketingEventSubscription"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/marketing-event-subscriptions/{id}":{"get":{"summary":"Get a marketing event subscription.","tags":["marketing-event-subscriptions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Subscription row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MarketingEventSubscription"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a marketing event subscription.","tags":["marketing-event-subscriptions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingEventSubscription"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/MarketingEventSubscription"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a marketing event subscription.","tags":["marketing-event-subscriptions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chat-messages":{"get":{"summary":"List chat messages for the org (filter by brand_id).","tags":["chat-messages"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Chat messages list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Append a chat message.","tags":["chat-messages"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ChatMessage"},{"required":["role","content"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChatMessage"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/chat-messages/{id}":{"get":{"summary":"Get a chat message.","tags":["chat-messages"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Chat message row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChatMessage"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/notifications":{"get":{"summary":"List caller's notifications for the org.","tags":["notifications"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Notifications list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a notification.","tags":["notifications"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Notification"},{"required":["kind"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Notification"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/notifications/{id}":{"get":{"summary":"Get a notification.","tags":["notifications"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Notification row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Notification"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/notifications/{id}/read":{"patch":{"summary":"Mark a notification as read.","tags":["notifications"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Updated notification with readAt set.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Notification"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/publish-logs":{"get":{"summary":"List publish logs for the org.","tags":["publish-logs"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Publish logs list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PublishLog"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a publish log entry.","tags":["publish-logs"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/PublishLog"},{"required":["platform","status"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PublishLog"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/publish-logs/{id}":{"get":{"summary":"Get a publish log.","tags":["publish-logs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Publish log row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/PublishLog"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-billing":{"get":{"summary":"List workspace billing rows for the org.","tags":["workspace-billing"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Billing rows list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WorkspaceBilling"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a workspace billing row (record usage).","tags":["workspace-billing"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceBilling"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceBilling"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/workspace-billing/{id}":{"get":{"summary":"Get a workspace billing row.","tags":["workspace-billing"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Billing row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/WorkspaceBilling"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/subscriptions":{"get":{"summary":"List subscriptions for the org.","tags":["subscriptions"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Subscriptions list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Subscription"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Upsert a subscription (webhook-written).","tags":["subscriptions"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Subscription"},{"required":["userId","stripeCustomerId","stripeSubscriptionId","status","planId","currentPeriodEnd"]}]}}}},"responses":{"201":{"description":"Created / updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Subscription"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/subscriptions/{id}":{"get":{"summary":"Get a subscription.","tags":["subscriptions"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Subscription row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Subscription"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/stripe-events":{"get":{"summary":"List Stripe events (idempotency log).","tags":["stripe-events"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Stripe events list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/StripeEvent"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Record a Stripe event (idempotent — duplicate ids ignored).","tags":["stripe-events"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StripeEvent"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StripeEvent"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/stripe-events/{id}":{"get":{"summary":"Get a Stripe event by Stripe event id.","tags":["stripe-events"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Stripe event row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/StripeEvent"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-todos":{"get":{"summary":"List user todos for the org.","tags":["user-todos"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Todos list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/UserTodo"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a user todo.","tags":["user-todos"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/UserTodo"},{"required":["userId","title","source"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UserTodo"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-todos/team":{"get":{"summary":"Admin-only cross-user todos listing for the org (manage_team permission).","tags":["user-todos"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Todos list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/UserTodo"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/user-todos/{id}":{"get":{"summary":"Get a user todo.","tags":["user-todos"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Todo row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UserTodo"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a user todo.","tags":["user-todos"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserTodo"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/UserTodo"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a user todo.","tags":["user-todos"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/paid-metrics":{"get":{"summary":"Aggregated paid hub metrics (spend/ROAS/CPA/pacing) from metrics_snapshots.","tags":["paid-metrics"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Paid metrics aggregate.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"spend":{"type":"object","properties":{"today":{"type":"number"},"week":{"type":"number"},"week_prior":{"type":"number"}},"required":["today","week","week_prior"]},"roas":{"type":"object","properties":{"value":{"type":["number","null"]},"by_provider":{"type":"object","additionalProperties":{"type":"number"}}},"required":["value","by_provider"]},"cpa":{"type":"object","properties":{"value":{"type":["number","null"]},"by_provider":{"type":"object","additionalProperties":{"type":"number"}}},"required":["value","by_provider"]},"pacing":{"type":"object","properties":{"monthly_budget":{"type":["number","null"]},"spent":{"type":"number"},"days_elapsed":{"type":"number"},"days_total":{"type":"number"},"status":{"type":"string","enum":["on_track","ahead","behind"]}},"required":["monthly_budget","spent","days_elapsed","days_total","status"]},"campaigns":{"type":"object","properties":{"active":{"type":"number"},"best":{},"worst":{}},"required":["active"]},"anomalies":{"type":"array","items":{}},"providers_connected":{"type":"array","items":{"type":"string"}},"as_of":{"type":"string"}},"required":["spend","roas","cpa","pacing","campaigns","anomalies","providers_connected","as_of"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-resolve":{"get":{"summary":"Resolve live KPI value for a hub_kpi_targets row.","tags":["kpi-resolve"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"KPI value (current/previous/delta/sparkline).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"current":{"type":["number","null"]},"previous":{"type":["number","null"]},"deltaPct":{"type":["number","null"]},"asOf":{"type":"string"},"source":{"type":"string","enum":["live","cached","unavailable"]},"implemented":{"type":"boolean"},"error":{"type":"string"},"sparkline":{"type":"array","items":{"type":"number"}}},"required":["current","previous","deltaPct","asOf","source","implemented"]}},"required":["ok","data"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/quarterly-actuals":{"get":{"summary":"Aggregate actuals (spent/leads/revenue/meetings) for a quarterly plan.","tags":["quarterly-actuals"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Quarterly actuals aggregate.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"spent":{"type":"number"},"leads":{"type":"number"},"revenue":{"type":"number"},"meetings":{"type":"number"},"hasData":{"type":"boolean"},"lastSyncedAt":{"type":["string","null"]}},"required":["spent","leads","revenue","meetings","hasData","lastSyncedAt"]}},"required":["ok","data"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/lineage":{"get":{"summary":"Return lineage/cascade tree for a root entity (plan|artifact|calendar_item).","tags":["lineage"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Lineage tree.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"type":{"type":"string"},"root":{},"parent":{},"children":{"type":"array","items":{}}},"required":["type","children"]}},"required":["ok","data"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/internal/event-dispatch-processor":{"post":{"summary":"Manually trigger the event-dispatch-processor job (CRON_SECRET-guarded).","tags":["internal"],"security":[{"cronSecret":[]}],"responses":{"200":{"description":"Processor completed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"claimed":{"type":"number"},"succeeded":{"type":"number"},"failed":{"type":"number"},"retried":{"type":"number"},"durationMs":{"type":"number"}},"required":["ok","claimed","succeeded","failed","retried","durationMs"]}}}},"401":{"description":"Unauthorized — wrong or missing x-cron-secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/internal/integration-delivery-worker":{"post":{"summary":"Manually trigger the integration-delivery-worker job (CRON_SECRET-guarded).","tags":["internal"],"security":[{"cronSecret":[]}],"responses":{"200":{"description":"Worker completed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"claimed":{"type":"number"},"sent":{"type":"number"},"skipped":{"type":"number"},"retried":{"type":"number"},"dead":{"type":"number"},"durationMs":{"type":"number"},"errors":{"type":"array","items":{"type":"string"}}},"required":["ok","claimed","sent","skipped","retried","dead","durationMs","errors"]}}}},"401":{"description":"Unauthorized — wrong or missing x-cron-secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/klaviyo/connect":{"post":{"summary":"Connect klaviyo — store API key.","tags":["integrations-klaviyo"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1,"example":"pk_live_..."}},"required":["api_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/klaviyo/status":{"get":{"summary":"Get klaviyo connection status (no secrets).","tags":["integrations-klaviyo"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/klaviyo/test":{"get":{"summary":"Test klaviyo credentials with a real API call.","tags":["integrations-klaviyo"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/klaviyo/sync":{"get":{"summary":"Pull latest data from klaviyo.","tags":["integrations-klaviyo"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/mailchimp/connect":{"post":{"summary":"Connect mailchimp — store API key.","tags":["integrations-mailchimp"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1,"example":"abc123-us12"}},"required":["api_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/mailchimp/status":{"get":{"summary":"Get mailchimp connection status (no secrets).","tags":["integrations-mailchimp"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/mailchimp/test":{"get":{"summary":"Test mailchimp credentials with a real API call.","tags":["integrations-mailchimp"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/mailchimp/sync":{"get":{"summary":"Pull latest data from mailchimp.","tags":["integrations-mailchimp"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/activecampaign/connect":{"post":{"summary":"Connect activecampaign — store API key.","tags":["integrations-activecampaign"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1},"api_url":{"type":"string","format":"uri","example":"https://youraccountname.api-us1.com"}},"required":["api_key","api_url"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/activecampaign/status":{"get":{"summary":"Get activecampaign connection status (no secrets).","tags":["integrations-activecampaign"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/activecampaign/test":{"get":{"summary":"Test activecampaign credentials with a real API call.","tags":["integrations-activecampaign"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/activecampaign/sync":{"get":{"summary":"Pull latest data from activecampaign.","tags":["integrations-activecampaign"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/beehiiv/connect":{"post":{"summary":"Connect beehiiv — store API key.","tags":["integrations-beehiiv"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1},"publication_id":{"type":"string","minLength":1,"example":"pub_abc123"}},"required":["api_key","publication_id"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/beehiiv/status":{"get":{"summary":"Get beehiiv connection status (no secrets).","tags":["integrations-beehiiv"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/beehiiv/test":{"get":{"summary":"Test beehiiv credentials with a real API call.","tags":["integrations-beehiiv"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/beehiiv/sync":{"get":{"summary":"Pull latest data from beehiiv.","tags":["integrations-beehiiv"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/twilio/connect":{"post":{"summary":"Connect twilio — store API key.","tags":["integrations-twilio"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"account_sid":{"type":"string","minLength":1,"example":"ACxxxxxxx"},"auth_token":{"type":"string","minLength":1},"from_number":{"type":"string","minLength":1,"example":"+15551234567"},"whatsapp_from_number":{"type":"string"}},"required":["account_sid","auth_token","from_number"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/twilio/status":{"get":{"summary":"Get twilio connection status (no secrets).","tags":["integrations-twilio"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/twilio/test":{"get":{"summary":"Test twilio credentials with a real API call.","tags":["integrations-twilio"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/twilio/sync":{"get":{"summary":"Pull latest data from twilio.","tags":["integrations-twilio"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/semrush/connect":{"post":{"summary":"Connect semrush — store API key.","tags":["integrations-semrush"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1},"domain":{"type":"string","example":"example.com"}},"required":["api_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/semrush/status":{"get":{"summary":"Get semrush connection status (no secrets).","tags":["integrations-semrush"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/semrush/test":{"get":{"summary":"Test semrush credentials with a real API call.","tags":["integrations-semrush"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/semrush/sync":{"get":{"summary":"Pull latest data from semrush.","tags":["integrations-semrush"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/shopify/connect":{"post":{"summary":"Connect shopify — store API key.","tags":["integrations-shopify"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"shop_domain":{"type":"string","minLength":1,"example":"mystore.myshopify.com"},"access_token":{"type":"string","minLength":1}},"required":["shop_domain","access_token"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/shopify/status":{"get":{"summary":"Get shopify connection status (no secrets).","tags":["integrations-shopify"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/shopify/test":{"get":{"summary":"Test shopify credentials with a real API call.","tags":["integrations-shopify"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/shopify/sync":{"get":{"summary":"Pull latest data from shopify.","tags":["integrations-shopify"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/stripe/connect":{"post":{"summary":"Connect stripe — store API key.","tags":["integrations-stripe"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"restricted_key":{"type":"string","minLength":1,"example":"rk_live_..."}},"required":["restricted_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/stripe/status":{"get":{"summary":"Get stripe connection status (no secrets).","tags":["integrations-stripe"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/stripe/test":{"get":{"summary":"Test stripe credentials with a real API call.","tags":["integrations-stripe"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/stripe/sync":{"get":{"summary":"Pull latest data from stripe.","tags":["integrations-stripe"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/canva/connect":{"post":{"summary":"Connect canva — store API key.","tags":["integrations-canva"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1}},"required":["api_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/canva/status":{"get":{"summary":"Get canva connection status (no secrets).","tags":["integrations-canva"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/canva/test":{"get":{"summary":"Test canva credentials with a real API call.","tags":["integrations-canva"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/canva/sync":{"get":{"summary":"Pull latest data from canva.","tags":["integrations-canva"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/motion/connect":{"post":{"summary":"Connect motion — store API key.","tags":["integrations-motion"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1}},"required":["api_key"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/motion/status":{"get":{"summary":"Get motion connection status (no secrets).","tags":["integrations-motion"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/motion/test":{"get":{"summary":"Test motion credentials with a real API call.","tags":["integrations-motion"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/motion/sync":{"get":{"summary":"Pull latest data from motion.","tags":["integrations-motion"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/posthog/connect":{"post":{"summary":"Connect posthog — store API key.","tags":["integrations-posthog"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_key":{"type":"string","minLength":1},"project_id":{"type":"string","minLength":1},"base_url":{"type":"string","format":"uri","example":"https://us.posthog.com"},"project_api_key":{"type":"string"}},"required":["api_key","project_id"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/posthog/status":{"get":{"summary":"Get posthog connection status (no secrets).","tags":["integrations-posthog"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/posthog/test":{"get":{"summary":"Test posthog credentials with a real API call.","tags":["integrations-posthog"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/posthog/sync":{"get":{"summary":"Pull latest data from posthog.","tags":["integrations-posthog"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/webflow/connect":{"post":{"summary":"Connect webflow — store API key.","tags":["integrations-webflow"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"api_token":{"type":"string","minLength":1},"site_id":{"type":"string"}},"required":["api_token"]}}}},"responses":{"201":{"description":"Connected.","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"provider":{"type":"string"}},"required":["connected","provider"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/webflow/status":{"get":{"summary":"Get webflow connection status (no secrets).","tags":["integrations-webflow"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string"},"connected":{"type":"boolean"},"status":{"type":["string","null"]},"lastSyncedAt":{"type":["string","null"]},"metadata":{"type":"object","additionalProperties":{}}},"required":["provider","connected","status","lastSyncedAt","metadata"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/webflow/test":{"get":{"summary":"Test webflow credentials with a real API call.","tags":["integrations-webflow"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Test result (may indicate not_connected or auth failure without throwing).","content":{"application/json":{"schema":{"type":"object","properties":{"connected":{"type":"boolean"},"success":{"type":"boolean"},"error":{"type":"string"},"message":{"type":"string"}},"required":["connected"],"additionalProperties":{}}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/webflow/sync":{"get":{"summary":"Pull latest data from webflow.","tags":["integrations-webflow"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Sync summary.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"provider":{"type":"string"}},"required":["success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/preview/providers":{"get":{"summary":"List integration providers that have a mock-preview sample.","tags":["integrations-preview"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Provider list.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"providers":{"type":"array","items":{"type":"string"}}},"required":["ok","providers"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/preview/{provider}":{"get":{"summary":"Fetch a realistic sample payload for one integration (always mock:true).","tags":["integrations-preview"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","example":"klaviyo"},"required":true,"name":"provider","in":"path"}],"responses":{"200":{"description":"Mock sample data.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"provider":{"type":"string"},"mock":{"type":"boolean","enum":[true]},"headline":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"value":{"type":"string"}},"required":["label","value"]}},"chart":{"type":"object","properties":{"label":{"type":"string"},"series":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"value":{"type":"number"}},"required":["name","value"]}}},"required":["label","series"]},"tableRows":{"type":"array","items":{"type":"object","additionalProperties":{}}},"signal":{"type":"object","additionalProperties":{}}},"required":["ok","provider","mock","headline"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"No mock available for this provider.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/query":{"post":{"summary":"Federated query — ask a natural-language marketing question, get a live answer.","description":"Wave 7 moat feature. Accepts a natural-language question, uses an LLM planner to map it to internal data sources (agent_runs, metrics_snapshots, campaigns, leads, attribution_records), executes org-scoped Drizzle aggregates (no ETL warehouse), and returns a rendered widget spec. The model never writes SQL — it selects from a safe source registry.","tags":["query"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"question":{"type":"string","minLength":1,"maxLength":1000,"example":"how many agent runs in the last 30 days, by agent?"},"brandId":{"type":"string","format":"uuid","example":"e3d1a2b3-..."}},"required":["question"]}}}},"responses":{"200":{"description":"Query answer with data rows, widget spec, sources used, and plan taken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FederatedQueryResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"validation_failed — invalid request body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/credentials-create":{"post":{"summary":"Store an API-key connector credential.","description":"Encrypts and stores the key + sensitive metadata via the connector-creds vault. Secrets are never echoed back.","tags":["credentials"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialCreateBody"}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"provider":{"type":"string"}},"required":["success","provider"]}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Failed to store credential.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/credentials-delete":{"post":{"summary":"Soft-revoke credential(s) by provider or credential_id.","tags":["credentials"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialDeleteBody"}}}},"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Credential not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/credentials-update-metadata":{"post":{"summary":"Update credential metadata, status, last_synced_at, or enabled.","tags":["credentials"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialUpdateMetadataBody"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}},"required":["success"]}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Credential not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/credentials-list":{"get":{"summary":"List integration credentials visible to the caller.","description":"Optional ?provider to filter to one provider, ?brand_id to filter to one brand. Secrets are never returned.","tags":["credentials"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string"},"required":false,"name":"provider","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Credential list.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CredentialsListResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/competitors/by-brand/{brandId}":{"delete":{"summary":"Bulk-delete all competitors for a brand.","description":"Verifies the brand belongs to the caller org before deleting. Returns 204 No Content.","tags":["competitors"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"brandId","in":"path"}],"responses":{"204":{"description":"Deleted (no content)."},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/projects/batch-delete":{"post":{"summary":"Bulk-delete projects by id list.","description":"Only deletes projects the org owns. Returns count of deleted rows.","tags":["projects"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"}}},"required":["ids"]}}}},"responses":{"200":{"description":"Bulk deletion acknowledged with count.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"deleted":{"type":"integer"}},"required":["ok","deleted"]}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/slack/post":{"post":{"summary":"Server-side Slack webhook proxy (keeps webhook URL off the browser).","description":"Looks up the stored Slack webhook and POSTs the message server-side. Degrades cleanly when Slack is not connected.","tags":["integrations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlackPostBody"}}}},"responses":{"200":{"description":"Message delivered to Slack.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlackPostResponse"}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Slack not connected or unauthorized.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"No access to brand.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/posthog":{"post":{"summary":"PostHog integration actions.","description":"Action-dispatch endpoint. Supported actions: test, sync, capture_event, create_feature_flag.","tags":["integrations"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationActionBody"}}}},"responses":{"200":{"description":"Provider-specific success response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationSuccessResponse"}}}},"400":{"description":"Validation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationErrorResponse"}}}},"401":{"description":"Unauthorized or provider not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationErrorResponse"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationErrorResponse"}}}},"429":{"description":"Rate limit exceeded.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationErrorResponse"}}}}}}},"/api/v1/checkout":{"post":{"summary":"Create a Stripe Checkout Session for platform billing.","description":"Public (no auth). Prospects call this from the pricing page to start a subscription checkout. Returns a Stripe-hosted checkout_url. On success, the Stripe webhook provisions the workspace automatically.","tags":["billing"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"plan_id":{"type":"string","enum":["operator","growth","enterprise","agency"]}},"required":["plan_id"]}}}},"responses":{"200":{"description":"Checkout session created.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"checkout_url":{"type":"string","format":"uri"},"session_id":{"type":["string","null"]}},"required":["checkout_url","session_id"]}},"required":["ok","data"]}}}},"422":{"description":"Validation error — invalid plan_id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Checkout not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/checkout/claim":{"post":{"summary":"Claim a pre-provisioned workspace after Stripe Checkout.","description":"Authenticated. Called by the frontend after the user signs up / logs in following a Stripe Checkout success. Exchanges the Stripe session_id for the provisioned workspace, links the authenticated user as the org owner + admin, and returns workspace_id + brand_id so the FE can set x-active-org.","tags":["billing"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"session_id":{"type":"string","minLength":1}},"required":["session_id"]}}}},"responses":{"200":{"description":"Workspace claimed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"workspaceId":{"type":"string","format":"uuid"},"brandId":{"type":["string","null"],"format":"uuid"}},"required":["workspaceId","brandId"]}},"required":["ok","data"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Session or workspace not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Could not reach Stripe.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/health/deep":{"get":{"summary":"Deep health check — DB ping + dependency key-presence.","description":"Public (no auth). Pings the database with SELECT 1 and reports whether key env-var secrets are present (no outbound calls). Returns 200 when healthy, 503 when the DB is down.","tags":["observability"],"responses":{"200":{"description":"Healthy. `deps` is only present when x-cron-secret matches CRON_SECRET.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["ok","degraded"]},"db":{"type":"string","enum":["ok","down"]},"uptimeSeconds":{"type":"integer"},"startedAt":{"type":"string","example":"2026-05-30T00:00:00.000Z"}},"required":["status","db","uptimeSeconds","startedAt"]}}}},"503":{"description":"Degraded — DB is unreachable.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["degraded"]},"db":{"type":"string","enum":["down"]},"uptimeSeconds":{"type":"integer"},"startedAt":{"type":"string"}},"required":["status","db","uptimeSeconds","startedAt"]}}}}}}},"/api/v1/internal/ops":{"get":{"summary":"Internal ops board — CRON_SECRET required (x-cron-secret header).","description":"Returns the live ops dashboard JSON: golden signals (RED counters from observabilityMiddleware), queue depths + lag (event_dispatches, integration_deliveries), AI telemetry (agent runs + token totals last 24h), and error counts. Not authenticated via Supabase JWT — requires x-cron-secret.","tags":["observability"],"responses":{"200":{"description":"Ops board payload.","content":{"application/json":{"schema":{"type":"object","properties":{"golden":{"type":"object","properties":{"totalRequests":{"type":"integer"},"errorRate":{"type":"number"},"topRoutes":{"type":"array","items":{"type":"object","properties":{"route":{"type":"string"},"count":{"type":"integer"},"errorCount":{"type":"integer"},"p50Ms":{"type":"integer"},"p95Ms":{"type":"integer"}},"required":["route","count","errorCount","p50Ms","p95Ms"]}}},"required":["totalRequests","errorRate","topRoutes"]},"queues":{"type":"object","properties":{"eventDispatches":{"type":"object","properties":{"queued":{"type":"integer"},"running":{"type":"integer"},"failed":{"type":"integer"},"deadLetterCount":{"type":"integer"},"oldestQueuedAgeSeconds":{"type":["integer","null"]}},"required":["queued","running","failed","deadLetterCount","oldestQueuedAgeSeconds"]},"integrationDeliveries":{"type":"object","properties":{"queued":{"type":"integer"},"running":{"type":"integer"},"failed":{"type":"integer"},"deadLetterCount":{"type":"integer"},"oldestQueuedAgeSeconds":{"type":["integer","null"]}},"required":["queued","running","failed","deadLetterCount","oldestQueuedAgeSeconds"]}},"required":["eventDispatches","integrationDeliveries"]},"ai":{"type":"object","properties":{"agentRunsLast24h":{"type":"integer"},"tokenTotalsLast24h":{"type":"object","properties":{"promptTokens":{"type":"integer"},"outputTokens":{"type":"integer"},"totalTokens":{"type":"integer"}},"required":["promptTokens","outputTokens","totalTokens"]},"topModels":{"type":"array","items":{"type":"object","properties":{"model":{"type":"string"},"count":{"type":"integer"}},"required":["model","count"]}}},"required":["agentRunsLast24h","tokenTotalsLast24h","topModels"]},"errors":{"type":"object","properties":{"serverErrorCount":{"type":"integer"}},"required":["serverErrorCount"]},"generatedAt":{"type":"string"}},"required":["golden","queues","ai","errors","generatedAt"]}}}},"401":{"description":"unauthorized — missing or invalid x-cron-secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/content/post/generate":{"post":{"summary":"Generate a single on-brand social post for a channel.","tags":["content"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"topic":{"type":"string","minLength":2,"maxLength":300},"channel":{"type":"string","enum":["instagram","linkedin","x","facebook","tiktok"]}},"required":["brand_id","topic"]}}}},"responses":{"200":{"description":"Generated post with hook, body, hashtags, CTA, visual brief, and quality score.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"hook":{"type":"string"},"body":{"type":"string"},"hashtags":{"type":"array","items":{"type":"string"}},"cta":{"type":"string"},"visualBrief":{"type":"string"},"score":{"type":"number"},"verdict":{"type":"string","enum":["strong","needs_work","weak"]},"issues":{"type":"array","items":{"type":"string"}}},"required":["hook","body","hashtags","cta","score","verdict","issues"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"LLM service unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/content/calendar/generate":{"post":{"summary":"Generate a synchronous N-day content calendar plan (post seeds).","description":"Runs the LLM calendar build synchronously. Prefer /calendar/generate-async for 30-day plans to avoid the 26s timeout.","tags":["content"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"days":{"type":"integer","minimum":7,"maximum":31},"channels":{"type":"array","items":{"type":"string","enum":["instagram","linkedin","x","facebook","tiktok"]},"maxItems":5},"themes":{"type":"string","maxLength":2000},"posts_per_week":{"type":"integer","minimum":1,"maximum":14}},"required":["brand_id"]}}}},"responses":{"200":{"description":"Calendar plan with post seeds (title, channel, day, angle, visual brief).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"days":{"type":"integer"},"count":{"type":"integer"},"plan":{"type":"array","items":{"type":"object","properties":{"day":{"type":"integer"},"title":{"type":"string"},"channel":{"type":"string"},"angle":{"type":"string"},"visualBrief":{"type":"string"}},"required":["day","title","channel"]}}},"required":["days","count","plan"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"LLM service unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/content/calendar/generate-async":{"post":{"summary":"Async 30-day calendar generation — returns 202 immediately, writes AI drafts in the background.","description":"Brain-gate: if the brand has no promise/ICP, returns needsSetup=true with a setupRoute. Otherwise dispatches to a Netlify background function (15-min cap) that generates the plan and writes each post to content_calendar as ai_draft rows.","tags":["content"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"days":{"type":"integer","minimum":7,"maximum":31},"channels":{"type":"array","items":{"type":"string","enum":["instagram","linkedin","x","facebook","tiktok"]},"maxItems":5},"themes":{"type":"string","maxLength":2000},"posts_per_week":{"type":"integer","minimum":1,"maximum":14}},"required":["brand_id"]}}}},"responses":{"202":{"description":"Generation dispatched. Or needsSetup=true if brand profile is incomplete.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"anyOf":[{"type":"object","properties":{"started":{"type":"boolean","enum":[true]},"brandId":{"type":"string","format":"uuid"},"days":{"type":"integer"},"agentRunId":{"type":"string","format":"uuid"}},"required":["started","brandId","days","agentRunId"]},{"type":"object","properties":{"needsSetup":{"type":"boolean","enum":[true]},"missing":{"type":"array","items":{"type":"string"}},"message":{"type":"string"},"setupRoute":{"type":"string"}},"required":["needsSetup","missing","message","setupRoute"]}]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Could not dispatch background job.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/content/channels":{"get":{"summary":"List supported social channels for content generation.","tags":["content"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Supported channel identifiers.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"channels":{"type":"array","items":{"type":"string"}}},"required":["channels"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/content/write-drafts":{"post":{"summary":"Write full post copy for angle-only content calendar drafts (D-033).","description":"Single-item mode (brand_id + item_id): synchronously generates full copy for that one ai_draft row and returns the updated row. Batch mode (brand_id only): dispatches to a background function (15-min cap, ~3 LLM calls at a time) and returns 202 + agent_run_id to poll. \"Angle-only\" = rows where content is null/empty or equals the one-liner angle stored as the first segment of notes (set by the calendar generator).","tags":["content"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"item_id":{"type":"string","format":"uuid","description":"Omit for full-brand batch dispatch (async)."}},"required":["brand_id"]}}}},"responses":{"200":{"description":"Single-item mode: updated calendar row with full copy.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{}},"required":["ok"]}}}},"202":{"description":"Batch mode: generation dispatched.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"data":{"type":"object","properties":{"started":{"type":"boolean","enum":[true]},"brandId":{"type":"string","format":"uuid"},"agentRunId":{"type":"string","format":"uuid"}},"required":["started","brandId","agentRunId"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand or item not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Copy generation failed or background dispatch failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/strategies":{"get":{"summary":"List strategies for the org.","tags":["strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Strategies list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Strategy"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a strategy.","tags":["strategies"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Strategy"},{"required":["brandId"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Strategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/strategies/{id}":{"get":{"summary":"Get a strategy.","tags":["strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Strategy row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Strategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a strategy.","tags":["strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Strategy"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Strategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a strategy.","tags":["strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/funnel-stages":{"get":{"summary":"List funnel stages for the org.","tags":["funnel-stages"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Funnel stages list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/FunnelStage"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a funnel stage.","tags":["funnel-stages"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/FunnelStage"},{"required":["brandId","stageKey"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FunnelStage"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/funnel-stages/{id}":{"get":{"summary":"Get a funnel stage.","tags":["funnel-stages"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Funnel stage row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FunnelStage"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a funnel stage.","tags":["funnel-stages"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FunnelStage"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/FunnelStage"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a funnel stage.","tags":["funnel-stages"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-defs":{"get":{"summary":"List KPI defs for the org.","tags":["kpi-defs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"KPI defs list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/KpiDef"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a KPI def.","tags":["kpi-defs"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/KpiDef"},{"required":["brandId","metric"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/kpi-defs/{id}":{"get":{"summary":"Get a KPI def.","tags":["kpi-defs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"KPI def row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a KPI def.","tags":["kpi-defs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KpiDef"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/KpiDef"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a KPI def.","tags":["kpi-defs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/channel-strategies":{"get":{"summary":"List channel strategies for the org.","tags":["channel-strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Channel strategies list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ChannelStrategy"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a channel strategy.","tags":["channel-strategies"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ChannelStrategy"},{"required":["brandId","channel"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChannelStrategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/channel-strategies/{id}":{"get":{"summary":"Get a channel strategy.","tags":["channel-strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Channel strategy row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChannelStrategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a channel strategy.","tags":["channel-strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelStrategy"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ChannelStrategy"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a channel strategy.","tags":["channel-strategies"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/tactics":{"get":{"summary":"List tactics for the org.","tags":["tactics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Tactics list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Tactic"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a tactic.","tags":["tactics"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Tactic"},{"required":["brandId","title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Tactic"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/tactics/{id}":{"get":{"summary":"Get a tactic.","tags":["tactics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Tactic row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Tactic"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a tactic.","tags":["tactics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Tactic"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Tactic"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a tactic.","tags":["tactics"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/cascade/seed-funnel-stages":{"post":{"summary":"Seed the 5 standard funnel-first stages + key-conversion KPIs for a strategy (deterministic, idempotent).","tags":["cascade"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"strategy_id":{"type":"string","format":"uuid"}},"required":["strategy_id"]}}}},"responses":{"201":{"description":"Seeded (or already present — idempotent).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"strategy_id":{"type":"string","format":"uuid"},"stages":{"type":"array","items":{"$ref":"#/components/schemas/FunnelStage"}},"kpis":{"type":"array","items":{"$ref":"#/components/schemas/KpiDef"}},"created_count":{"type":"number"}},"required":["ok","success","strategy_id","stages","kpis","created_count"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/cascade/draft-channel-strategies":{"post":{"summary":"AI-draft channel strategies for a strategy's funnel stages × channels (status=draft, human-approval required). Degrades to 202 on LLM failure, never 500s.","tags":["cascade"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"strategy_id":{"type":"string","format":"uuid"},"channels":{"type":"array","items":{"type":"string","minLength":1},"maxItems":8},"funnel_stage_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":10}},"required":["strategy_id"]}}}},"responses":{"202":{"description":"Drafted (or degraded — see `degraded` flag on LLM failure).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"strategy_id":{"type":"string","format":"uuid"},"drafted":{"type":"array","items":{"$ref":"#/components/schemas/ChannelStrategy"}},"drafted_count":{"type":"number"},"degraded":{"type":"boolean"},"message":{"type":"string"}},"required":["ok","success","strategy_id","drafted","drafted_count"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Strategy not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"No funnel stages found for this strategy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/insights":{"get":{"summary":"List insights for the org (filter by ?brand_id/?status/?channel).","tags":["insights"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"},{"schema":{"type":"string","enum":["new","read","actioned","dismissed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"}],"responses":{"200":{"description":"Insights list.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Insight"}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an insight (generator/internal use).","tags":["insights"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Insight"},{"required":["brandId","title"]}]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Insight"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/insights/unread-count":{"get":{"summary":"Count of unread (status=new) insights.","tags":["insights"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"}],"responses":{"200":{"description":"Unread count.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"unread":{"type":"number"}},"required":["unread"]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/insights/{id}":{"get":{"summary":"Get an insight.","tags":["insights"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Insight row.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Insight"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Set an insight's status (read|actioned|dismissed).","tags":["insights"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","enum":["read","actioned","dismissed"]}},"required":["status"]}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/Insight"}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an insight.","tags":["insights"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"}},"required":["ok"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/insights/mark-all-read":{"post":{"summary":"Mark all 'new' insights (optionally scoped to a brand) as 'read'.","tags":["insights"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brandId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Updated count.","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","properties":{"updated":{"type":"number"}},"required":["updated"]}},"required":["data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/insights/generate":{"post":{"summary":"AI-generate 3-6 actionable insights for a brand from recent signals + agent activity (deduped against open insights). Degrades to 202 on LLM failure, never 500s.","tags":["insights"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"channel":{"type":"string"}},"required":["brand_id"]}}}},"responses":{"202":{"description":"Generated (or degraded — see `degraded` flag on LLM failure).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"brand_id":{"type":"string","format":"uuid"},"insights":{"type":"array","items":{"$ref":"#/components/schemas/Insight"}},"generated_count":{"type":"number"},"degraded":{"type":"boolean"},"message":{"type":"string"}},"required":["ok","success","brand_id","insights","generated_count"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/notion":{"post":{"summary":"Push a page into Notion (uses the stored OAuth token + configured parent page/database).","tags":["integrations-notion"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["push_page"]},"title":{"type":"string","minLength":1},"content":{"type":"string","default":""},"parent_page_id":{"type":"string","minLength":1}},"required":["action","title"]}}}},"responses":{"200":{"description":"Pushed.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["notion"]},"page_id":{},"url":{"type":["string","null"]}},"required":["ok","success","provider","url"]}}}},"400":{"description":"Notion not connected or missing destination.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/r2-upload":{"post":{"summary":"Presign a direct-to-storage PUT URL for content media (images/video).","tags":["integrations-r2-upload"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"filename":{"type":"string","minLength":1,"maxLength":255},"contentType":{"type":"string"},"brandId":{"type":"string","format":"uuid"}},"required":["filename","contentType","brandId"]}}}},"responses":{"200":{"description":"Presigned.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"uploadUrl":{"type":"string"},"publicUrl":{"type":"string"},"bucket":{"type":"string"},"key":{"type":"string"}},"required":["ok","uploadUrl","publicUrl","bucket","key"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Storage not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/google-ads":{"post":{"summary":"Create a PAUSED Google Ads campaign (budget + campaign, manual-CPC).","tags":["integrations-google-ads"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["create_campaign"]},"name":{"type":"string","minLength":1},"daily_budget_micros":{"type":"integer","exclusiveMinimum":0},"advertising_channel_type":{"type":"string","minLength":1,"default":"SEARCH"},"customer_id":{"type":"string"}},"required":["action","name","daily_budget_micros"]}}}},"responses":{"200":{"description":"Campaign created (PAUSED).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["google_ads"]},"resource_name":{"type":["string","null"]},"status":{"type":"string","enum":["PAUSED"]}},"required":["ok","success","provider","resource_name","status"]}}}},"400":{"description":"Not connected or missing customer_id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Google Ads API error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"GOOGLE_ADS_DEVELOPER_TOKEN not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/meta-ads":{"post":{"summary":"Create a PAUSED Meta (Facebook) Ads campaign.","tags":["integrations-meta-ads"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["create_campaign"]},"ad_account_id":{"type":"string"},"name":{"type":"string","minLength":1},"objective":{"type":"string","minLength":1,"default":"OUTCOME_TRAFFIC"},"daily_budget":{"type":"integer","exclusiveMinimum":0},"special_ad_categories":{"type":"array","items":{"type":"string"},"default":[]}},"required":["action","ad_account_id","name","daily_budget"]}}}},"responses":{"200":{"description":"Campaign created (PAUSED).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["meta_ads"]},"id":{},"status":{"type":"string","enum":["PAUSED"]}},"required":["ok","success","provider","status"]}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"Meta Graph API error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/tiktok-ads":{"post":{"summary":"Create a disabled TikTok Ads campaign.","tags":["integrations-tiktok-ads"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["create_campaign"]},"advertiser_id":{"type":"string","minLength":1},"campaign_name":{"type":"string","minLength":1},"objective_type":{"type":"string","minLength":1,"default":"TRAFFIC"},"budget_mode":{"type":"string","minLength":1,"default":"BUDGET_MODE_DAY"},"budget":{"type":"number","exclusiveMinimum":0}},"required":["action","advertiser_id","campaign_name","budget"]}}}},"responses":{"200":{"description":"Campaign created (disabled).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["tiktok_ads"]},"campaign_id":{}},"required":["ok","success","provider"],"additionalProperties":{}}}}},"400":{"description":"Not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"502":{"description":"TikTok API error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/organic/generate":{"post":{"summary":"Generate an AEO-first article for a topic (Write+QA stage) and auto-score it.","tags":["organic"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"topic":{"type":"string","minLength":2,"maxLength":200}},"required":["brand_id","topic"]}}}},"responses":{"200":{"description":"Draft + content score.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"topic":{"type":"string"},"draft":{"type":"string"},"score":{"type":"number"},"verdict":{"type":"string","enum":["strong","needs_work","weak"]},"issues":{"type":"array","items":{"type":"string"}},"dimensions":{"type":"object","additionalProperties":{}}},"required":["topic","draft","score","verdict","issues","dimensions"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Generation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/creative/email/generate/generate":{"post":{"summary":"Generate an email-safe HTML artifact (subject/preheader/html) and auto-score it.","tags":["creative-email"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"brief":{"type":"string","minLength":4,"maxLength":4000},"reference_html":{"type":"string","maxLength":60000}},"required":["brand_id","brief"]}}}},"responses":{"200":{"description":"Email artifact + score.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","additionalProperties":{}}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Email generation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/creative/email/generate/fill":{"post":{"summary":"Fill a frontend email-builder template's structured content on-brand + score it.","tags":["creative-email"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"template_slug":{"type":"string","minLength":2,"maxLength":80},"template_name":{"type":"string","maxLength":120},"shape":{"type":"object","additionalProperties":{}},"brief":{"type":"string","minLength":4,"maxLength":4000}},"required":["brand_id","template_slug","shape","brief"]}}}},"responses":{"200":{"description":"Filled template content + score.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"template_slug":{"type":"string"},"content":{},"score":{"type":"number"},"verdict":{"type":"string"},"issues":{"type":"array","items":{"type":"string"}}},"required":["template_slug","score","verdict","issues"]}},"required":["ok","data"]}}}},"400":{"description":"shape must be the template default-data object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Email generation failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/creative/image/generate":{"post":{"summary":"Generate an on-brand ad-creative image (gpt-image-1) and optionally save it into the Creative gallery.","tags":["creative-image"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"brief":{"type":"string","minLength":4,"maxLength":4000},"headline":{"type":"string","maxLength":200},"cta":{"type":"string","maxLength":120},"placement":{"type":"string","enum":["square","portrait","landscape"]},"campaign_id":{"type":"string","format":"uuid"},"save":{"type":"boolean"}},"required":["brand_id","brief"]}}}},"responses":{"200":{"description":"Generated image.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"url":{"type":"string"},"stored":{"type":"boolean"},"size":{"type":"string"},"prompt":{"type":"string"},"creative_item_id":{"type":"string","format":"uuid"}},"required":["url","size","prompt"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Image generation not configured or failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/social/connect-session":{"post":{"summary":"Mint a Nango Connect session token for the frontend OAuth UI.","tags":["integrations-social"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"integrations":{"type":"array","items":{"type":"string","minLength":1},"maxItems":10}}}}}},"responses":{"200":{"description":"Connect token.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Connector platform not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/social/connections":{"get":{"summary":"List which social networks this org has connected (via Nango).","tags":["integrations-social"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"Connections.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"connections":{"type":"array","items":{}}},"required":["connections"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/social/publish":{"post":{"summary":"Publish a post now to a connected social network (manual/test).","tags":["integrations-social"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"provider":{"type":"string","enum":["linkedin","x","facebook","instagram","tiktok"]},"text":{"type":"string","minLength":1,"maxLength":8000}},"required":["provider","text"]}}}},"responses":{"200":{"description":"Published.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","additionalProperties":{}}},"required":["ok","data"]}}}},"400":{"description":"Publish failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/social-scheduler":{"post":{"summary":"Cron worker — publishes due scheduled posts to their networks (x-cron-secret guarded).","tags":["internal"],"security":[{"cronSecret":[]}],"responses":{"200":{"description":"Run summary.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"],"additionalProperties":{}}}}},"401":{"description":"Unauthorized — wrong or missing x-cron-secret.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/agents/web-search":{"post":{"summary":"Proxy a query to the web-search provider (Brave), normalized. Never errors — degrades to success:false.","tags":["agents"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"query":{"type":"string","minLength":1,"maxLength":400},"count":{"type":"integer","exclusiveMinimum":0,"maximum":20}},"required":["query"]}}}},"responses":{"200":{"description":"Results (or success:false if unconfigured/failed).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean"},"error":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"url":{"type":"string"},"description":{"type":"string"}},"required":["title","url","description"]}}},"required":["ok","success","results"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/ga4-metrics":{"get":{"summary":"Tenant's own GA4 traffic (last 28d default) + derived signals. Best-effort — never 500s on upstream/auth failure.","tags":["data"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\d{4,20}$"},"required":true,"name":"property_id","in":"query"},{"schema":{"type":"string"},"required":false,"name":"start_date","in":"query"},{"schema":{"type":"string"},"required":false,"name":"end_date","in":"query"}],"responses":{"200":{"description":"GA4 report + signals.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"connected":{"type":"boolean"},"property_id":{"type":"string"},"rows":{"type":"array","items":{}},"signals":{"type":"array","items":{}}},"required":["connected","property_id","rows","signals"]}},"required":["ok","data"]}}}},"400":{"description":"Invalid query parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/ga4-properties":{"get":{"summary":"List GA4 properties the tenant's connected Google account can access. Best-effort — degrades to connected:false.","tags":["data"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"GA4 properties.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"connected":{"type":"boolean"},"properties":{"type":"array","items":{}}},"required":["connected","properties"]}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/signal-stream":{"get":{"summary":"The ranked, cross-connector signal feed (GA4 + Search Console today). Best-effort — unconfigured sources contribute nothing, never 500s.","tags":["data"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","pattern":"^\\d{4,20}$"},"required":false,"name":"ga4_property_id","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":2048},"required":false,"name":"gsc_site_url","in":"query"}],"responses":{"200":{"description":"Signal stream.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"count":{"type":"number"},"critical":{"type":"number"},"signals":{"type":"array","items":{}}},"required":["count","critical","signals"]}},"required":["ok","data"]}}}},"400":{"description":"Invalid query parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/metrics-list":{"post":{"summary":"Filtered metrics-snapshots list in the legacy { metrics } shape (org-scoped; no brand_id = all org brands).","tags":["data"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"source":{"type":"string"},"limit":{"type":"integer","exclusiveMinimum":0,"maximum":500}}}}}},"responses":{"200":{"description":"Metrics snapshots.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"metrics":{"type":"array","items":{}}},"required":["ok","metrics"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/copilot/chat":{"post":{"summary":"CMO Co-pilot conversational orchestrator (brand-brain chat + specialist agents as tools).","tags":["copilot"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"brand_id":{"type":"string","format":"uuid"},"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string","minLength":1}},"required":["role","content"]},"minItems":1,"maxItems":40}},"required":["brand_id","messages"]}}}},"responses":{"200":{"description":"Assistant reply + any specialist deliverables.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"type":"object","additionalProperties":{}}},"required":["ok","data"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Brand not found or not in your organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"503":{"description":"Co-pilot service error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/klaviyo":{"post":{"summary":"klaviyo root action-dispatch — currently supports action:'test' (frontend verifies a saved credential by POSTing here).","tags":["integrations-klaviyo"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["test"]}}}}}},"responses":{"200":{"description":"Action result.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"],"additionalProperties":{}}}}},"400":{"description":"Unknown action.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/mailchimp":{"post":{"summary":"mailchimp root action-dispatch — currently supports action:'test' (frontend verifies a saved credential by POSTing here).","tags":["integrations-mailchimp"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["test"]}}}}}},"responses":{"200":{"description":"Action result.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"],"additionalProperties":{}}}}},"400":{"description":"Unknown action.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/activecampaign":{"post":{"summary":"activecampaign root action-dispatch — currently supports action:'test' (frontend verifies a saved credential by POSTing here).","tags":["integrations-activecampaign"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["test"]}}}}}},"responses":{"200":{"description":"Action result.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"],"additionalProperties":{}}}}},"400":{"description":"Unknown action.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/beehiiv":{"post":{"summary":"beehiiv root action-dispatch — currently supports action:'test' (frontend verifies a saved credential by POSTing here).","tags":["integrations-beehiiv"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["test"]}}}}}},"responses":{"200":{"description":"Action result.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"],"additionalProperties":{}}}}},"400":{"description":"Unknown action.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/shopify":{"post":{"summary":"Shopify root action-dispatch — action:create_discount_code (real Shopify price-rule + discount code).","tags":["integrations-shopify"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["create_discount_code"]},"code":{"type":"string","minLength":1},"value_type":{"type":"string","enum":["percentage","fixed_amount"]},"value":{"type":"number","exclusiveMinimum":0},"usage_limit":{"type":"integer","exclusiveMinimum":0},"ends_at":{"type":"string","minLength":1}},"required":["action","code","value"]}}}},"responses":{"201":{"description":"Discount code created.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["shopify"]}},"required":["ok","success","provider"],"additionalProperties":{}}}}},"400":{"description":"Shopify not connected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/integrations/stripe":{"post":{"summary":"Stripe root action-dispatch — action:create_coupon (tenant's restricted key, not platform billing).","tags":["integrations-stripe"],"security":[{"bearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string","enum":["create_coupon"]},"id":{"type":"string","minLength":1},"duration":{"type":"string","enum":["once","repeating","forever"]},"percent_off":{"type":"number","exclusiveMinimum":0,"maximum":100},"amount_off":{"type":"integer","exclusiveMinimum":0},"currency":{"type":"string","minLength":1}},"required":["action","id"]}}}},"responses":{"201":{"description":"Coupon created.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"success":{"type":"boolean","enum":[true]},"provider":{"type":"string","enum":["stripe"]},"id":{"type":"string"}},"required":["ok","success","provider","id"]}}}},"400":{"description":"Stripe not connected or missing percent_off/amount_off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/api/v1/data/agent-runs/count":{"get":{"summary":"Count agent runs for the org (optionally scoped to a brand and/or a ?from/?since timestamp).","tags":["agent-runs"],"security":[{"bearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"brand_id","in":"query"},{"schema":{"type":"string"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string"},"required":false,"name":"since","in":"query"}],"responses":{"200":{"description":"Count.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"count":{"type":"number"}},"required":["ok","count"]}}}},"401":{"description":"unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"webhooks":{}}