{"openapi":"3.1.0","info":{"title":"WizBI Core API","version":"0.1.0","description":"Generated from the route definitions. This document is never edited by hand."},"tags":[{"name":"ops","description":"Health, manifest and runtime facts."},{"name":"auth","description":"Sign-in: the e-mail one-time code (public, rate-limited)."},{"name":"me","description":"The signed-in principal."},{"name":"orgs","description":"Organizations."},{"name":"people","description":"Members and invitations."},{"name":"invites","description":"Personal invitations and JOIN codes."},{"name":"groups","description":"Groups: the unit of permission and sharing."},{"name":"policy","description":"The access policy: compile once, enforce mechanically."},{"name":"tokens","description":"wz_ API tokens."},{"name":"oauth","description":"OAuth 2.1 for MCP clients."},{"name":"connectors","description":"Connect & Forget: sources, schema, sync."},{"name":"channels","description":"Channel bindings and rooms."},{"name":"chat","description":"The web channel (SSE) and its threads."},{"name":"reports","description":"Scheduled reports and alerts (ADR-0029)."},{"name":"activity","description":"Turns, denials, audit and usage."},{"name":"credits","description":"The organization’s credits for its admins (ADR-0043): balance, breakdown, budgets, caps — credit quantities only, each component behind a platform switch."},{"name":"webhooks","description":"Provider webhooks (transport auth inside)."},{"name":"admin","description":"Platform administration (super_admin)."},{"name":"agents","description":"The agent registry: personas, layers, routing."},{"name":"features","description":"Feature flags per organization."},{"name":"catalog","description":"Modules (connectors, channels, agents, capabilities) and their switches (ADR-0031)."},{"name":"security","description":"Consent, second factor, sessions, org security and AI disclosure."},{"name":"sso","description":"Enterprise SSO (SAML/OIDC per org) and SCIM administration."},{"name":"knowledge","description":"Versioned knowledge items: one write path, approval matrix, history (ADR-0037)."},{"name":"data","description":"Data rights (ADR-0059): exports and erasure of a person, export and offboarding of an organization, legal holds, deletion certificates."},{"name":"learning","description":"The learning loop: harvested candidates to review, issues, internal testers (ADR-0037 §9)."},{"name":"library","description":"The public data library (ADR-0061): the catalog, an item’s advanced details, attach and detach of an item, the platform sync."}],"components":{"schemas":{"Health":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"service":{"type":"string"},"version":{"type":"string"},"env":{"type":"string"},"region":{"type":"string"},"revision":{"type":"string"},"time":{"type":"string"}},"required":["ok","service","version","env","region","time"]},"Meta":{"type":"object","properties":{"runtime":{"type":"object","properties":{"version":{"type":"string"},"env":{"type":"string"},"mcp":{"type":"string","enum":["enabled","disabled"]},"build":{"type":"string"}},"required":["version","env","mcp"]}},"required":["runtime"]},"MonitoringHookResult":{"type":"object","properties":{"routed":{"type":"string"},"channel":{"type":"string"},"kind":{"type":"string"}},"required":["routed","channel","kind"]},"PubSubPush":{"type":"object","properties":{"message":{"type":"object","properties":{"data":{"type":"string"},"messageId":{"type":"string"},"publishTime":{"type":"string"},"attributes":{"type":"object","additionalProperties":{"type":"string"}}}},"subscription":{"type":"string"}},"required":["message"]},"Error":{"type":"object","properties":{"code":{"type":"string","description":"Catalog error code (always present)."},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]},"description":"Interpolation values for the translation (always present)."},"traceId":{"type":"string"},"error":{"type":"string","description":"Same as `code` (deprecated)."},"message":{"type":"string","description":"Developer detail; not sent in prod."},"details":{"type":"object","additionalProperties":{"nullable":true}}},"required":["traceId","error"]},"OAuthGrant":{"type":"object","properties":{"id":{"type":"string"},"clientId":{"type":"string"},"clientName":{"type":"string"},"principalId":{"type":"string"},"orgId":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}},"extraScopes":{"type":"array","items":{"type":"string"}},"resource":{"type":"string"},"surface":{"type":"string"},"createdAt":{"type":"string"},"lastUsedAt":{"type":"string"},"refreshExpiresAt":{"type":"string"},"revokedAt":{"type":"string"},"revokedReason":{"type":"string"},"active":{"type":"boolean"}},"required":["id","clientId","principalId","orgId","scopes","extraScopes","resource","surface","createdAt","refreshExpiresAt","active"]},"OAuthClient":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"clientId":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"tokenEndpointAuthMethod":{"type":"string"},"createdAt":{"type":"string"},"createdBy":{"type":"string"}},"required":["id","name","clientId","redirectUris","tokenEndpointAuthMethod","createdAt"]},"CreateOAuthClientBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"redirectUris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"maxItems":20},"tokenEndpointAuthMethod":{"type":"string","enum":["none","client_secret_post","client_secret_basic"],"default":"none"}},"required":["name","redirectUris"]},"AuthCodeStartResponse":{"type":"object","properties":{"method":{"type":"string","enum":["email","phone","sso","methods"]},"providerId":{"type":"string"},"protocol":{"type":"string","enum":["saml","oidc"]},"preset":{"type":"string","enum":["entra","google_workspace","oidc","saml"]},"required":{"type":"boolean"},"allowed":{"type":"array","items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]}}},"required":["method"]},"AuthCodeStartBody":{"type":"object","properties":{"identifier":{"type":"string","minLength":3,"maxLength":320},"lang":{"type":"string","enum":["he","en","pt"]},"preferCode":{"type":"boolean"}},"required":["identifier"]},"AuthCodeVerifyResponse":{"type":"object","properties":{"customToken":{"type":"string"}},"required":["customToken"]},"AuthCodeVerifyBody":{"type":"object","properties":{"identifier":{"type":"string","minLength":3,"maxLength":320},"code":{"type":"string","minLength":6,"maxLength":8}},"required":["identifier","code"]},"AuthLinkStartResponse":{"type":"object","properties":{"method":{"type":"string","enum":["email"]},"email":{"type":"string"}},"required":["method","email"]},"AuthLinkStartBody":{"type":"object","properties":{"email":{"type":"string","minLength":3,"maxLength":320},"lang":{"type":"string","enum":["he","en","pt"]}}},"AuthLinkVerifyResponse":{"type":"object","properties":{"linked":{"type":"boolean","enum":[true]},"email":{"type":"string"}},"required":["linked","email"]},"AuthLinkVerifyBody":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":8}},"required":["code"]},"AuthBlockingRequest":{"type":"object","properties":{"data":{"type":"object","properties":{"jwt":{"type":"string"}},"required":["jwt"]}},"required":["data"]},"JobRunResult":{"type":"object","properties":{"status":{"type":"string","enum":["done","duplicate","busy","retry","dead"]},"runId":{"type":"string"},"attempt":{"type":"integer"},"outcome":{"type":"string"},"error":{"type":"string"}},"required":["status","runId"]},"JobEnvelope":{"type":"object","properties":{"kind":{"type":"string","pattern":"^[a-z][a-z0-9-]*(?:\\.[a-z][a-z0-9-]*)+$"},"key":{"type":"string","minLength":1,"maxLength":512},"payload":{"nullable":true},"orgId":{"type":"string","maxLength":128},"traceId":{"type":"string","maxLength":64},"enqueuedAt":{"type":"string"},"scheduled":{"type":"object","properties":{"jobId":{"type":"string"},"slot":{"type":"string"}},"required":["jobId","slot"]}},"required":["kind","key","enqueuedAt"]},"JobsTickResult":{"type":"object","properties":{"scheduler":{"type":"object","additionalProperties":{"type":"number"}},"maintenance":{"type":"object","additionalProperties":{"nullable":true}},"ms":{"type":"number"}},"required":["scheduler","maintenance","ms"]},"Me":{"type":"object","properties":{"principal":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["person","agent","room","service"]},"status":{"type":"string","enum":["active","pending","suspended"],"default":"active"},"displayName":{"type":"string","minLength":1,"maxLength":200},"phone":{"type":"string","pattern":"^\\+[1-9]\\d{6,14}$"},"email":{"type":"string","format":"email"},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"primaryOrgId":{"type":"string","minLength":1,"maxLength":128},"superAdmin":{"type":"boolean","default":false},"aliases":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string","enum":["firebase","phone","email","google","microsoft","slack","telegram","whatsapp","lid","api","channel","wa_bsuid"]},"externalId":{"type":"string","minLength":1,"maxLength":256},"verified":{"type":"boolean","default":false},"verifiedAt":{"type":"string","format":"date-time"},"linkedAt":{"type":"string","format":"date-time"}},"required":["provider","externalId"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"activeOrgId":{"type":"string","minLength":1,"maxLength":128},"lastSeenAt":{"type":"string","format":"date-time"},"presence":{"type":"object","properties":{"web":{"type":"string","format":"date-time"},"mcp":{"type":"string","format":"date-time"},"rest":{"type":"string","format":"date-time"},"whatsapp":{"type":"string","format":"date-time"},"whatsapp_web":{"type":"string","format":"date-time"},"telegram":{"type":"string","format":"date-time"},"sms":{"type":"string","format":"date-time"},"slack":{"type":"string","format":"date-time"},"teams":{"type":"string","format":"date-time"},"email":{"type":"string","format":"date-time"},"voice":{"type":"string","format":"date-time"},"scheduled":{"type":"string","format":"date-time"}},"default":{}},"demoSandbox":{"type":"boolean"},"lastSignInAt":{"type":"string","format":"date-time"},"notifications":{"type":"object","properties":{"digest":{"type":"string","enum":["daily","weekly","off"],"default":"weekly"},"alerts":{"type":"boolean","default":true}}},"consent":{"type":"object","properties":{"version":{"type":"string","minLength":1,"maxLength":32},"acceptedAt":{"type":"string","format":"date-time"},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"recordId":{"type":"string","maxLength":80}},"required":["version","acceptedAt","channel","method"]},"sessionsValidAfter":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","format":"date-time"},"deletedBy":{"type":"string","maxLength":128},"emailAsserted":{"type":"boolean"},"phoneAsserted":{"type":"boolean"}},"required":["id","kind","displayName","createdAt"]},"memberships":{"type":"array","items":{"type":"object","properties":{"principalId":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"status":{"type":"string","enum":["active","invited","suspended"],"default":"active"},"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"groupsUntil":{"type":"object","additionalProperties":{"type":"string"}},"attrs":{"type":"object","additionalProperties":{"nullable":true}},"attributes":{"type":"object","additionalProperties":{"nullable":true}},"addedBy":{"type":"string","minLength":1,"maxLength":128},"addedAt":{"type":"string","format":"date-time"},"allowedDatasets":{"type":"array","nullable":true,"items":{"type":"string"}},"allowedConnectors":{"type":"array","nullable":true,"items":{"type":"string"}},"lastSeenAt":{"type":"string","format":"date-time"},"presence":{"type":"object","properties":{"web":{"type":"string","format":"date-time"},"mcp":{"type":"string","format":"date-time"},"rest":{"type":"string","format":"date-time"},"whatsapp":{"type":"string","format":"date-time"},"whatsapp_web":{"type":"string","format":"date-time"},"telegram":{"type":"string","format":"date-time"},"sms":{"type":"string","format":"date-time"},"slack":{"type":"string","format":"date-time"},"teams":{"type":"string","format":"date-time"},"email":{"type":"string","format":"date-time"},"voice":{"type":"string","format":"date-time"},"scheduled":{"type":"string","format":"date-time"}}}},"required":["principalId","orgId","addedAt"]}},"orgs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"runtimeIdentity":{"type":"string"},"filesBucket":{"type":"string"},"stagingBucket":{"type":"string"}},"default":{}},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}}},"required":["id","slug","name","createdAt"]}},"activeOrgId":{"type":"string","nullable":true},"canCreateOrg":{"type":"boolean"}},"required":["principal","memberships","orgs","activeOrgId","canCreateOrg"]},"ActiveOrgBody":{"type":"object","properties":{"orgId":{"type":"string","nullable":true,"minLength":1}},"required":["orgId"]},"MyOrgs":{"type":"object","properties":{"primaryOrgId":{"type":"string","nullable":true},"activeOrgId":{"type":"string","nullable":true},"superAdmin":{"type":"boolean"},"orgs":{"type":"array","items":{"type":"object","properties":{"orgId":{"type":"string"},"name":{"type":"string"},"role":{"type":"string"},"primary":{"type":"boolean"},"active":{"type":"boolean"}},"required":["orgId","name","role","primary","active"]}}},"required":["primaryOrgId","activeOrgId","superAdmin","orgs"]},"PrimaryOrgChange":{"type":"object","properties":{"primaryOrgId":{"type":"string"},"previousOrgId":{"type":"string","nullable":true},"changed":{"type":"boolean"}},"required":["primaryOrgId","previousOrgId","changed"]},"PrimaryOrgBody":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["orgId"]},"MePatchBody":{"type":"object","properties":{"displayName":{"type":"string","minLength":1,"maxLength":200},"lang":{"type":"string","enum":["he","en","pt"]},"notifications":{"type":"object","properties":{"digest":{"type":"string","enum":["daily","weekly","off"],"default":"weekly"},"alerts":{"type":"boolean","default":true}}}}},"JoinResponse":{"type":"object","properties":{"orgId":{"type":"string"},"role":{"type":"string","enum":["org_admin","member"]},"groupIds":{"type":"array","items":{"type":"string"}},"alreadyMember":{"type":"boolean"}},"required":["orgId","role","groupIds","alreadyMember"]},"JoinBody":{"type":"object","properties":{"code":{"type":"string","minLength":8,"maxLength":40}},"required":["code"]},"MyPhones":{"type":"object","properties":{"phones":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string"},"primary":{"type":"boolean"}},"required":["phone","primary"]}}},"required":["phones"]},"PairingDoor":{"type":"object","properties":{"available":{"type":"boolean"},"number":{"type":"string"}},"required":["available"]},"PairingCode":{"type":"object","properties":{"code":{"type":"string"},"expiresAt":{"type":"string"},"number":{"type":"string"},"waUrl":{"type":"string"}},"required":["code","expiresAt","number","waUrl"]},"ConnectPreview":{"type":"object","properties":{"status":{"type":"string","enum":["valid","expired","used","invalid"]},"channel":{"type":"string"},"orgName":{"type":"string"},"hint":{"type":"string"},"displayName":{"type":"string"},"expiresAt":{"type":"string"},"methods":{"type":"array","nullable":true,"items":{"type":"string"}}},"required":["status"]},"ChannelLinks":{"type":"object","properties":{"links":{"type":"array","items":{"$ref":"#/components/schemas/ChannelLink"}}},"required":["links"]},"ChannelLink":{"type":"object","properties":{"id":{"type":"string"},"channel":{"type":"string","nullable":true},"label":{"type":"string"},"orgId":{"type":"string","nullable":true},"linkedAt":{"type":"string","nullable":true},"proof":{"type":"string","nullable":true,"enum":["signed_link","microsoft_identity",null]}},"required":["id","channel","label","orgId","linkedAt","proof"]},"ChannelLinkResult":{"oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["linked"]},"link":{"$ref":"#/components/schemas/ChannelLink"},"org":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]},"proof":{"type":"string","enum":["signed_link","microsoft_identity"]},"already":{"type":"boolean"}},"required":["status","link","org","proof","already"]},{"type":"object","properties":{"status":{"type":"string","enum":["confirm_required"]},"preview":{"$ref":"#/components/schemas/ConnectPreview"}},"required":["status","preview"]}]},"ChannelLinkBody":{"type":"object","properties":{"t":{"type":"string","minLength":10,"maxLength":200,"description":"The token of the /connect link."},"mode":{"type":"string","enum":["auto","confirm"],"default":"confirm"}},"required":["t"]},"CreateOrgBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"lang":{"type":"string","enum":["he","en","pt"]}},"required":["name"]},"OrganizationView":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"allOf":[{"$ref":"#/components/schemas/OrgDataStatus"},{"type":"object","properties":{"runtimeIdentity":{"type":"string"}}}]},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}},"memberCount":{"type":"integer","minimum":0}},"required":["id","slug","name","data","createdAt","memberCount"]},"OrgDataStatus":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"status":{"type":"string","enum":["ready","empty"]},"connectors":{"type":"integer","minimum":0}},"required":["status","connectors"]},"PatchOrgBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"lang":{"type":"string","enum":["he","en","pt"]},"tier":{"type":"string","enum":["standard","dedicated","byoc"]},"status":{"type":"string","enum":["active","suspended","archived"]},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","maxLength":200000}}},"emailDomains":{"type":"array","items":{"type":"string"},"maxItems":20}}},"OrgSkill":{"type":"object","properties":{"orgId":{"type":"string"},"markdown":{"type":"string"},"version":{"type":"string"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"canEdit":{"type":"boolean"},"maxChars":{"type":"integer"}},"required":["orgId","markdown","version","canEdit","maxChars"]},"PutSkillBody":{"type":"object","properties":{"markdown":{"type":"string","maxLength":200000},"version":{"type":"string"},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["markdown"]},"OrgSkillVersion":{"type":"object","properties":{"version":{"type":"string"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"note":{"type":"string"},"chars":{"type":"integer"}},"required":["version","chars"]},"RestoreSkillBody":{"type":"object","properties":{"version":{"type":"string","minLength":1},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["version"]},"People":{"type":"object","properties":{"members":{"type":"array","items":{"$ref":"#/components/schemas/Person"}},"invites":{"type":"array","items":{"$ref":"#/components/schemas/PendingInvite"}}},"required":["members","invites"]},"Person":{"type":"object","properties":{"principalId":{"type":"string"},"displayName":{"type":"string"},"email":{"type":"string"},"phone":{"type":"string"},"status":{"type":"string"},"membershipStatus":{"type":"string","enum":["active","invited","suspended"]},"membershipRole":{"type":"string","enum":["org_admin","member"]},"effectiveRole":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]},"superAdmin":{"type":"boolean"},"groups":{"type":"array","items":{"type":"string"}},"lastSeen":{"type":"object","properties":{"web":{"type":"string","format":"date-time"},"mcp":{"type":"string","format":"date-time"},"rest":{"type":"string","format":"date-time"},"whatsapp":{"type":"string","format":"date-time"},"whatsapp_web":{"type":"string","format":"date-time"},"telegram":{"type":"string","format":"date-time"},"sms":{"type":"string","format":"date-time"},"slack":{"type":"string","format":"date-time"},"teams":{"type":"string","format":"date-time"},"email":{"type":"string","format":"date-time"},"voice":{"type":"string","format":"date-time"},"scheduled":{"type":"string","format":"date-time"}}},"lastSeenAt":{"type":"string","format":"date-time"},"addedAt":{"type":"string","format":"date-time"}},"required":["principalId","displayName","status","membershipStatus","membershipRole","effectiveRole","superAdmin","groups","lastSeen","addedAt"]},"PendingInvite":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"identifier":{"type":"object","properties":{"kind":{"type":"string","enum":["email","phone"]},"value":{"type":"string","minLength":3}},"required":["kind","value"]},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"status":{"type":"string","enum":["pending","consumed"],"default":"pending"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"consumedAt":{"type":"string","format":"date-time"},"consumedBy":{"type":"string","minLength":1,"maxLength":128},"linkKey":{"type":"string","minLength":16,"maxLength":64},"delivery":{"type":"object","properties":{"channel":{"type":"string","enum":["email","whatsapp","sms","manual"]},"status":{"type":"string","enum":["sent","failed","manual"]},"at":{"type":"string","format":"date-time"},"error":{"type":"string","maxLength":120},"attempts":{"type":"integer","minimum":0,"default":1}},"required":["channel","status","at"]},"link":{"type":"string"}},"required":["id","orgId","identifier","createdBy","createdAt","link"]},"Preview":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},"Applied":{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]},"AddPersonBody":{"type":"object","properties":{"email":{"type":"string","format":"email"},"phone":{"type":"string","minLength":3},"mode":{"type":"string","enum":["invite","active"],"default":"invite"},"displayName":{"type":"string","minLength":1,"maxLength":200},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groups":{"type":"array","items":{"type":"string"},"default":[]},"send":{"type":"boolean","default":true},"lang":{"type":"string","enum":["he","en","pt"]},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"PatchPersonBody":{"type":"object","properties":{"role":{"type":"string","enum":["org_admin","member"]},"status":{"type":"string","enum":["active","invited","suspended"]},"groups":{"type":"array","items":{"type":"string"}},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"PersonPhones":{"type":"object","properties":{"principalId":{"type":"string"},"phones":{"type":"array","items":{"$ref":"#/components/schemas/PersonPhone"}},"canEdit":{"type":"boolean"},"reason":{"type":"string"}},"required":["principalId","phones","canEdit"]},"PersonPhone":{"type":"object","properties":{"phone":{"type":"string"},"primary":{"type":"boolean"},"linkedBy":{"type":"string"},"linkedAt":{"type":"string"}},"required":["phone","primary"]},"AddPersonPhoneBody":{"type":"object","properties":{"phone":{"type":"string","minLength":3,"maxLength":40},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["phone"]},"InviteResendPreview":{"type":"object","properties":{"preview":{"type":"object","properties":{"inviteId":{"type":"string"},"identifier":{"type":"string"},"kind":{"type":"string","enum":["email","phone"]},"last":{"type":"object","properties":{"channel":{"type":"string","enum":["email","whatsapp","sms","manual"]},"status":{"type":"string","enum":["sent","failed","manual"]},"at":{"type":"string","format":"date-time"},"error":{"type":"string","maxLength":120},"attempts":{"type":"integer","minimum":0,"default":1}},"required":["channel","status","at"]}},"required":["inviteId","identifier","kind"]}},"required":["preview"]},"InviteResendApplied":{"type":"object","properties":{"applied":{"type":"object","properties":{"inviteId":{"type":"string"},"delivery":{"type":"object","properties":{"channel":{"type":"string","enum":["email","whatsapp","sms","manual"]},"status":{"type":"string","enum":["sent","failed","manual"]},"at":{"type":"string","format":"date-time"},"error":{"type":"string","maxLength":120},"attempts":{"type":"integer","minimum":0,"default":1}},"required":["channel","status","at"]},"link":{"type":"string"}},"required":["inviteId","delivery","link"]}},"required":["applied"]},"InviteResendBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"InviteLinkPreview":{"type":"object","properties":{"status":{"type":"string","enum":["valid","used","expired","invalid"]},"orgName":{"type":"string"},"kind":{"type":"string","enum":["email","phone"]},"methods":{"type":"array","nullable":true,"items":{"type":"string"}}},"required":["status"]},"CreateInviteCodeBody":{"type":"object","properties":{"maxUses":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":10000},"expiresAt":{"type":"string","format":"date-time"},"expiresInDays":{"type":"integer","minimum":1,"maximum":365},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groups":{"type":"array","items":{"type":"string"},"default":[]}}},"RedeemResponse":{"type":"object","properties":{"orgId":{"type":"string"},"role":{"type":"string","enum":["org_admin","member"]},"groupIds":{"type":"array","items":{"type":"string"}},"alreadyMember":{"type":"boolean"}},"required":["orgId","role","groupIds","alreadyMember"]},"RedeemBody":{"type":"object","properties":{"code":{"type":"string","minLength":8,"maxLength":40}},"required":["code"]},"GroupWithMembers":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","minLength":1,"maxLength":128},"resources":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1,"maxLength":128},"sharedBy":{"type":"string","minLength":1,"maxLength":128},"sharedAt":{"type":"string","format":"date-time"}},"required":["kind","id"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"members":{"type":"array","items":{"type":"object","properties":{"principalId":{"type":"string","minLength":1,"maxLength":128},"groupId":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"role":{"type":"string","enum":["group_admin","member"],"default":"member"},"addedBy":{"type":"string","minLength":1,"maxLength":128},"addedAt":{"type":"string","format":"date-time"},"temporaryUntil":{"type":"string","format":"date-time"}},"required":["principalId","groupId","orgId","addedAt"]}}},"required":["id","orgId","slug","name","createdAt","members"]},"CreateGroupBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string"},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["name"]},"PatchGroupBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","nullable":true},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"AddGroupMemberBody":{"type":"object","properties":{"principalId":{"type":"string","minLength":1},"role":{"type":"string","enum":["group_admin","member"],"default":"member"},"temporaryUntil":{"type":"string","format":"date-time"},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["principalId"]},"ShareResourceBody":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["kind","id"]},"CreatedToken":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-f]{64}$"},"prefix":{"type":"string","minLength":11,"maxLength":11},"principalId":{"type":"string","minLength":1,"maxLength":128},"orgIdOverride":{"type":"string","minLength":1,"maxLength":128},"channel":{"type":"string","maxLength":32},"allowedTools":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"default":["read"]},"expiresAt":{"type":"string","format":"date-time"},"revokedAt":{"type":"string","format":"date-time"},"lastUsedAt":{"type":"string","format":"date-time"},"usageCount":{"type":"integer","minimum":0,"default":0},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":120},"clientId":{"type":"string","maxLength":1024},"grantId":{"type":"string","maxLength":64},"audience":{"type":"string","maxLength":1024},"token":{"type":"string"}},"required":["id","prefix","principalId","createdAt","token"]},"CreateTokenBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"expiresAt":{"type":"string","format":"date-time"},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"default":["read"]},"channel":{"type":"string","maxLength":32,"default":"rest"}},"required":["name"]},"GetPolicyResponse":{"type":"object","properties":{"policy":{"$ref":"#/components/schemas/Policy"},"canEdit":{"type":"boolean"},"role":{"type":"string"}},"required":["policy","canEdit","role"]},"Policy":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"version":{"type":"integer","minimum":0},"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["topic","source","table","column","row"]},"effect":{"type":"string","enum":["allow","deny"]},"scope":{"anyOf":[{"type":"object","properties":{"all":{"type":"boolean","enum":[true]},"except":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]}},"required":["all"]},{"type":"object","properties":{"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["groups"]},{"type":"object","properties":{"principals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["principals"]}]},"target":{"type":"object","properties":{"sourceId":{"type":"string","minLength":1,"maxLength":128},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"table":{"type":"string"},"tables":{"type":"array","items":{"type":"string"},"default":[]},"column":{"type":"string"},"columns":{"type":"array","items":{"type":"string"},"default":[]},"rowFilter":{"type":"string","maxLength":2000},"rowFilters":{"type":"object","additionalProperties":{"type":"string","maxLength":2000}},"topic":{"type":"string","maxLength":500}}},"compiled":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"string"},"default":[]},"columns":{"type":"array","items":{"type":"string"},"default":[]},"keywords":{"type":"array","items":{"type":"string"},"default":[]},"rationale":{"type":"string","maxLength":1000},"compiledAt":{"type":"string","format":"date-time"},"model":{"type":"string"}},"required":["compiledAt"]},"enabled":{"type":"boolean","default":true},"say":{"type":"string","maxLength":2000,"default":""},"refusal":{"type":"string","maxLength":500},"exemptSuperAdmin":{"type":"boolean","default":false},"exemptPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"note":{"type":"string","maxLength":1000},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","kind","effect","scope","target"]},"default":[]},"rooms":{"type":"array","items":{"type":"object","properties":{"room":{"type":"string","minLength":1,"maxLength":128},"groupId":{"type":"string","minLength":1,"maxLength":128},"reads":{"type":"string","enum":["group","speaker"]},"boundAt":{"type":"string","format":"date-time"},"boundBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["room","boundAt","boundBy"]},"default":[]},"orgAdminCanEdit":{"type":"boolean","default":true},"note":{"type":"string","maxLength":500},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["orgId","version","updatedAt"]},"PolicyError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]},"PutPolicyResponse":{"type":"object","properties":{"policy":{"$ref":"#/components/schemas/Policy"},"preview":{"type":"object","properties":{"version":{"type":"integer"},"groups":{"type":"array","items":{"type":"string"}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["topic","source","table","column","row"]},"effect":{"type":"string","enum":["allow","deny"]},"scope":{"anyOf":[{"type":"object","properties":{"all":{"type":"boolean","enum":[true]},"except":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]}},"required":["all"]},{"type":"object","properties":{"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["groups"]},{"type":"object","properties":{"principals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["principals"]}]},"target":{"type":"object","properties":{"sourceId":{"type":"string","minLength":1,"maxLength":128},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"table":{"type":"string"},"tables":{"type":"array","items":{"type":"string"},"default":[]},"column":{"type":"string"},"columns":{"type":"array","items":{"type":"string"},"default":[]},"rowFilter":{"type":"string","maxLength":2000},"rowFilters":{"type":"object","additionalProperties":{"type":"string","maxLength":2000}},"topic":{"type":"string","maxLength":500}}},"compiled":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"string"},"default":[]},"columns":{"type":"array","items":{"type":"string"},"default":[]},"keywords":{"type":"array","items":{"type":"string"},"default":[]},"rationale":{"type":"string","maxLength":1000},"compiledAt":{"type":"string","format":"date-time"},"model":{"type":"string"}},"required":["compiledAt"]},"enabled":{"type":"boolean","default":true},"say":{"type":"string","maxLength":2000,"default":""},"refusal":{"type":"string","maxLength":500},"exemptSuperAdmin":{"type":"boolean","default":false},"exemptPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"note":{"type":"string","maxLength":1000},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","kind","effect","scope","target"]}},"orgAdminCanEdit":{"type":"boolean"},"diff":{"type":"object","properties":{"added":{"type":"array","items":{"type":"string"}},"removed":{"type":"array","items":{"type":"string"}},"changed":{"type":"array","items":{"type":"string"}}},"required":["added","removed","changed"]}},"required":["version","groups","rules","orgAdminCanEdit","diff"]}}},"PutPolicyBody":{"type":"object","properties":{"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["topic","source","table","column","row"]},"effect":{"type":"string","enum":["allow","deny"]},"scope":{"anyOf":[{"type":"object","properties":{"all":{"type":"boolean","enum":[true]},"except":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]}},"required":["all"]},{"type":"object","properties":{"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["groups"]},{"type":"object","properties":{"principals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["principals"]}]},"target":{"type":"object","properties":{"sourceId":{"type":"string","minLength":1,"maxLength":128},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"table":{"type":"string"},"tables":{"type":"array","items":{"type":"string"},"default":[]},"column":{"type":"string"},"columns":{"type":"array","items":{"type":"string"},"default":[]},"rowFilter":{"type":"string","maxLength":2000},"rowFilters":{"type":"object","additionalProperties":{"type":"string","maxLength":2000}},"topic":{"type":"string","maxLength":500}}},"compiled":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"string"},"default":[]},"columns":{"type":"array","items":{"type":"string"},"default":[]},"keywords":{"type":"array","items":{"type":"string"},"default":[]},"rationale":{"type":"string","maxLength":1000},"compiledAt":{"type":"string","format":"date-time"},"model":{"type":"string"}},"required":["compiledAt"]},"enabled":{"type":"boolean","default":true},"say":{"type":"string","maxLength":2000,"default":""},"refusal":{"type":"string","maxLength":500},"exemptSuperAdmin":{"type":"boolean","default":false},"exemptPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"note":{"type":"string","maxLength":1000},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","kind","effect","scope","target"]}},"orgAdminCanEdit":{"type":"boolean"},"note":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0},"confirm":{"type":"boolean","default":false}}},"CompileResponse":{"type":"object","properties":{"proposal":{"nullable":true}}},"CompileBody":{"type":"object","properties":{"say":{"type":"string","minLength":1,"maxLength":2000},"kindHint":{"type":"string","enum":["topic","source","table","column"]}},"required":["say"]},"SimulateResponse":{"type":"object","properties":{"effective":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"uid":{"type":"string"},"policyVersion":{"type":"integer","minimum":0},"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"restricted":{"type":"boolean"},"isRoom":{"type":"boolean"},"roomAccess":{"type":"string","enum":["group","room_principal","none"]},"roomGroup":{"type":"string","minLength":1,"maxLength":128},"roomReads":{"type":"string","enum":["group","speaker"]},"allowedSources":{"type":"array","nullable":true,"items":{"type":"string"}},"deniedSources":{"type":"array","items":{"type":"string"},"default":[]},"deniedTables":{"type":"array","items":{"type":"string"}},"allowedTables":{"type":"array","nullable":true,"items":{"type":"string"}},"deniedColumns":{"type":"array","items":{"type":"string"}},"rows":{"type":"object","additionalProperties":{"type":"object","properties":{"allow":{"type":"array","items":{"type":"object","properties":{"ruleId":{"type":"string","minLength":1,"maxLength":128},"predicate":{"type":"object","properties":{"op":{"type":"string","enum":["and","or","not","cmp","in","not_in","is_null","not_null","const"]}},"required":["op"],"additionalProperties":{"nullable":true}},"sources":{"type":"array","items":{"type":"string"},"default":[]}},"required":["ruleId","predicate"]},"default":[]},"deny":{"type":"array","items":{"type":"object","properties":{"ruleId":{"type":"string","minLength":1,"maxLength":128},"predicate":{"type":"object","properties":{"op":{"type":"string","enum":["and","or","not","cmp","in","not_in","is_null","not_null","const"]}},"required":["op"],"additionalProperties":{"nullable":true}},"sources":{"type":"array","items":{"type":"string"},"default":[]}},"required":["ruleId","predicate"]},"default":[]}}},"default":{}},"attributes":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},"topics":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"say":{"type":"string"},"keywords":{"type":"array","items":{"type":"string"}},"refusal":{"type":"string"}},"required":["id","say","keywords"]}},"sources":{"type":"object","properties":{"tables":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":128}},"columns":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":128}},"sources":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":128},"default":{}},"sourcesRule":{"type":"string"}},"required":["tables","columns"]},"failClosed":{"type":"boolean"},"failReason":{"type":"string","maxLength":300}},"required":["orgId","uid","policyVersion","restricted","isRoom","allowedSources","deniedTables","allowedTables","deniedColumns","topics","sources"]},"rowFilters":{"type":"array","items":{"type":"object","properties":{"table":{"type":"string"},"filter":{"type":"string"},"ruleIds":{"type":"array","items":{"type":"string"}},"attributes":{"type":"object","additionalProperties":{"type":"array","nullable":true,"items":{"type":"string"}}},"missing":{"type":"array","items":{"type":"string"}}},"required":["table","filter","ruleIds","attributes","missing"]}}},"required":["effective","rowFilters"]},"Decision":{"type":"object","properties":{"allowed":{"type":"boolean"},"effect":{"type":"string","enum":["allow","deny"]},"matchedRuleIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"deniedColumns":{"type":"array","items":{"type":"string"},"default":[]},"reason":{"type":"string","maxLength":500},"failClosed":{"type":"boolean","default":false},"question":{"type":"string","maxLength":4000},"evaluatedAt":{"type":"string","format":"date-time"}},"required":["allowed","effect","reason","evaluatedAt"]},"SimulateBody":{"type":"object","properties":{"question":{"type":"string","minLength":1,"maxLength":4000}},"required":["question"]},"DenialsResponse":{"type":"object","properties":{"denials":{"type":"array","items":{"nullable":true}}},"required":["denials"]},"VersionsResponse":{"type":"object","properties":{"versions":{"type":"array","items":{"type":"object","properties":{"version":{"type":"integer"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"note":{"type":"string"},"rules":{"type":"integer"}},"required":["version","rules"]}}},"required":["versions"]},"RestoreBody":{"type":"object","properties":{"version":{"type":"integer","minimum":0},"confirm":{"type":"boolean","default":false}},"required":["version"]},"PolicyWarningsResponse":{"type":"object","properties":{"warnings":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"groupId":{"type":"string"},"ruleId":{"type":"string"},"principalId":{"type":"string"},"until":{"type":"string"}},"required":["code"]}}},"required":["warnings"]},"ViewAsResponse":{"type":"object","properties":{"principalId":{"type":"string"},"kind":{"type":"string"},"role":{"type":"string"},"groups":{"type":"array","items":{"type":"string"}},"policyVersion":{"type":"integer"},"failClosed":{"type":"boolean"},"restricted":{"type":"boolean"},"room":{"type":"string"},"sources":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"allowed":{"type":"boolean"}},"required":["id","type","allowed"]}},"tables":{"type":"object","properties":{"allowed":{"type":"array","nullable":true,"items":{"type":"string"}},"denied":{"type":"array","items":{"type":"string"}}},"required":["allowed","denied"]},"hiddenColumns":{"type":"array","items":{"type":"string"}},"rowFilters":{"type":"array","items":{"type":"object","properties":{"table":{"type":"string"},"filter":{"type":"string"},"missing":{"type":"array","items":{"type":"string"}}},"required":["table","filter","missing"]}},"topics":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"say":{"type":"string"}},"required":["id","say"]}},"actions":{"type":"string"},"tools":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"title":{"type":"string"},"grade":{"type":"string"}},"required":["name","grade"]}}},"required":["principalId","kind","role","groups","policyVersion","failClosed","restricted","sources","tables","hiddenColumns","rowFilters","topics","actions","tools"]},"ViewAsQueryResponse":{"type":"object","properties":{"allowed":{"type":"boolean"},"sql":{"type":"string"},"rewritten":{"type":"boolean"},"rowTables":{"type":"array","items":{"type":"string"}},"refusal":{"type":"object","properties":{"code":{"type":"string"},"name":{"type":"string"},"detail":{"type":"string"}},"required":["code","name","detail"]}},"required":["allowed"]},"ViewAsQueryBody":{"type":"object","properties":{"sql":{"type":"string","minLength":1,"maxLength":20000},"dialect":{"type":"string","enum":["bigquery","tsql","postgres","mysql"],"default":"bigquery"},"source":{"type":"string","maxLength":200}},"required":["sql"]},"ProposalsResponse":{"type":"object","properties":{"proposals":{"type":"array","items":{"$ref":"#/components/schemas/PolicyProposal"}}},"required":["proposals"]},"PolicyProposal":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"say":{"type":"string","maxLength":2000},"rule":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["topic","source","table","column","row"]},"effect":{"type":"string","enum":["allow","deny"]},"scope":{"anyOf":[{"type":"object","properties":{"all":{"type":"boolean","enum":[true]},"except":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]}},"required":["all"]},{"type":"object","properties":{"groups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["groups"]},{"type":"object","properties":{"principals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1}},"required":["principals"]}]},"target":{"type":"object","properties":{"sourceId":{"type":"string","minLength":1,"maxLength":128},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"table":{"type":"string"},"tables":{"type":"array","items":{"type":"string"},"default":[]},"column":{"type":"string"},"columns":{"type":"array","items":{"type":"string"},"default":[]},"rowFilter":{"type":"string","maxLength":2000},"rowFilters":{"type":"object","additionalProperties":{"type":"string","maxLength":2000}},"topic":{"type":"string","maxLength":500}}},"compiled":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"string"},"default":[]},"columns":{"type":"array","items":{"type":"string"},"default":[]},"keywords":{"type":"array","items":{"type":"string"},"default":[]},"rationale":{"type":"string","maxLength":1000},"compiledAt":{"type":"string","format":"date-time"},"model":{"type":"string"}},"required":["compiledAt"]},"enabled":{"type":"boolean","default":true},"say":{"type":"string","maxLength":2000,"default":""},"refusal":{"type":"string","maxLength":500},"exemptSuperAdmin":{"type":"boolean","default":false},"exemptPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"note":{"type":"string","maxLength":1000},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","kind","effect","scope","target"]},"unknown":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"string"}},"columns":{"type":"array","items":{"type":"string"}}},"required":["tables","columns"]},"via":{"type":"string","enum":["chat","console","mcp"]},"status":{"type":"string","enum":["pending","applied","dismissed"]},"basedOnVersion":{"type":"integer","minimum":0},"impact":{"type":"object","properties":{"narrowed":{"type":"integer","minimum":0},"widened":{"type":"integer","minimum":0},"audiences":{"type":"array","items":{"type":"object","properties":{"principalId":{"type":"string"},"isRoom":{"type":"boolean"},"widened":{"type":"boolean"}},"required":["principalId","isRoom","widened"]},"maxItems":50,"default":[]}},"required":["narrowed","widened"]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"appliedVersion":{"type":"integer","minimum":0}},"required":["id","orgId","say","rule","via","status","basedOnVersion","impact","createdAt","createdBy"]},"ApplyProposalResponse":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}},"proposal":{"$ref":"#/components/schemas/PolicyProposal"}}},"ApplyBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"version":{"type":"integer","minimum":0}}},"DismissProposalResponse":{"type":"object","properties":{"proposal":{"$ref":"#/components/schemas/PolicyProposal"}},"required":["proposal"]},"MemberAttributes":{"type":"object","properties":{"attributes":{"type":"array","items":{"$ref":"#/components/schemas/AttributeReading"}},"canEdit":{"type":"boolean"}},"required":["attributes","canEdit"]},"AttributeReading":{"type":"object","properties":{"key":{"type":"string"},"values":{"type":"array","items":{"type":"string"}},"source":{"type":"string","enum":["manual","scim","sso","connector","import"]},"sourceRef":{"type":"string"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"expiresAt":{"type":"string"},"fresh":{"type":"boolean"},"reason":{"type":"string","enum":["expired","empty","malformed"]}},"required":["key","values","source","fresh"]},"AttributesPreview":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},"AttributesApplied":{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]},"PutAttributeBody":{"type":"object","properties":{"values":{"type":"array","items":{"type":"string","minLength":1,"maxLength":500},"maxItems":200},"expiresAt":{"type":"string","format":"date-time"},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["values"]},"AttributeSourcesResponse":{"type":"object","properties":{"sources":{"type":"object","properties":{"orgId":{"type":"string"},"claims":{"type":"array","items":{"type":"object","properties":{"attribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"claim":{"type":"string","minLength":1,"maxLength":300},"via":{"type":"string","enum":["scim","sso"],"default":"scim"}},"required":["attribute","claim"]}},"connectors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"attribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"connectorId":{"type":"string","minLength":1,"maxLength":128},"table":{"type":"string","minLength":1,"maxLength":200},"valueColumn":{"type":"string","minLength":1,"maxLength":128},"matchColumn":{"type":"string","minLength":1,"maxLength":128},"matchOn":{"type":"string","enum":["email","phone","principal","attribute"]},"matchAttribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"ttlHours":{"type":"integer","minimum":1,"maximum":744,"default":24},"enabled":{"type":"boolean","default":true}},"required":["id","attribute","connectorId","table","valueColumn","matchColumn","matchOn"]}},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"lastRefreshAt":{"type":"string"},"lastReport":{"type":"object","additionalProperties":{"nullable":true}}},"required":["orgId","claims","connectors","updatedAt"]},"canEdit":{"type":"boolean"}},"required":["sources","canEdit"]},"PutAttributeSourcesBody":{"type":"object","properties":{"claims":{"type":"array","items":{"type":"object","properties":{"attribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"claim":{"type":"string","minLength":1,"maxLength":300},"via":{"type":"string","enum":["scim","sso"],"default":"scim"}},"required":["attribute","claim"]},"default":[]},"connectors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"attribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"connectorId":{"type":"string","minLength":1,"maxLength":128},"table":{"type":"string","minLength":1,"maxLength":200},"valueColumn":{"type":"string","minLength":1,"maxLength":128},"matchColumn":{"type":"string","minLength":1,"maxLength":128},"matchOn":{"type":"string","enum":["email","phone","principal","attribute"]},"matchAttribute":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"ttlHours":{"type":"integer","minimum":1,"maximum":744,"default":24},"enabled":{"type":"boolean","default":true}},"required":["id","attribute","connectorId","table","valueColumn","matchColumn","matchOn"]},"default":[]},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"RefreshAttributesBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"RoomsResponse":{"type":"object","properties":{"rooms":{"type":"array","items":{"$ref":"#/components/schemas/RoomRow"}},"canEdit":{"type":"boolean"},"version":{"type":"integer"}},"required":["rooms","canEdit","version"]},"RoomRow":{"type":"object","properties":{"room":{"type":"string"},"roomId":{"type":"string"},"name":{"type":"string"},"channel":{"type":"string"},"groupId":{"type":"string","nullable":true},"groupName":{"type":"string","nullable":true},"binding":{"type":"object","nullable":true,"properties":{"room":{"type":"string","minLength":1,"maxLength":128},"groupId":{"type":"string","minLength":1,"maxLength":128},"reads":{"type":"string","enum":["group","speaker"]},"boundAt":{"type":"string","format":"date-time"},"boundBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["room","boundAt","boundBy"]},"access":{"type":"string","enum":["group","speaker","room_principal"]},"reads":{"type":"string","nullable":true,"enum":["group","speaker",null]}},"required":["room","groupId","groupName","binding","access","reads"]},"RoomsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]},"PutRoomGroupResponse":{"type":"object","properties":{"preview":{"type":"object","properties":{"room":{"type":"string"},"from":{"type":"string","nullable":true},"to":{"type":"string","nullable":true},"readsFrom":{"type":"string","nullable":true,"enum":["group","speaker",null]},"readsTo":{"type":"string","nullable":true,"enum":["group","speaker",null]},"version":{"type":"integer"}},"required":["room","from","to","readsFrom","readsTo","version"]},"room":{"$ref":"#/components/schemas/RoomRow"},"version":{"type":"integer"}}},"PutRoomGroupBody":{"type":"object","properties":{"groupId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"reads":{"type":"string","enum":["group","speaker"]},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false}},"required":["groupId"]},"RoomWhatsAppState":{"type":"object","properties":{"room":{"type":"object","properties":{"roomId":{"type":"string"},"name":{"type":"string","nullable":true},"bindingId":{"type":"string"}},"required":["roomId","name","bindingId"]},"group":{"type":"object","nullable":true,"properties":{"name":{"type":"string"},"topic":{"type":"string"},"participantCount":{"type":"integer"},"joinApproval":{"type":"boolean"},"addMode":{"type":"string","enum":["admin_add","all_member_add","unknown"]},"locked":{"type":"boolean"},"announce":{"type":"boolean"},"participants":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string"},"displayName":{"type":"string","nullable":true},"isAdmin":{"type":"boolean"},"isOwner":{"type":"boolean"},"principalId":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"ours":{"type":"boolean"}},"required":["phone","displayName","isAdmin","isOwner","principalId","name","ours"]}}},"required":["name","topic","participantCount","joinApproval","addMode","locked","announce","participants"]},"standard":{"type":"object","properties":{"joinApproval":{"type":"boolean"},"addMode":{"type":"string"},"locked":{"type":"boolean"}},"required":["joinApproval","addMode","locked"]},"drift":{"type":"array","items":{"type":"string","enum":["join_approval","add_mode","locked"]}},"botIsAdmin":{"type":"boolean"},"inviteLink":{"type":"string","nullable":true},"notInGroup":{"type":"array","items":{"type":"object","properties":{"principalId":{"type":"string"},"name":{"type":"string"}},"required":["principalId","name"]}},"joinRequests":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string"},"displayName":{"type":"string","nullable":true},"requestedAt":{"type":"string","nullable":true},"principalId":{"type":"string","nullable":true},"name":{"type":"string","nullable":true}},"required":["phone","displayName","requestedAt","principalId","name"]}}},"required":["room","group","standard","drift","botIsAdmin","inviteLink","notInGroup","joinRequests"]},"RoomWhatsAppError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"params":{"type":"object","additionalProperties":{"type":"string"}},"traceId":{"type":"string"}},"required":["error","traceId"]},"RoomWhatsAppAction":{"type":"object","properties":{"action":{"type":"string","enum":["join_approval_on","admin_add_only","lock","reset_link","promote","demote","approve_request","reject_request"]},"principalId":{"type":"string","minLength":1,"maxLength":200},"phone":{"type":"string","minLength":6,"maxLength":20},"confirm":{"type":"boolean","default":false}},"required":["action"]},"AdminWhatsAppGroups":{"type":"object","properties":{"standard":{"type":"object","properties":{"joinApproval":{"type":"boolean"},"addMode":{"type":"string"},"locked":{"type":"boolean"}},"required":["joinApproval","addMode","locked"]},"numbers":{"type":"array","items":{"type":"object","properties":{"bindingId":{"type":"string"},"number":{"type":"string"},"label":{"type":"string"},"status":{"type":"string"},"reachable":{"type":"boolean"},"groups":{"type":"integer"},"unbound":{"type":"array","items":{"type":"object","properties":{"jid":{"type":"string"},"name":{"type":"string"},"participantCount":{"type":"integer"}},"required":["jid","name","participantCount"]}}},"required":["bindingId","number","label","status","reachable","groups","unbound"]}},"groups":{"type":"array","items":{"type":"object","properties":{"bindingId":{"type":"string"},"roomId":{"type":"string"},"name":{"type":"string","nullable":true},"orgId":{"type":"string"},"orgName":{"type":"string","nullable":true},"active":{"type":"boolean"},"participantCount":{"type":"integer","nullable":true},"inStandard":{"type":"boolean","nullable":true},"drift":{"type":"array","items":{"type":"string","enum":["join_approval","add_mode","locked"]}},"botIsAdmin":{"type":"boolean","nullable":true}},"required":["bindingId","roomId","name","orgId","orgName","active","participantCount","inStandard","drift","botIsAdmin"]}}},"required":["standard","numbers","groups"]},"OrgWhatsAppGroups":{"type":"object","properties":{"standard":{"type":"object","properties":{"joinApproval":{"type":"boolean"},"addMode":{"type":"string"},"locked":{"type":"boolean"}},"required":["joinApproval","addMode","locked"]},"groups":{"type":"array","items":{"type":"object","properties":{"roomId":{"type":"string"},"name":{"type":"string","nullable":true},"active":{"type":"boolean"},"participantCount":{"type":"integer","nullable":true},"inStandard":{"type":"boolean","nullable":true},"drift":{"type":"array","items":{"type":"string","enum":["join_approval","add_mode","locked"]}},"botIsAdmin":{"type":"boolean","nullable":true},"pendingRequests":{"type":"integer","nullable":true}},"required":["roomId","name","active","participantCount","inStandard","drift","botIsAdmin","pendingRequests"]}}},"required":["standard","groups"]},"OrgWhatsAppGroupsError":{"type":"object","properties":{"error":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]},"KnowledgeItem":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"scope":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"scopeRef":{"type":"string","nullable":true,"minLength":1,"maxLength":256},"kind":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"layer":{"type":"string","enum":["core","source","learned","task"]},"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50,"default":[]},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"weight":{"type":"integer","minimum":0,"maximum":100,"default":50},"status":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"statusReason":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"sha":{"type":"string","pattern":"^[0-9a-f]{64}$"},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"origin":{"type":"string","enum":["manual","import","harvest","user_command","eval"]},"evidence":{"type":"array","items":{"type":"object","properties":{"interactionId":{"type":"string","maxLength":200},"turnId":{"type":"string","maxLength":200},"quote":{"type":"string","maxLength":500},"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"}},"required":["at"]},"maxItems":20,"default":[]},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"warnings":{"type":"array","items":{"type":"string","maxLength":200},"default":[]},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"approvedBy":{"type":"string","minLength":1,"maxLength":128},"approvedAt":{"type":"string","format":"date-time"},"eval":{"type":"object","properties":{"runId":{"type":"string","minLength":1,"maxLength":200},"verdict":{"type":"string","enum":["pass","fail","inconclusive"]},"at":{"type":"string","format":"date-time"}},"required":["runId","verdict","at"]},"metrics":{"type":"object","properties":{"injected":{"type":"integer","minimum":0,"default":0},"lastInjectedAt":{"type":"string","format":"date-time"}},"default":{"injected":0}},"pinned":{"type":"boolean"},"blocked":{"type":"boolean"}},"required":["id","orgId","scope","scopeRef","kind","layer","title","body","status","version","sha","origin","createdBy","createdAt","updatedBy","updatedAt"]},"KnowledgeVersion":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"scope":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"scopeRef":{"type":"string","nullable":true,"minLength":1,"maxLength":256},"kind":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"layer":{"type":"string","enum":["core","source","learned","task"]},"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50,"default":[]},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"weight":{"type":"integer","minimum":0,"maximum":100,"default":50},"status":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"statusReason":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"sha":{"type":"string","pattern":"^[0-9a-f]{64}$"},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"origin":{"type":"string","enum":["manual","import","harvest","user_command","eval"]},"evidence":{"type":"array","items":{"type":"object","properties":{"interactionId":{"type":"string","maxLength":200},"turnId":{"type":"string","maxLength":200},"quote":{"type":"string","maxLength":500},"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"}},"required":["at"]},"maxItems":20,"default":[]},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"warnings":{"type":"array","items":{"type":"string","maxLength":200},"default":[]},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"approvedBy":{"type":"string","minLength":1,"maxLength":128},"approvedAt":{"type":"string","format":"date-time"},"eval":{"type":"object","properties":{"runId":{"type":"string","minLength":1,"maxLength":200},"verdict":{"type":"string","enum":["pass","fail","inconclusive"]},"at":{"type":"string","format":"date-time"}},"required":["runId","verdict","at"]},"metrics":{"type":"object","properties":{"injected":{"type":"integer","minimum":0,"default":0},"lastInjectedAt":{"type":"string","format":"date-time"}},"default":{"injected":0}},"pinned":{"type":"boolean"},"blocked":{"type":"boolean"},"change":{"type":"string","enum":["create","update","transition","restore","governance"]},"restoredFrom":{"type":"integer","minimum":0,"exclusiveMinimum":true},"note":{"type":"string","maxLength":500}},"required":["id","orgId","scope","scopeRef","kind","layer","title","body","status","version","sha","origin","createdBy","createdAt","updatedBy","updatedAt","change"]},"KnowledgeDiff":{"type":"object","properties":{"itemId":{"type":"string"},"from":{"type":"integer"},"to":{"type":"integer"},"fromSha":{"type":"string"},"toSha":{"type":"string"},"fields":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"from":{"nullable":true},"to":{"nullable":true}},"required":["field"]}},"body":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"op":{"type":"string","enum":[" ","+","-"]},"text":{"type":"string"}},"required":["op","text"]}},"added":{"type":"integer"},"removed":{"type":"integer"},"coarse":{"type":"boolean"}},"required":["lines","added","removed","coarse"]}},"required":["itemId","from","to","fromSha","toSha","fields","body"]},"KnowledgePreview":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},"KnowledgeWriteResult":{"type":"object","properties":{"item":{"$ref":"#/components/schemas/KnowledgeItem"},"warnings":{"type":"array","items":{"type":"object","properties":{"rule":{"type":"string"},"detail":{"type":"string"}},"required":["rule","detail"]}}},"required":["item","warnings"]},"CreateKnowledgeBody":{"type":"object","properties":{"scope":{"type":"string","enum":["org","source","group","room"]},"scopeRef":{"type":"string","minLength":1,"maxLength":256},"kind":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"layer":{"type":"string","enum":["core","source","learned","task"]},"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"weight":{"type":"integer","minimum":0,"maximum":100},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"status":{"type":"string","enum":["candidate","approved","active"]},"reason":{"type":"string","maxLength":500},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["scope","kind","layer","title","body"]},"UpdateKnowledgeBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"weight":{"type":"integer","minimum":0,"maximum":100},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"expectedVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true},"reason":{"type":"string","maxLength":500},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["expectedVersion"]},"KnowledgeTransitionBody":{"type":"object","properties":{"to":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"reason":{"type":"string","maxLength":500},"expectedVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["to"]},"RestoreKnowledgeBody":{"type":"object","properties":{"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"expectedVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true},"reason":{"type":"string","maxLength":500},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["version"]},"KnowledgeGovernanceBody":{"type":"object","properties":{"pinned":{"type":"boolean"},"blocked":{"type":"boolean"},"reason":{"type":"string","minLength":1,"maxLength":500},"expectedVersion":{"type":"integer","minimum":0,"exclusiveMinimum":true},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["reason"]},"CreatePlatformKnowledgeBody":{"type":"object","properties":{"scope":{"type":"string","enum":["platform","source_type"]},"scopeRef":{"type":"string","minLength":1,"maxLength":256},"kind":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"layer":{"type":"string","enum":["core","source","learned","task"]},"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100},"weight":{"type":"integer","minimum":0,"maximum":100},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"status":{"type":"string","enum":["candidate","approved","active"]},"reason":{"type":"string","maxLength":500},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["scope","kind","layer","title","body"]},"LearningCandidate":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"scope":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"scopeRef":{"type":"string","nullable":true,"minLength":1,"maxLength":256},"kind":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"layer":{"type":"string","enum":["core","source","learned","task"]},"title":{"type":"string","minLength":1,"maxLength":200},"body":{"type":"string","maxLength":20000},"sources":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":50,"default":[]},"entities":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"triggers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":100,"default":[]},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"maxItems":20},"weight":{"type":"integer","minimum":0,"maximum":100,"default":50},"status":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"statusReason":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"sha":{"type":"string","pattern":"^[0-9a-f]{64}$"},"budgetChars":{"type":"integer","minimum":0,"exclusiveMinimum":true},"origin":{"type":"string","enum":["manual","import","harvest","user_command","eval"]},"evidence":{"type":"array","items":{"type":"object","properties":{"interactionId":{"type":"string","maxLength":200},"turnId":{"type":"string","maxLength":200},"quote":{"type":"string","maxLength":500},"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"}},"required":["at"]},"maxItems":20,"default":[]},"confidence":{"type":"number","minimum":0,"maximum":1},"verifiedAt":{"type":"string","format":"date-time"},"revalidateAfter":{"type":"string","format":"date-time"},"warnings":{"type":"array","items":{"type":"string","maxLength":200},"default":[]},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"approvedBy":{"type":"string","minLength":1,"maxLength":128},"approvedAt":{"type":"string","format":"date-time"},"eval":{"type":"object","properties":{"runId":{"type":"string","minLength":1,"maxLength":200},"verdict":{"type":"string","enum":["pass","fail","inconclusive"]},"at":{"type":"string","format":"date-time"}},"required":["runId","verdict","at"]},"metrics":{"type":"object","properties":{"injected":{"type":"integer","minimum":0,"default":0},"lastInjectedAt":{"type":"string","format":"date-time"}},"default":{"injected":0}},"pinned":{"type":"boolean"},"blocked":{"type":"boolean"}},"required":["id","orgId","scope","scopeRef","kind","layer","title","body","status","version","sha","origin","createdBy","createdAt","updatedBy","updatedAt"]},"LearningPreview":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},"LearningReviewResult":{"type":"object","properties":{"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"from":{"type":"string","nullable":true,"enum":["candidate","approved","active","retired","rejected",null]},"to":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"allowed":{"type":"boolean"},"denied":{"type":"string","nullable":true},"applied":{"type":"boolean"}},"required":["id","from","to","allowed","denied"]}},"applied":{"type":"integer"},"denied":{"type":"integer"}},"required":["results","applied","denied"]},"LearningReviewBody":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":100},"action":{"type":"string","enum":["approve","activate","reject"]},"reason":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["ids","action"]},"LearningIssue":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"type":{"type":"string","enum":["tool_failed","refused","no_answer","slow","huge_context","discovery_loop","turn_error","user_reported","conflict","regression","contradicted","revalidation_due"]},"key":{"type":"string","maxLength":120},"kind":{"type":"string","enum":["real","scheduled","internal"]},"interactionId":{"type":"string","minLength":1,"maxLength":200},"at":{"type":"string","format":"date-time"},"detail":{"type":"string","maxLength":200},"cluster":{"type":"string","maxLength":200},"status":{"type":"string","enum":["open","ack","resolved"]},"origin":{"type":"string","enum":["harvest","import"],"default":"harvest"},"statusReason":{"type":"string","maxLength":500},"statusBy":{"type":"string","minLength":1,"maxLength":128},"statusAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}},"required":["id","orgId","type","key","kind","interactionId","at","detail","cluster","status","createdAt","updatedAt"]},"LearningIssueStatusBody":{"type":"object","properties":{"to":{"type":"string","enum":["open","ack","resolved"]},"reason":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["to"]},"LearningConfig":{"type":"object","nullable":true,"properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"internalPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200,"default":[]},"internalPrefixes":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":20,"default":[]},"scheduledPrefixes":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":20,"default":[]},"autonomy":{"type":"boolean"},"governance":{"type":"object","properties":{"confidenceThreshold":{"type":"number","minimum":0.5,"maximum":1},"evalDailyTokens":{"type":"integer","minimum":0,"maximum":50000000},"evalSample":{"type":"integer","minimum":20,"maximum":200},"evalRepeats":{"type":"integer","minimum":1,"maximum":5},"watchDays":{"type":"integer","minimum":1,"maximum":30},"watchMinTurns":{"type":"integer","minimum":1,"maximum":500}}},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"}},"required":["orgId","updatedBy","updatedAt"]},"LearningConfigBody":{"type":"object","properties":{"internalPrincipals":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200,"default":[]},"internalPrefixes":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":20,"default":[]},"scheduledPrefixes":{"type":"array","items":{"type":"string","minLength":1,"maxLength":120},"maxItems":20,"default":[]},"autonomy":{"type":"boolean"},"governance":{"type":"object","properties":{"confidenceThreshold":{"type":"number","minimum":0.5,"maximum":1},"evalDailyTokens":{"type":"integer","minimum":0,"maximum":50000000},"evalSample":{"type":"integer","minimum":20,"maximum":200},"evalRepeats":{"type":"integer","minimum":1,"maximum":5},"watchDays":{"type":"integer","minimum":1,"maximum":30},"watchMinTurns":{"type":"integer","minimum":1,"maximum":500}}},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"KnowledgeGovernanceRun":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["govern","watch"]},"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"skipped":{"type":"string","maxLength":120},"decisions":{"type":"array","items":{"type":"object","properties":{"itemId":{"type":"string","minLength":1,"maxLength":128},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"scope":{"type":"string","maxLength":40},"kind":{"type":"string","maxLength":40},"decision":{"type":"string","enum":["activated","rejected","conflict","waiting","deferred_budget","retired_regression","retired_contradicted","retired_revalidation","revalidated","revalidation_due","kept","insufficient_sample","skipped"]},"reason":{"type":"string","maxLength":200},"evidenceIds":{"type":"array","items":{"type":"string","maxLength":200},"maxItems":20,"default":[]},"evalRunId":{"type":"string","maxLength":200},"issueId":{"type":"string","maxLength":200}},"required":["itemId","scope","kind","decision","reason"]},"maxItems":500,"default":[]},"counts":{"type":"object","additionalProperties":{"type":"integer","minimum":0},"default":{}},"evalTokens":{"type":"integer","minimum":0,"default":0},"evalTokenCap":{"type":"integer","minimum":0,"default":0},"watchedUntil":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"}},"required":["orgId","kind","day","createdAt"]},"ReportAnswer":{"type":"object","additionalProperties":{"nullable":true},"description":"The service answer (the same one the chat tools get)."},"ReportsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"params":{"type":"object","additionalProperties":{"nullable":true}},"traceId":{"type":"string"}},"required":["error"]},"ReportSchedulePreviewBody":{"type":"object","properties":{"frequency":{"type":"string","enum":["once","dates","every_minutes","hourly","daily","weekly","monthly","custom"],"description":"once · dates · every_minutes (15/20/30/45) · hourly (every N hours) · daily · weekly · monthly · custom (several times a day, weekdays, days of month, nth weekday, months, every N days/weeks)."},"at":{"type":"string","maxLength":40,"description":"once: local \"YYYY-MM-DDTHH:MM\" in the caller's zone."},"in_minutes":{"type":"integer","description":"once, instead of `at`: minutes from now."},"every_minutes":{"type":"integer","description":"every_minutes: 15, 20, 30 or 45."},"every_hours":{"type":"integer","description":"hourly: every N hours (1,2,3,4,6,8,12)."},"minute":{"type":"integer","description":"Minute past the hour, multiple of 5."},"hour":{"type":"integer","description":"daily/weekly/monthly: hour of day 0-23."},"weekday":{"type":"integer","description":"weekly: 0 = Sunday … 6 = Saturday."},"day_of_month":{"type":"integer","description":"monthly: 1-31 (29-31 fall back to a short month's last day)."},"times":{"type":"array","items":{"type":"string","maxLength":5},"maxItems":48,"description":"custom: \"HH:MM\"."},"month_days":{"type":"array","items":{"type":"integer"},"maxItems":32},"months":{"type":"array","items":{"type":"integer"},"maxItems":12},"nth_weekdays":{"type":"array","items":{"type":"string","maxLength":6},"maxItems":10,"description":"custom: \"n:weekday\" (\"1:0\" = first Sunday, \"-1:5\" = last Friday)."},"every_days":{"type":"integer","description":"custom: every N days."},"every_weeks":{"type":"integer","description":"custom: every N weeks."},"anchor_date":{"type":"string","maxLength":10},"dates":{"type":"array","items":{"type":"string","maxLength":40},"maxItems":100},"start_date":{"type":"string","nullable":true,"maxLength":40},"end_date":{"type":"string","nullable":true,"maxLength":40},"max_runs":{"type":"integer","description":"Stop after this many deliveries (0 clears)."},"skip_holidays":{"type":"boolean"},"from_hour":{"type":"integer","description":"every_minutes/hourly: first hour of the window."},"to_hour":{"type":"integer","description":"every_minutes/hourly: last hour of the window (inclusive)."},"days":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"maxItems":7},"timezone":{"type":"string","maxLength":64,"description":"IANA zone for this schedule."},"deliver_when":{"type":"string","enum":["always","notable"],"description":"always = every run delivers; notable = check every run, deliver only when `notable_when` holds (an alert)."},"notable_when":{"type":"string","nullable":true,"maxLength":500}}},"CreateReportBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":120},"prompt":{"type":"string","minLength":1,"maxLength":6000,"description":"What to report, in the person's own words (the brain runs it)."},"frequency":{"type":"string","enum":["once","dates","every_minutes","hourly","daily","weekly","monthly","custom"]},"at":{"type":"string","maxLength":40,"description":"once: local \"YYYY-MM-DDTHH:MM\" in the caller's zone."},"in_minutes":{"type":"integer","description":"once, instead of `at`: minutes from now."},"every_minutes":{"type":"integer","description":"every_minutes: 15, 20, 30 or 45."},"every_hours":{"type":"integer","description":"hourly: every N hours (1,2,3,4,6,8,12)."},"minute":{"type":"integer","description":"Minute past the hour, multiple of 5."},"hour":{"type":"integer","description":"daily/weekly/monthly: hour of day 0-23."},"weekday":{"type":"integer","description":"weekly: 0 = Sunday … 6 = Saturday."},"day_of_month":{"type":"integer","description":"monthly: 1-31 (29-31 fall back to a short month's last day)."},"times":{"type":"array","items":{"type":"string","maxLength":5},"maxItems":48,"description":"custom: \"HH:MM\"."},"month_days":{"type":"array","items":{"type":"integer"},"maxItems":32},"months":{"type":"array","items":{"type":"integer"},"maxItems":12},"nth_weekdays":{"type":"array","items":{"type":"string","maxLength":6},"maxItems":10,"description":"custom: \"n:weekday\" (\"1:0\" = first Sunday, \"-1:5\" = last Friday)."},"every_days":{"type":"integer","description":"custom: every N days."},"every_weeks":{"type":"integer","description":"custom: every N weeks."},"anchor_date":{"type":"string","maxLength":10},"dates":{"type":"array","items":{"type":"string","maxLength":40},"maxItems":100},"start_date":{"type":"string","nullable":true,"maxLength":40},"end_date":{"type":"string","nullable":true,"maxLength":40},"max_runs":{"type":"integer","description":"Stop after this many deliveries (0 clears)."},"skip_holidays":{"type":"boolean"},"from_hour":{"type":"integer","description":"every_minutes/hourly: first hour of the window."},"to_hour":{"type":"integer","description":"every_minutes/hourly: last hour of the window (inclusive)."},"days":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"maxItems":7},"timezone":{"type":"string","maxLength":64,"description":"IANA zone for this schedule."},"deliver_when":{"type":"string","enum":["always","notable"],"description":"always = every run delivers; notable = check every run, deliver only when `notable_when` holds (an alert)."},"notable_when":{"type":"string","nullable":true,"maxLength":500},"followup_context":{"type":"string","maxLength":1500},"destination":{"type":"string","maxLength":400,"description":"A destination id from GET …/reports/destinations; omitted = the only one offered, if exactly one."},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}},"required":["title","prompt","frequency"]},"UpdateReportBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":120},"prompt":{"type":"string","minLength":1,"maxLength":6000},"frequency":{"type":"string","enum":["once","dates","every_minutes","hourly","daily","weekly","monthly","custom"],"description":"once · dates · every_minutes (15/20/30/45) · hourly (every N hours) · daily · weekly · monthly · custom (several times a day, weekdays, days of month, nth weekday, months, every N days/weeks)."},"at":{"type":"string","maxLength":40,"description":"once: local \"YYYY-MM-DDTHH:MM\" in the caller's zone."},"in_minutes":{"type":"integer","description":"once, instead of `at`: minutes from now."},"every_minutes":{"type":"integer","description":"every_minutes: 15, 20, 30 or 45."},"every_hours":{"type":"integer","description":"hourly: every N hours (1,2,3,4,6,8,12)."},"minute":{"type":"integer","description":"Minute past the hour, multiple of 5."},"hour":{"type":"integer","description":"daily/weekly/monthly: hour of day 0-23."},"weekday":{"type":"integer","description":"weekly: 0 = Sunday … 6 = Saturday."},"day_of_month":{"type":"integer","description":"monthly: 1-31 (29-31 fall back to a short month's last day)."},"times":{"type":"array","items":{"type":"string","maxLength":5},"maxItems":48,"description":"custom: \"HH:MM\"."},"month_days":{"type":"array","items":{"type":"integer"},"maxItems":32},"months":{"type":"array","items":{"type":"integer"},"maxItems":12},"nth_weekdays":{"type":"array","items":{"type":"string","maxLength":6},"maxItems":10,"description":"custom: \"n:weekday\" (\"1:0\" = first Sunday, \"-1:5\" = last Friday)."},"every_days":{"type":"integer","description":"custom: every N days."},"every_weeks":{"type":"integer","description":"custom: every N weeks."},"anchor_date":{"type":"string","maxLength":10},"dates":{"type":"array","items":{"type":"string","maxLength":40},"maxItems":100},"start_date":{"type":"string","nullable":true,"maxLength":40},"end_date":{"type":"string","nullable":true,"maxLength":40},"max_runs":{"type":"integer","description":"Stop after this many deliveries (0 clears)."},"skip_holidays":{"type":"boolean"},"from_hour":{"type":"integer","description":"every_minutes/hourly: first hour of the window."},"to_hour":{"type":"integer","description":"every_minutes/hourly: last hour of the window (inclusive)."},"days":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"maxItems":7},"timezone":{"type":"string","maxLength":64,"description":"IANA zone for this schedule."},"deliver_when":{"type":"string","enum":["always","notable"],"description":"always = every run delivers; notable = check every run, deliver only when `notable_when` holds (an alert)."},"notable_when":{"type":"string","nullable":true,"maxLength":500},"active":{"type":"boolean","description":"false = pause, true = resume."},"destination":{"type":"string","maxLength":400},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}}},"ReportConfirmBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}}},"ReportTimezoneBody":{"type":"object","properties":{"timezone":{"type":"string","minLength":1,"maxLength":64},"scope":{"type":"string","enum":["me","org"],"default":"me"},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}},"required":["timezone"]},"AlertAnswer":{"type":"object","additionalProperties":{"nullable":true}},"AlertsError":{"type":"object","properties":{"error":{"type":"string"},"params":{"type":"object","additionalProperties":{"nullable":true}},"traceId":{"type":"string"}},"required":["error"]},"CreateAlertBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":120},"source":{"$ref":"#/components/schemas/AlertSource"},"condition":{"$ref":"#/components/schemas/AlertCondition"},"severity":{"type":"string","enum":["low","medium","high"],"default":"medium"},"policy":{"$ref":"#/components/schemas/AlertPolicy"},"once":{"type":"boolean"},"frequency":{"type":"string","enum":["once","dates","every_minutes","hourly","daily","weekly","monthly","custom"]},"at":{"type":"string","maxLength":40,"description":"once: local \"YYYY-MM-DDTHH:MM\" in the caller's zone."},"in_minutes":{"type":"integer","description":"once, instead of `at`: minutes from now."},"every_minutes":{"type":"integer","description":"every_minutes: 15, 20, 30 or 45."},"every_hours":{"type":"integer","description":"hourly: every N hours (1,2,3,4,6,8,12)."},"minute":{"type":"integer","description":"Minute past the hour, multiple of 5."},"hour":{"type":"integer","description":"daily/weekly/monthly: hour of day 0-23."},"weekday":{"type":"integer","description":"weekly: 0 = Sunday … 6 = Saturday."},"day_of_month":{"type":"integer","description":"monthly: 1-31 (29-31 fall back to a short month's last day)."},"times":{"type":"array","items":{"type":"string","maxLength":5},"maxItems":48,"description":"custom: \"HH:MM\"."},"month_days":{"type":"array","items":{"type":"integer"},"maxItems":32},"months":{"type":"array","items":{"type":"integer"},"maxItems":12},"nth_weekdays":{"type":"array","items":{"type":"string","maxLength":6},"maxItems":10,"description":"custom: \"n:weekday\" (\"1:0\" = first Sunday, \"-1:5\" = last Friday)."},"every_days":{"type":"integer","description":"custom: every N days."},"every_weeks":{"type":"integer","description":"custom: every N weeks."},"anchor_date":{"type":"string","maxLength":10},"dates":{"type":"array","items":{"type":"string","maxLength":40},"maxItems":100},"start_date":{"type":"string","nullable":true,"maxLength":40},"end_date":{"type":"string","nullable":true,"maxLength":40},"max_runs":{"type":"integer","description":"Stop after this many deliveries (0 clears)."},"skip_holidays":{"type":"boolean"},"from_hour":{"type":"integer","description":"every_minutes/hourly: first hour of the window."},"to_hour":{"type":"integer","description":"every_minutes/hourly: last hour of the window (inclusive)."},"days":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"maxItems":7},"timezone":{"type":"string","maxLength":64,"description":"IANA zone for this schedule."},"destination":{"type":"string","maxLength":400},"born_from":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}},"required":["title","source","condition","frequency"]},"AlertSource":{"type":"object","properties":{"tool":{"type":"string","minLength":1,"maxLength":128,"description":"A read-only tool of a connected source, as the owner has it."},"connector":{"type":"string","nullable":true,"maxLength":128},"args":{"type":"object","additionalProperties":{"nullable":true}},"value_path":{"type":"string","nullable":true,"maxLength":200,"description":"Dot path to the number; absent = the first row's measure."},"rows_path":{"type":"string","nullable":true,"maxLength":200,"description":"Dot path to the list counted as rows; absent = the largest list."}},"required":["tool"]},"AlertCondition":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["threshold"]},"op":{"type":"string","enum":["gt","gte","lt","lte"]},"value":{"type":"number"}},"required":["kind","op","value"]},{"type":"object","properties":{"kind":{"type":"string","enum":["delta_wow"]},"direction":{"type":"string","enum":["up","down","any"],"default":"any"},"pct":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1000}},"required":["kind","pct"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rows"]},"minRows":{"type":"integer","minimum":1,"maximum":1000000}},"required":["kind","minRows"]}],"description":"threshold (the value vs a bound) · delta_wow (week-over-week, confirmed by the median) · rows (at least N rows). Evaluated by the engine, never a model."},"AlertPolicy":{"type":"object","properties":{"onDelay":{"type":"integer","minimum":1,"maximum":10},"offDelay":{"type":"integer","minimum":1,"maximum":10},"notifyClear":{"type":"boolean"},"renotifyAfterH":{"type":"integer","minimum":0,"maximum":168},"dailyCap":{"type":"integer","minimum":1,"maximum":48},"quietHours":{"type":"object","nullable":true,"properties":{"from":{"type":"integer","minimum":0,"maximum":23},"to":{"type":"integer","minimum":0,"maximum":23}},"required":["from","to"]}},"description":"ISA-18.2, adapted: fired checks in a row before raising (onDelay), clear checks before clearing (offDelay), \"back to normal\" line, reminder interval for an unacknowledged episode, messages per day, quiet hours (non-high messages wait)."},"UpdateAlertBody":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":120},"source":{"$ref":"#/components/schemas/AlertSource"},"condition":{"$ref":"#/components/schemas/AlertCondition"},"severity":{"type":"string","enum":["low","medium","high"]},"policy":{"$ref":"#/components/schemas/AlertPolicy"},"frequency":{"type":"string","enum":["once","dates","every_minutes","hourly","daily","weekly","monthly","custom"],"description":"once · dates · every_minutes (15/20/30/45) · hourly (every N hours) · daily · weekly · monthly · custom (several times a day, weekdays, days of month, nth weekday, months, every N days/weeks)."},"at":{"type":"string","maxLength":40,"description":"once: local \"YYYY-MM-DDTHH:MM\" in the caller's zone."},"in_minutes":{"type":"integer","description":"once, instead of `at`: minutes from now."},"every_minutes":{"type":"integer","description":"every_minutes: 15, 20, 30 or 45."},"every_hours":{"type":"integer","description":"hourly: every N hours (1,2,3,4,6,8,12)."},"minute":{"type":"integer","description":"Minute past the hour, multiple of 5."},"hour":{"type":"integer","description":"daily/weekly/monthly: hour of day 0-23."},"weekday":{"type":"integer","description":"weekly: 0 = Sunday … 6 = Saturday."},"day_of_month":{"type":"integer","description":"monthly: 1-31 (29-31 fall back to a short month's last day)."},"times":{"type":"array","items":{"type":"string","maxLength":5},"maxItems":48,"description":"custom: \"HH:MM\"."},"month_days":{"type":"array","items":{"type":"integer"},"maxItems":32},"months":{"type":"array","items":{"type":"integer"},"maxItems":12},"nth_weekdays":{"type":"array","items":{"type":"string","maxLength":6},"maxItems":10,"description":"custom: \"n:weekday\" (\"1:0\" = first Sunday, \"-1:5\" = last Friday)."},"every_days":{"type":"integer","description":"custom: every N days."},"every_weeks":{"type":"integer","description":"custom: every N weeks."},"anchor_date":{"type":"string","maxLength":10},"dates":{"type":"array","items":{"type":"string","maxLength":40},"maxItems":100},"start_date":{"type":"string","nullable":true,"maxLength":40},"end_date":{"type":"string","nullable":true,"maxLength":40},"max_runs":{"type":"integer","description":"Stop after this many deliveries (0 clears)."},"skip_holidays":{"type":"boolean"},"from_hour":{"type":"integer","description":"every_minutes/hourly: first hour of the window."},"to_hour":{"type":"integer","description":"every_minutes/hourly: last hour of the window (inclusive)."},"days":{"type":"array","items":{"type":"integer","minimum":0,"maximum":6},"maxItems":7},"timezone":{"type":"string","maxLength":64,"description":"IANA zone for this schedule."},"destination":{"type":"string","maxLength":400},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}}},"AlertConfirmBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}}},"AlertShelveBody":{"type":"object","properties":{"hours":{"type":"integer","minimum":1,"maximum":168},"confirm":{"type":"boolean","default":false,"description":"false (default) = preview, nothing changes; true = act."}},"required":["hours"]},"ChatBody":{"type":"object","properties":{"message":{"type":"string","minLength":1,"maxLength":20000},"thread":{"type":"string","minLength":1,"maxLength":200},"mode":{"type":"string","enum":["lean","full"]},"attachments":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["image","pdf","audio","video","file"]},"mimeType":{"type":"string","minLength":1,"maxLength":120},"data":{"type":"string","maxLength":20000000},"uri":{"type":"string","format":"uri"},"name":{"type":"string","maxLength":200},"bytes":{"type":"integer","minimum":0}},"required":["kind","mimeType"]},"maxItems":10},"lang":{"type":"string","enum":["he","en","pt"]}},"required":["message"]},"ChatThread":{"type":"object","properties":{"id":{"type":"string"},"orgId":{"type":"string"},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"principalId":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"turnCount":{"type":"integer"},"startedAt":{"type":"string","nullable":true},"updatedAt":{"type":"string","nullable":true},"hasSummary":{"type":"boolean"}},"required":["id","orgId","channel","principalId","title","turnCount","startedAt","updatedAt","hasSummary"]},"ChatThreadDetail":{"allOf":[{"$ref":"#/components/schemas/ChatThread"},{"type":"object","properties":{"turns":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["user","model"]},"text":{"type":"string"},"at":{"type":"string"},"media":{"type":"array","items":{"type":"object","properties":{"mimeType":{"type":"string"},"uri":{"type":"string"}},"required":["mimeType"]}}},"required":["role","text","at"]}},"summary":{"type":"string","nullable":true}},"required":["turns","summary"]}]},"UploadedAttachment":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"mime":{"type":"string"},"size":{"type":"integer","minimum":0},"url":{"type":"string"}},"required":["id","name","mime","size","url"]},"McpToolCalls":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string"},"surface":{"type":"string"},"principalId":{"type":"string","nullable":true},"ok":{"type":"boolean"},"client":{"type":"object","properties":{"name":{"type":"string","nullable":true},"via":{"type":"string","enum":["oauth","token","key"]}},"required":["name","via"]},"kind":{"type":"string"},"label":{"type":"string"}},"required":["id","at","surface","principalId","ok","client","kind","label"]}}},"required":["rows"]},"Activity":{"type":"object","properties":{"kind":{"type":"string","enum":["turns","denials","audit"]},"rows":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"turn_id":{"type":"string"},"started_at":{"type":"string"},"event_time":{"type":"string"},"channel":{"type":"string"},"org_id":{"type":"string","nullable":true},"user_id":{"type":"string","nullable":true},"principal_id":{"type":"string","nullable":true},"conversation_ref":{"type":"string","nullable":true},"outcome":{"type":"string"},"content_policy":{"type":"string"},"question_preview":{"type":"string","nullable":true},"answer_preview":{"type":"string","nullable":true},"is_group":{"type":"boolean","nullable":true},"speaker_principal_id":{"type":"string","nullable":true},"speaker_name":{"type":"string","nullable":true},"tool_count":{"type":"number"},"denial_count":{"type":"number"},"input":{"type":"object","properties":{"kind":{"type":"string","nullable":true},"media_count":{"type":"number"}},"required":["kind","media_count"]},"output":{"type":"object","properties":{"media_count":{"type":"number"},"formats":{"type":"array","items":{"type":"string"}}},"required":["media_count","formats"]},"credits":{"type":"number"},"sources":{"type":"array","items":{"type":"string"}}},"required":["turn_id","started_at","channel","outcome"]},{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string"},"orgId":{"type":"string"},"principalId":{"type":"string","nullable":true},"channel":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"where":{"type":"string","nullable":true}},"required":["id","at","orgId","principalId","channel","code","name","where"]},{"type":"object","properties":{"id":{"type":"string","minLength":1},"at":{"type":"string","format":"date-time"},"org_id":{"type":"string","minLength":1},"principal_id":{"type":"string","minLength":1},"principal_kind":{"type":"string"},"role":{"type":"string"},"channel":{"type":"string"},"trace_id":{"type":"string","minLength":1},"action":{"type":"string","minLength":1,"maxLength":120},"target":{"type":"object","properties":{"kind":{"type":"string","minLength":1},"id":{"type":"string","minLength":1}},"required":["kind","id"]},"confirm":{"type":"boolean"},"result":{"type":"string","enum":["preview","applied","denied","failed"]},"before":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"after":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"message":{"type":"string","nullable":true,"maxLength":500},"ip":{"type":"string","maxLength":64},"user_agent":{"type":"string","maxLength":300}},"required":["id","at","org_id","principal_id","principal_kind","role","channel","trace_id","action","target","confirm","result","before","after","message"]}]}}},"required":["kind","rows"]},"Usage":{"type":"object","properties":{"granularity":{"type":"string","enum":["day"]},"rows":{"type":"array","items":{"type":"object","properties":{"org_id":{"type":"string"},"principal_id":{"type":"string","nullable":true},"channel":{"type":"string"},"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"turns":{"type":"integer","minimum":0},"failed":{"type":"integer","minimum":0},"refused":{"type":"integer","minimum":0},"tokens_input":{"type":"integer","minimum":0},"tokens_output":{"type":"integer","minimum":0},"tokens_cached":{"type":"integer","minimum":0},"tokens_thinking":{"type":"integer","minimum":0},"credits":{"type":"number","minimum":0,"default":0},"tool_calls":{"type":"integer","minimum":0},"denials":{"type":"integer","minimum":0},"model_ms":{"type":"integer","minimum":0},"total_ms":{"type":"integer","minimum":0},"updated_at":{"type":"string","format":"date-time"}},"required":["org_id","principal_id","channel","day","turns","failed","refused","tokens_input","tokens_output","tokens_cached","tokens_thinking","tool_calls","denials","model_ms","total_ms","updated_at"]}},"totals":{"type":"object","properties":{"turns":{"type":"number"},"credits":{"type":"number"},"tool_calls":{"type":"number"},"tokens_input":{"type":"number"},"tokens_output":{"type":"number"},"tokens_cached":{"type":"number"}},"required":["turns","credits","tool_calls","tokens_input","tokens_output","tokens_cached"]}},"required":["granularity","rows","totals"]},"Credits":{"type":"object","properties":{"orgId":{"type":"string"},"month":{"type":"string"},"credits":{"type":"number"},"turns":{"type":"number"},"updatedAt":{"type":"string","nullable":true}},"required":["orgId","month","credits","turns","updatedAt"]},"UsageBreakdown":{"type":"object","properties":{"by":{"type":"string","enum":["channel","person","group","source"]},"metric":{"type":"string","enum":["messages","credits"]},"days":{"type":"array","items":{"type":"string"}},"series":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string","nullable":true},"values":{"type":"array","items":{"type":"number"}},"total":{"type":"number"}},"required":["key","label","values","total"]}},"total":{"type":"number"},"scope":{"type":"string","enum":["org","self"]},"connectorId":{"type":"string"},"scanned":{"type":"number"},"truncated":{"type":"boolean"},"reservedKeys":{"type":"object","properties":{"none":{"type":"string"},"unknown":{"type":"string"},"other":{"type":"string"},"warehouse":{"type":"string"}},"required":["none","unknown","other","warehouse"]}},"required":["by","metric","days","series","total","scope","scanned","truncated","reservedKeys"]},"UsageSummary":{"type":"object","properties":{"range":{"type":"string","enum":["today","7d","30d"]},"tz":{"type":"string"},"fromDay":{"type":"string"},"toDay":{"type":"string"},"from":{"type":"string"},"messages":{"type":"number"},"credits":{"type":"number"},"people":{"type":"number"},"denials":{"type":"number","nullable":true},"truncated":{"type":"boolean"},"asOf":{"type":"string"}},"required":["range","tz","fromDay","toDay","from","messages","credits","people","denials","truncated","asOf"]},"CreditVisibilitySwitches":{"type":"object","properties":{"balance":{"type":"boolean"},"budgets":{"type":"boolean"},"breakdown":{"type":"boolean"},"alerts":{"type":"boolean"},"agent":{"type":"boolean"}},"required":["balance","budgets","breakdown","alerts","agent"]},"CreditSummary":{"type":"object","properties":{"balance":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0},"consumed":{"type":"number","minimum":0},"allowance_left":{"type":"number","minimum":0},"grants_total":{"type":"number"},"granted_left":{"type":"number"},"available":{"type":"number"},"exhausted":{"type":"boolean"},"used_pct":{"type":"number","nullable":true,"minimum":0}},"required":["org_id","month","allowance","consumed","allowance_left","grants_total","granted_left","available","exhausted","used_pct"]},"plan":{"type":"string","nullable":true},"caps":{"type":"object","properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["soft","hard"],"description":"The per-question caps in force (credits)."},"onExhausted":{"type":"string","enum":["allow","lean","block"]},"history":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"available":{"type":"number"},"consumed":{"type":"number"}},"required":["day","available","consumed"]}},"includedByPlan":{"type":"boolean"},"overagePct":{"type":"number"},"forecast":{"type":"object","nullable":true,"properties":{"period":{"type":"string"},"used":{"type":"number","minimum":0},"daily_rate":{"type":"number","minimum":0},"rate_days":{"type":"integer","minimum":0},"days_left":{"type":"integer","minimum":0},"projected":{"type":"number","minimum":0},"limit":{"type":"number","nullable":true},"projected_pct":{"type":"number","nullable":true,"minimum":0},"runs_out_on":{"type":"string","nullable":true,"pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["period","used","daily_rate","rate_days","days_left","projected","limit","projected_pct","runs_out_on"]}},"required":["balance","plan","caps","onExhausted","history","includedByPlan","overagePct","forecast"]},"CreditBreakdown":{"type":"object","properties":{"by":{"type":"string","enum":["channel","person","group","source","agent","report","line","module"]},"from":{"type":"string"},"to":{"type":"string"},"total":{"type":"object","properties":{"credits":{"type":"number"},"messages":{"type":"number"}},"required":["credits","messages"]},"rows":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string","nullable":true},"credits":{"type":"number"},"messages":{"type":"number"}},"required":["key","label","credits","messages"]}},"truncated":{"type":"boolean","description":"The scan stopped at its cap: older messages of the range were not read."}},"required":["by","from","to","total","rows","truncated"]},"CreditBudgets":{"type":"object","properties":{"budgets":{"type":"array","items":{"type":"object","properties":{"budget_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"scope":{"type":"string","enum":["org","group","person","channel","agent"]},"scope_id":{"type":"string","nullable":true,"maxLength":200},"period":{"type":"string","enum":["day","month"]},"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true},"on_exceed":{"type":"string","enum":["warn","cap","block"],"default":"warn"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"alert_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"enabled":{"type":"boolean","default":true},"label":{"type":"string","nullable":true,"maxLength":120,"default":null},"created_by":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_by":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["budget_id","org_id","scope","scope_id","period","limit","created_by","created_at","updated_by","updated_at"]}},"usage":{"type":"object","additionalProperties":{"type":"number"},"description":"Credits consumed in each budget’s current period, by budget id."},"state":{"type":"object","additionalProperties":{"type":"string","enum":["under","over","overage","capped","blocked"]}},"forecast":{"type":"object","additionalProperties":{"type":"object","properties":{"period":{"type":"string"},"used":{"type":"number","minimum":0},"daily_rate":{"type":"number","minimum":0},"rate_days":{"type":"integer","minimum":0},"days_left":{"type":"integer","minimum":0},"projected":{"type":"number","minimum":0},"limit":{"type":"number","nullable":true},"projected_pct":{"type":"number","nullable":true,"minimum":0},"runs_out_on":{"type":"string","nullable":true,"pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["period","used","daily_rate","rate_days","days_left","projected","limit","projected_pct","runs_out_on"]}},"caps":{"$ref":"#/components/schemas/CreditCapsView"}},"required":["budgets","usage","state","forecast","caps"]},"CreditCapsView":{"type":"object","properties":{"org":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["soft","hard"]},"ceiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"number"},"hard":{"type":"number"}}},"effective":{"type":"object","properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["soft","hard"]},"applied":{"type":"boolean"},"source":{"type":"string","enum":["default","org","ceiling"]}},"required":["org","ceiling","effective","applied","source"]},"CreditBudgetPutResult":{"type":"object","properties":{"budget":{"type":"object","properties":{"budget_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"scope":{"type":"string","enum":["org","group","person","channel","agent"]},"scope_id":{"type":"string","nullable":true,"maxLength":200},"period":{"type":"string","enum":["day","month"]},"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true},"on_exceed":{"type":"string","enum":["warn","cap","block"],"default":"warn"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"alert_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"enabled":{"type":"boolean","default":true},"label":{"type":"string","nullable":true,"maxLength":120,"default":null},"created_by":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_by":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["budget_id","org_id","scope","scope_id","period","limit","created_by","created_at","updated_by","updated_at"]}},"required":["budget"]},"CreditBudgetPutBody":{"type":"object","properties":{"budget":{"$ref":"#/components/schemas/CreditBudgetInput"}},"required":["budget"]},"CreditBudgetInput":{"type":"object","properties":{"budget_id":{"type":"string","minLength":1,"maxLength":64,"description":"Present = replace this budget of the org; absent = a new one."},"scope":{"type":"string","enum":["org","group","person","channel","agent"]},"scope_id":{"type":"string","nullable":true,"minLength":1,"maxLength":200,"description":"group id, member principal id or channel name; omitted/null for `org`. Must belong to the org."},"period":{"type":"string","enum":["day","month"]},"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":1000000000},"on_exceed":{"type":"string","enum":["warn","cap","block"],"description":"`warn` alerts only · `cap` runs through the overage, then keeps basic chat alive and blocks heavy work · `block` refuses at the limit."},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"description":"`cap` only: % past the limit before the hard cap (default 20)."},"alert_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5},"enabled":{"type":"boolean"},"label":{"type":"string","nullable":true,"maxLength":120}},"required":["scope","period","limit"]},"CreditBudgetDeleted":{"type":"object","properties":{"deleted":{"type":"boolean","enum":[true]}},"required":["deleted"]},"CreditCapsPutResult":{"type":"object","properties":{"caps":{"$ref":"#/components/schemas/CreditCapsView"}},"required":["caps"]},"CreditCapsPutBody":{"type":"object","properties":{"caps":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["soft","hard"]}},"required":["caps"]},"CreditTrend":{"type":"object","properties":{"month":{"type":"string"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"credits":{"type":"number"}},"required":["day","credits"]}},"previous":{"type":"object","properties":{"month":{"type":"string"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"credits":{"type":"number"}},"required":["day","credits"]}},"total":{"type":"number"}},"required":["month","days","total"]},"forecast":{"type":"object","properties":{"period":{"type":"string"},"used":{"type":"number","minimum":0},"daily_rate":{"type":"number","minimum":0},"rate_days":{"type":"integer","minimum":0},"days_left":{"type":"integer","minimum":0},"projected":{"type":"number","minimum":0},"limit":{"type":"number","nullable":true},"projected_pct":{"type":"number","nullable":true,"minimum":0},"runs_out_on":{"type":"string","nullable":true,"pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["period","used","daily_rate","rate_days","days_left","projected","limit","projected_pct","runs_out_on"]}},"required":["month","days","previous","forecast"]},"CreditAlertFeed":{"type":"object","properties":{"alerts":{"type":"array","items":{"type":"object","properties":{"alert_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["soft_cap","hard_cap","exhausted_refused","exhausted_lean","exhausted_overage","budget_refused","budget_exceeded_warn","budget_overage","budget_capped","budget_threshold","balance_threshold","report_blocked","approval_asked","approval_given"]},"threshold":{"type":"number","nullable":true},"period":{"type":"string"},"scope":{"type":"string","nullable":true,"default":null},"scope_id":{"type":"string","nullable":true,"default":null},"budget_id":{"type":"string","nullable":true,"default":null},"used":{"type":"number","nullable":true,"default":null},"limit":{"type":"number","nullable":true,"default":null},"used_pct":{"type":"number","nullable":true,"default":null},"available":{"type":"number","nullable":true,"default":null},"person":{"type":"string","nullable":true,"default":null},"channel":{"type":"string","nullable":true,"default":null},"agent":{"type":"string","nullable":true,"default":null},"delivered":{"type":"object","properties":{"email":{"type":"integer","minimum":0,"default":0},"whatsapp":{"type":"integer","minimum":0,"default":0},"room":{"type":"boolean","default":false}},"default":{"email":0,"whatsapp":0,"room":false}},"created_at":{"type":"string","format":"date-time"}},"required":["alert_id","org_id","kind","threshold","period","created_at"]}}},"required":["alerts"]},"CreditControls":{"type":"object","properties":{"alertThresholdsPct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5},"questionSoftAction":{"type":"string","enum":["warn","ask"]},"alertChannels":{"type":"object","properties":{"email":{"type":"boolean"},"room":{"type":"string","nullable":true},"whatsapp":{"type":"boolean","description":"Set by the platform only (owner approval)."}},"required":["email","room","whatsapp"]},"rooms":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"label":{"type":"string","nullable":true}},"required":["id","label"]}},"version":{"type":"number"}},"required":["alertThresholdsPct","questionSoftAction","alertChannels","rooms","version"]},"CreditControlsInput":{"type":"object","properties":{"alertThresholdsPct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"minItems":1,"maxItems":5},"questionSoftAction":{"type":"string","enum":["warn","ask"]},"alertChannels":{"type":"object","properties":{"email":{"type":"boolean"},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300}}},"expectedVersion":{"type":"integer","minimum":0}}},"ModuleMetrics":{"type":"object","properties":{"ref":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string"},"orgId":{"type":"string","nullable":true},"instanceId":{"type":"string","nullable":true},"from":{"type":"string"},"to":{"type":"string"},"totals":{"type":"object","properties":{"calls":{"type":"number","minimum":0},"errors":{"type":"number","minimum":0},"errorRate":{"type":"number","minimum":0},"avgMs":{"type":"number","minimum":0},"maxMs":{"type":"number","minimum":0},"bytes":{"type":"number","minimum":0},"costUsd":{"type":"number","minimum":0}},"required":["calls","errors","errorRate","avgMs","maxMs","bytes"]},"days":{"type":"array","items":{"type":"object","properties":{"calls":{"type":"number","minimum":0},"errors":{"type":"number","minimum":0},"errorRate":{"type":"number","minimum":0},"avgMs":{"type":"number","minimum":0},"maxMs":{"type":"number","minimum":0},"bytes":{"type":"number","minimum":0},"costUsd":{"type":"number","minimum":0},"day":{"type":"string"}},"required":["calls","errors","errorRate","avgMs","maxMs","bytes","day"]}},"ops":{"type":"array","items":{"type":"object","properties":{"calls":{"type":"number","minimum":0},"errors":{"type":"number","minimum":0},"errorRate":{"type":"number","minimum":0},"avgMs":{"type":"number","minimum":0},"maxMs":{"type":"number","minimum":0},"bytes":{"type":"number","minimum":0},"costUsd":{"type":"number","minimum":0},"op":{"type":"string"}},"required":["calls","errors","errorRate","avgMs","maxMs","bytes","op"]}},"instances":{"type":"array","items":{"type":"object","properties":{"calls":{"type":"number","minimum":0},"errors":{"type":"number","minimum":0},"errorRate":{"type":"number","minimum":0},"avgMs":{"type":"number","minimum":0},"maxMs":{"type":"number","minimum":0},"bytes":{"type":"number","minimum":0},"costUsd":{"type":"number","minimum":0},"instanceId":{"type":"string"},"orgId":{"type":"string"},"lastCallAt":{"type":"string","nullable":true},"lastErrorCode":{"type":"string","nullable":true}},"required":["calls","errors","errorRate","avgMs","maxMs","bytes","instanceId","lastCallAt","lastErrorCode"]}},"errorCodes":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string"},"count":{"type":"number","minimum":0}},"required":["code","count"]}},"lastCallAt":{"type":"string","nullable":true},"lastErrorAt":{"type":"string","nullable":true},"lastErrorCode":{"type":"string","nullable":true},"health":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"checkedAt":{"type":"string","format":"date-time"},"errorCode":{"type":"string","maxLength":64},"instances":{"type":"integer","minimum":0},"failing":{"type":"integer","minimum":0}},"required":["status"]},"healthChecks":{"type":"array","items":{"type":"object","properties":{"instanceId":{"type":"string","nullable":true},"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"source":{"type":"string"},"probe":{"type":"string"},"checkedAt":{"type":"string"},"changedAt":{"type":"string"},"errorCode":{"type":"string","nullable":true}},"required":["instanceId","status","source","probe","checkedAt","changedAt","errorCode"]}}},"required":["ref","kind","id","orgId","instanceId","from","to","totals","days","ops","instances","errorCodes","lastCallAt","lastErrorAt","lastErrorCode","health","healthChecks"]},"ConnectorsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["error"]},"Connector":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"type":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":120},"state":{"type":"string","enum":["draft","testing","discovered","syncing","live","degraded","disconnected"],"default":"draft"},"enabled":{"type":"boolean","default":true},"config":{"type":"object","additionalProperties":{"nullable":true},"default":{}},"schedule":{"type":"string","maxLength":32},"lastTestedAt":{"type":"string","format":"date-time"},"lastTestOk":{"type":"boolean"},"tableCount":{"type":"integer","nullable":true,"minimum":0},"sampleTables":{"type":"array","nullable":true,"items":{"type":"string"},"maxItems":50},"lastDiscoveredAt":{"type":"string","format":"date-time"},"discoveredSchema":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","maxLength":4000},"columns":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"type":{"type":"string","minLength":1,"default":"STRING"},"description":{"type":"string","maxLength":1024},"nullable":{"type":"boolean"},"primaryKey":{"type":"boolean"}},"required":["name"]},"default":[]},"rowCountEstimate":{"type":"integer","minimum":0},"cursorColumn":{"type":"string"},"kind":{"type":"string","enum":["table","view"]}},"required":["name"]},"default":[]},"discoveredAt":{"type":"string","format":"date-time"},"truncated":{"type":"boolean","default":false}},"required":["discoveredAt"]},"discoveredAt":{"type":"string","format":"date-time"},"lastSyncAt":{"type":"string","format":"date-time"},"lastSyncStatus":{"type":"string","enum":["succeeded","partial","failed"]},"lastErrorCode":{"type":"string","nullable":true,"maxLength":64},"lastErrorParams":{"type":"object","nullable":true,"additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"consecutiveFailures":{"type":"integer","minimum":0,"default":0},"selectedTables":{"type":"array","nullable":true,"items":{"type":"string","minLength":1,"maxLength":1024},"maxItems":2000},"remote":{"type":"object","properties":{"service":{"type":"string","format":"uri"},"audience":{"type":"string","format":"uri"},"major":{"type":"integer","minimum":0},"endpoint":{"type":"string","format":"uri"},"secrets":{"type":"string","enum":["core","customer"]},"revisionTag":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,45}$"}},"required":["service","audience","major"]},"cursor":{"type":"string","maxLength":4096},"selection":{"type":"object","properties":{"resources":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":5000},"default":{}},"newResources":{"type":"string","enum":["ask","include","ignore"]}}},"enabledActions":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"maxItems":200},"identityKind":{"type":"string","enum":["service_user","personal_temporary"]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"secrets":{"type":"array","items":{"type":"string"}},"lastTestErrorCode":{"type":"string"}},"required":["id","orgId","type","name","createdAt","secrets"]},"ConnectorCreate":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"type":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":120},"fields":{"type":"object","additionalProperties":{"nullable":true},"default":{}},"schedule":{"type":"string","maxLength":32}},"required":["type","name"]},"ConnectorPatch":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"schedule":{"type":"string","nullable":true,"maxLength":32},"enabled":{"type":"boolean"},"fields":{"type":"object","additionalProperties":{"nullable":true}}}},"Confirm":{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}},"ConnectorTest":{"type":"object","properties":{"ok":{"type":"boolean"},"tableCount":{"type":"integer","minimum":0},"sampleTables":{"type":"array","items":{"type":"string"}},"errorCode":{"type":"string"},"errorParams":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["ok"]},"ConnectorSync":{"type":"object","properties":{"mode":{"type":"string","enum":["full","incremental"],"default":"full"},"since":{"type":"string","format":"date-time"},"tables":{"type":"array","items":{"type":"string"},"maxItems":500}}},"ChannelsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"params":{"type":"object","additionalProperties":{"type":"string"}},"traceId":{"type":"string"}},"required":["error","traceId"]},"ChannelBindingCreate":{"allOf":[{"$ref":"#/components/schemas/ChannelBindingWrite"},{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}}]},"ChannelBindingWrite":{"type":"object","properties":{"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"externalId":{"type":"string","minLength":1,"maxLength":256},"displayName":{"type":"string","maxLength":200},"config":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"secretRefs":{"type":"object","additionalProperties":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":256},"version":{"type":"string","maxLength":32,"default":"latest"}},"required":["name"]}},"secrets":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":8192}},"rooms":{"type":"array","items":{"type":"object","properties":{"roomId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":200},"active":{"type":"boolean","default":true},"membersOnly":{"type":"boolean","default":false},"mediaOpen":{"type":"boolean","default":false},"dedicated":{"type":"boolean","default":false},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"boundBy":{"type":"string","minLength":1,"maxLength":128},"boundAt":{"type":"string","format":"date-time"},"orgId":{"type":"string","minLength":1,"maxLength":128},"settings":{"type":"object","additionalProperties":{"nullable":true}}},"required":["roomId"]}},"membersOnly":{"type":"boolean"},"mediaOpen":{"type":"boolean"},"dedicated":{"type":"boolean"},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64}},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64}},"status":{"type":"string","enum":["pending","active","disabled","error"]},"breakGlassReason":{"type":"string","maxLength":500}},"required":["channel","externalId"]},"ChannelBindingPatch":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"patch":{"type":"object","properties":{"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"externalId":{"type":"string","minLength":1,"maxLength":256},"displayName":{"type":"string","maxLength":200},"config":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"secretRefs":{"type":"object","additionalProperties":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":256},"version":{"type":"string","maxLength":32,"default":"latest"}},"required":["name"]}},"secrets":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":8192}},"rooms":{"type":"array","items":{"type":"object","properties":{"roomId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":200},"active":{"type":"boolean","default":true},"membersOnly":{"type":"boolean","default":false},"mediaOpen":{"type":"boolean","default":false},"dedicated":{"type":"boolean","default":false},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"boundBy":{"type":"string","minLength":1,"maxLength":128},"boundAt":{"type":"string","format":"date-time"},"orgId":{"type":"string","minLength":1,"maxLength":128},"settings":{"type":"object","additionalProperties":{"nullable":true}}},"required":["roomId"]}},"membersOnly":{"type":"boolean"},"mediaOpen":{"type":"boolean"},"dedicated":{"type":"boolean"},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64}},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64}},"status":{"type":"string","enum":["pending","active","disabled","error"]},"breakGlassReason":{"type":"string","maxLength":500}}}},"required":["patch"]},"ChannelPlatformCheck":{"type":"object","properties":{"key":{"type":"string"},"ok":{"type":"boolean"},"required":{"type":"boolean"},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["key","ok","required"]},"ChannelRoomsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"params":{"type":"object","additionalProperties":{"type":"string"}},"traceId":{"type":"string"}},"required":["error","traceId"]},"ChannelRoomAdd":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"room":{"type":"object","properties":{"roomId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":200},"active":{"type":"boolean","default":true},"membersOnly":{"type":"boolean","default":false},"mediaOpen":{"type":"boolean","default":false},"dedicated":{"type":"boolean","default":false},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64},"default":[]},"boundBy":{"type":"string","minLength":1,"maxLength":128},"boundAt":{"type":"string","format":"date-time"},"orgId":{"type":"string","minLength":1,"maxLength":128},"settings":{"type":"object","additionalProperties":{"nullable":true}}},"required":["roomId"]},"groupId":{"type":"string","minLength":1,"maxLength":128}},"required":["room"]},"ChannelRoomPatch":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"patch":{"$ref":"#/components/schemas/ChannelRoomEdit"}},"required":["patch"]},"ChannelRoomEdit":{"type":"object","properties":{"name":{"type":"string","maxLength":200},"active":{"type":"boolean"},"membersOnly":{"type":"boolean"},"mediaOpen":{"type":"boolean"},"dedicated":{"type":"boolean"},"gateDomainHints":{"type":"array","items":{"type":"string","maxLength":64}},"gateAskHints":{"type":"array","items":{"type":"string","maxLength":64}},"orgId":{"type":"string","minLength":1,"maxLength":128},"settings":{"type":"object","additionalProperties":{"nullable":true}}},"additionalProperties":false},"ChannelRoomIdentities":{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}},"ChannelInstall":{"type":"object","properties":{"channel":{"type":"string"},"externalId":{"type":"string"},"status":{"type":"string","enum":["bound","pending_unbound"]},"bindingId":{"type":"string","nullable":true},"installedAt":{"type":"string","nullable":true},"removedAt":{"type":"string","nullable":true},"updatedAt":{"type":"string"},"liveConversations":{"type":"integer","minimum":0},"msTenant":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["active","disconnected"]},"connectedAt":{"type":"string","nullable":true}},"required":["status","connectedAt"]}},"required":["channel","externalId","status","bindingId","installedAt","removedAt","updatedAt","liveConversations","msTenant"]},"ChannelInstallsError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]},"TeamsPackageLink":{"type":"object","properties":{"url":{"type":"string"},"fileName":{"type":"string"},"expiresAt":{"type":"string"},"name":{"type":"string"},"version":{"type":"string"}},"required":["url","fileName","expiresAt","name","version"]},"TeamsPackageError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]},"AdminOrgRow":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"runtimeIdentity":{"type":"string"},"filesBucket":{"type":"string"},"stagingBucket":{"type":"string"}},"default":{}},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}},"memberCount":{"type":"integer","minimum":0}},"required":["id","slug","name","createdAt","memberCount"]},"AdminTwoStep":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]}]},"AdminCreateOrgBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"lang":{"type":"string","enum":["he","en","pt"]},"ownerEmail":{"type":"string","format":"email"},"ownerPhone":{"type":"string","minLength":3,"maxLength":32},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["name"]},"AdminOrgDetail":{"type":"object","properties":{"org":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"runtimeIdentity":{"type":"string"},"filesBucket":{"type":"string"},"stagingBucket":{"type":"string"}},"default":{}},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}}},"required":["id","slug","name","createdAt"]},"members":{"type":"array","items":{"type":"object","properties":{"principalId":{"type":"string"},"displayName":{"type":"string"},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"role":{"type":"string","enum":["org_admin","member"]},"status":{"type":"string","enum":["active","invited","suspended"]},"superAdmin":{"type":"boolean"},"addedAt":{"type":"string"},"lastSeenAt":{"type":"string","nullable":true}},"required":["principalId","displayName","email","phone","role","status","superAdmin","addedAt","lastSeenAt"]}},"connectors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"enabled":{"type":"boolean"},"lastTestOk":{"type":"boolean","nullable":true},"lastDiscoveredAt":{"type":"string","nullable":true}},"required":["id","type","name","state","enabled","lastTestOk","lastDiscoveredAt"]}},"channels":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"channel":{"type":"string"},"displayName":{"type":"string","nullable":true},"status":{"type":"string"},"rooms":{"type":"integer"},"lastEventAt":{"type":"string","nullable":true}},"required":["id","channel","displayName","status","rooms","lastEventAt"]}},"tokenCount":{"type":"integer"},"usage30d":{"type":"object","properties":{"turns":{"type":"number"},"toolCalls":{"type":"number"},"credits":{"type":"number"},"tokensIn":{"type":"number"},"tokensOut":{"type":"number"}},"required":["turns","toolCalls","credits","tokensIn","tokensOut"]}},"required":["org","members","connectors","channels","tokenCount","usage30d"]},"AdminPatchOrgBody":{"type":"object","properties":{"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["kind"]},"AdminOrgSignInBody":{"type":"object","properties":{"open":{"type":"boolean"},"locked":{"type":"boolean"},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"AdminAddMemberBody":{"type":"object","properties":{"email":{"type":"string","format":"email"},"phone":{"type":"string","minLength":3,"maxLength":32},"principalId":{"type":"string","minLength":1},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"AdminPatchMemberBody":{"type":"object","properties":{"role":{"type":"string","enum":["org_admin","member"]},"status":{"type":"string","enum":["active","invited","suspended"]},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"AdminIssueTokenBody":{"type":"object","properties":{"principalId":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":120},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"default":["read"]},"expiresAt":{"type":"string","format":"date-time"},"channel":{"type":"string","maxLength":32},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}},"required":["name"]},"AdminToolCallRow":{"type":"object","properties":{"turnId":{"type":"string"},"at":{"type":"string"},"orgId":{"type":"string","nullable":true},"principalId":{"type":"string","nullable":true},"channel":{"type":"string"},"tool":{"type":"string"},"server":{"type":"string","nullable":true},"ok":{"type":"boolean"},"ms":{"type":"number"},"errorKind":{"type":"string","nullable":true},"errorMessage":{"type":"string","nullable":true},"resultBytes":{"type":"number","nullable":true},"truncated":{"type":"boolean"}},"required":["turnId","at","orgId","principalId","channel","tool","server","ok","ms","errorKind","errorMessage","resultBytes","truncated"]},"AdminDenialRow":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string"},"orgId":{"type":"string"},"principalId":{"type":"string","nullable":true},"channel":{"type":"string","nullable":true},"tool":{"type":"string","nullable":true},"code":{"type":"string","nullable":true},"name":{"type":"string","nullable":true},"ruleId":{"type":"string","nullable":true},"where":{"type":"string","nullable":true},"policyVersion":{"type":"string","nullable":true}},"required":["id","at","orgId","principalId","channel","tool","code","name","ruleId","where","policyVersion"]},"AdminGateRow":{"type":"object","properties":{"id":{"type":"string"},"at":{"type":"string"},"channel":{"type":"string"},"roomKey":{"type":"string"},"sender":{"type":"string"},"isGroup":{"type":"boolean"},"answered":{"type":"boolean"},"rule":{"type":"string"},"bodyLen":{"type":"number"},"event":{"type":"string","nullable":true}},"required":["id","at","channel","roomKey","sender","isGroup","answered","rule","bodyLen","event"]},"AdminPrincipalRow":{"type":"object","properties":{"id":{"type":"string"},"displayName":{"type":"string"},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"status":{"type":"string"},"superAdmin":{"type":"boolean"},"primaryOrgId":{"type":"string","nullable":true},"orgCount":{"type":"integer"},"lastSeenAt":{"type":"string","nullable":true},"createdAt":{"type":"string"}},"required":["id","displayName","email","phone","status","superAdmin","primaryOrgId","orgCount","lastSeenAt","createdAt"]},"AdminHealth":{"type":"object","properties":{"ok":{"type":"boolean"},"service":{"type":"string"},"version":{"type":"string"},"env":{"type":"string"},"region":{"type":"string"},"revision":{"type":"string","nullable":true},"time":{"type":"string"},"store":{"type":"object","properties":{"ok":{"type":"boolean"},"ms":{"type":"number"},"error":{"type":"string"}},"required":["ok","ms"]},"counts":{"type":"object","properties":{"orgs":{"type":"number"},"principals":{"type":"number"},"capped":{"type":"number"}},"required":["orgs","principals","capped"]},"last24h":{"type":"object","properties":{"turns":{"type":"number"},"failed":{"type":"number"},"denials":{"type":"number"},"sampled":{"type":"number"}},"required":["turns","failed","denials","sampled"]},"switches":{"type":"object","properties":{"mcp":{"type":"boolean"},"mail":{"type":"boolean"},"signinAllowlist":{"type":"boolean"},"contentPolicy":{"type":"string"},"channels":{"type":"array","items":{"type":"string"}}},"required":["mcp","mail","signinAllowlist","contentPolicy","channels"]}},"required":["ok","service","version","env","region","revision","time","store","counts","last24h","switches"]},"PlatformUsageRow":{"type":"object","properties":{"day":{"type":"string"},"orgId":{"type":"string"},"turns":{"type":"number"},"toolCalls":{"type":"number"},"credits":{"type":"number"},"tokensIn":{"type":"number"},"tokensOut":{"type":"number"}},"required":["day","orgId","turns","toolCalls","credits","tokensIn","tokensOut"]},"AdminCreditsOverview":{"type":"object","properties":{"month":{"type":"string"},"totals":{"type":"object","properties":{"orgs":{"type":"number"},"consumed":{"type":"number"},"available":{"type":"number"}},"required":["orgs","consumed","available"]},"orgs":{"type":"array","items":{"type":"object","properties":{"orgId":{"type":"string"},"name":{"type":"string"},"kind":{"type":"string"},"plan":{"type":"string","nullable":true},"monthlyAllowance":{"type":"number"},"consumed":{"type":"number"},"available":{"type":"number"},"grantsTotal":{"type":"number"},"usedPct":{"type":"number","nullable":true},"exhausted":{"type":"boolean"},"onExhausted":{"type":"string","enum":["allow","lean","block"]},"caps":{"type":"object","properties":{"soft":{"type":"number"},"hard":{"type":"number"}},"required":["soft","hard"]},"visibility":{"type":"object","properties":{"balance":{"type":"boolean","default":false},"budgets":{"type":"boolean","default":false},"breakdown":{"type":"boolean","default":false},"alerts":{"type":"boolean","default":false},"agent":{"type":"boolean","default":false}}},"lastGrantAt":{"type":"string","nullable":true},"today":{"type":"number"},"avg7d":{"type":"number"},"anomalies":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["overdrawn","exhausted_blocking","near_limit","spike","over_ceiling"]},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["code"]}}},"required":["orgId","name","kind","plan","monthlyAllowance","consumed","available","grantsTotal","usedPct","exhausted","onExhausted","caps","visibility","lastGrantAt","today","avg7d","anomalies"]}}},"required":["month","totals","orgs"]},"AdminOrgCredits":{"type":"object","properties":{"account":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","nullable":true,"maxLength":64,"default":null},"monthly_allowance":{"type":"integer","minimum":0,"default":0},"allowance_history":{"type":"array","items":{"type":"object","properties":{"from_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0}},"required":["from_month","allowance"]},"default":[]},"started_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"grants_total":{"type":"integer","default":0},"last_grant_at":{"type":"string","nullable":true,"format":"date-time","default":null},"caps":{"type":"object","properties":{"org":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null,"required":["soft","hard"]},"ceiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null}},"default":{"org":null,"ceiling":null}},"alert_thresholds_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"on_exhausted":{"type":"string","enum":["allow","lean","block"],"default":"allow"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"question_soft_action":{"type":"string","enum":["warn","ask"],"default":"warn"},"alert_channels":{"type":"object","properties":{"email":{"type":"boolean","default":true},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300,"default":null},"whatsapp":{"type":"boolean","default":false}},"default":{"email":true,"room":null,"whatsapp":false}},"visibility":{"type":"object","properties":{"balance":{"type":"boolean","default":false},"budgets":{"type":"boolean","default":false},"breakdown":{"type":"boolean","default":false},"alerts":{"type":"boolean","default":false},"agent":{"type":"boolean","default":false}},"default":{"balance":false,"budgets":false,"breakdown":false,"alerts":false,"agent":false}},"version":{"type":"integer","minimum":0,"default":0},"updated_at":{"type":"string","nullable":true,"format":"date-time","default":null},"updated_by":{"type":"string","nullable":true,"default":null},"exists":{"type":"boolean"}},"required":["org_id","started_month","exists"]},"balance":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0},"consumed":{"type":"number","minimum":0},"allowance_left":{"type":"number","minimum":0},"grants_total":{"type":"number"},"granted_left":{"type":"number"},"available":{"type":"number"},"exhausted":{"type":"boolean"},"used_pct":{"type":"number","nullable":true,"minimum":0}},"required":["org_id","month","allowance","consumed","allowance_left","grants_total","granted_left","available","exhausted","used_pct"]},"caps":{"type":"object","properties":{"soft":{"type":"number"},"hard":{"type":"number"}},"required":["soft","hard"],"description":"The effective per-question caps (org value, ceiling wins)."},"grants":{"type":"array","items":{"type":"object","properties":{"grant_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["grant","adjustment"]},"amount":{"type":"integer"},"reason":{"type":"string","minLength":3,"maxLength":500},"actor_principal_id":{"type":"string"},"actor_email":{"type":"string","nullable":true,"default":null},"nonce_hash":{"type":"string"},"balance_before":{"type":"number"},"balance_after":{"type":"number"},"created_at":{"type":"string","format":"date-time"},"trace_id":{"type":"string","nullable":true,"default":null}},"required":["grant_id","org_id","kind","amount","reason","actor_principal_id","nonce_hash","balance_before","balance_after","created_at"]}},"history":{"type":"array","items":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0},"consumed":{"type":"number","minimum":0},"allowance_left":{"type":"number","minimum":0},"grants_total":{"type":"number"},"granted_left":{"type":"number"},"available":{"type":"number"},"exhausted":{"type":"boolean"},"used_pct":{"type":"number","nullable":true,"minimum":0},"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"updated_at":{"type":"string","format":"date-time"}},"required":["org_id","month","allowance","consumed","allowance_left","grants_total","granted_left","available","exhausted","used_pct","day","updated_at"]}},"budgets":{"type":"array","items":{"type":"object","properties":{"budget_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"scope":{"type":"string","enum":["org","group","person","channel","agent"]},"scope_id":{"type":"string","nullable":true,"maxLength":200},"period":{"type":"string","enum":["day","month"]},"limit":{"type":"integer","minimum":0,"exclusiveMinimum":true},"on_exceed":{"type":"string","enum":["warn","cap","block"],"default":"warn"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"alert_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"enabled":{"type":"boolean","default":true},"label":{"type":"string","nullable":true,"maxLength":120,"default":null},"created_by":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_by":{"type":"string"},"updated_at":{"type":"string","format":"date-time"}},"required":["budget_id","org_id","scope","scope_id","period","limit","created_by","created_at","updated_by","updated_at"]}}},"required":["account","balance","caps","grants","history","budgets"]},"AdminCreditGrantResult":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","properties":{"org_id":{"type":"string"},"kind":{"type":"string","enum":["grant","adjustment"]},"amount":{"type":"number"},"balance_before":{"type":"number"},"balance_after":{"type":"number"},"nonce":{"type":"string"},"expires_at":{"type":"string"}},"required":["org_id","kind","amount","balance_before","balance_after","nonce","expires_at"]}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","properties":{"grant":{"type":"object","properties":{"grant_id":{"type":"string","minLength":1,"maxLength":128},"org_id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["grant","adjustment"]},"amount":{"type":"integer"},"reason":{"type":"string","minLength":3,"maxLength":500},"actor_principal_id":{"type":"string"},"actor_email":{"type":"string","nullable":true,"default":null},"nonce_hash":{"type":"string"},"balance_before":{"type":"number"},"balance_after":{"type":"number"},"created_at":{"type":"string","format":"date-time"},"trace_id":{"type":"string","nullable":true,"default":null}},"required":["grant_id","org_id","kind","amount","reason","actor_principal_id","nonce_hash","balance_before","balance_after","created_at"]},"replay":{"type":"boolean"}},"required":["grant","replay"]}},"required":["applied"]}]},"AdminCreditGrantBody":{"type":"object","properties":{"amount":{"type":"integer","minimum":-10000000,"maximum":10000000},"kind":{"type":"string","enum":["grant","adjustment"],"description":"`grant` (default) adds credits; a negative amount must be an `adjustment`."},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean"},"nonce":{"type":"string","minLength":1,"maxLength":200,"description":"The nonce the preview returned (single use, 15 minutes)."}},"required":["amount"]},"AdminCreditSettingsResult":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","properties":{"before":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","nullable":true,"maxLength":64,"default":null},"monthly_allowance":{"type":"integer","minimum":0,"default":0},"allowance_history":{"type":"array","items":{"type":"object","properties":{"from_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0}},"required":["from_month","allowance"]},"default":[]},"started_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"grants_total":{"type":"integer","default":0},"last_grant_at":{"type":"string","nullable":true,"format":"date-time","default":null},"caps":{"type":"object","properties":{"org":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null,"required":["soft","hard"]},"ceiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null}},"default":{"org":null,"ceiling":null}},"alert_thresholds_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"on_exhausted":{"type":"string","enum":["allow","lean","block"],"default":"allow"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"question_soft_action":{"type":"string","enum":["warn","ask"],"default":"warn"},"alert_channels":{"type":"object","properties":{"email":{"type":"boolean","default":true},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300,"default":null},"whatsapp":{"type":"boolean","default":false}},"default":{"email":true,"room":null,"whatsapp":false}},"visibility":{"type":"object","properties":{"balance":{"type":"boolean","default":false},"budgets":{"type":"boolean","default":false},"breakdown":{"type":"boolean","default":false},"alerts":{"type":"boolean","default":false},"agent":{"type":"boolean","default":false}},"default":{"balance":false,"budgets":false,"breakdown":false,"alerts":false,"agent":false}},"version":{"type":"integer","minimum":0,"default":0},"updated_at":{"type":"string","nullable":true,"format":"date-time","default":null},"updated_by":{"type":"string","nullable":true,"default":null}},"required":["org_id","started_month"]},"after":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","nullable":true,"maxLength":64,"default":null},"monthly_allowance":{"type":"integer","minimum":0,"default":0},"allowance_history":{"type":"array","items":{"type":"object","properties":{"from_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0}},"required":["from_month","allowance"]},"default":[]},"started_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"grants_total":{"type":"integer","default":0},"last_grant_at":{"type":"string","nullable":true,"format":"date-time","default":null},"caps":{"type":"object","properties":{"org":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null,"required":["soft","hard"]},"ceiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null}},"default":{"org":null,"ceiling":null}},"alert_thresholds_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"on_exhausted":{"type":"string","enum":["allow","lean","block"],"default":"allow"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"question_soft_action":{"type":"string","enum":["warn","ask"],"default":"warn"},"alert_channels":{"type":"object","properties":{"email":{"type":"boolean","default":true},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300,"default":null},"whatsapp":{"type":"boolean","default":false}},"default":{"email":true,"room":null,"whatsapp":false}},"visibility":{"type":"object","properties":{"balance":{"type":"boolean","default":false},"budgets":{"type":"boolean","default":false},"breakdown":{"type":"boolean","default":false},"alerts":{"type":"boolean","default":false},"agent":{"type":"boolean","default":false}},"default":{"balance":false,"budgets":false,"breakdown":false,"alerts":false,"agent":false}},"version":{"type":"integer","minimum":0,"default":0},"updated_at":{"type":"string","nullable":true,"format":"date-time","default":null},"updated_by":{"type":"string","nullable":true,"default":null}},"required":["org_id","started_month"]}},"required":["before","after"]}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","properties":{"account":{"type":"object","properties":{"org_id":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","nullable":true,"maxLength":64,"default":null},"monthly_allowance":{"type":"integer","minimum":0,"default":0},"allowance_history":{"type":"array","items":{"type":"object","properties":{"from_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"allowance":{"type":"integer","minimum":0}},"required":["from_month","allowance"]},"default":[]},"started_month":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"grants_total":{"type":"integer","default":0},"last_grant_at":{"type":"string","nullable":true,"format":"date-time","default":null},"caps":{"type":"object","properties":{"org":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null,"required":["soft","hard"]},"ceiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"default":null}},"default":{"org":null,"ceiling":null}},"alert_thresholds_pct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5,"default":[70,80,90,100]},"on_exhausted":{"type":"string","enum":["allow","lean","block"],"default":"allow"},"overage_pct":{"type":"integer","minimum":0,"maximum":100,"default":20},"question_soft_action":{"type":"string","enum":["warn","ask"],"default":"warn"},"alert_channels":{"type":"object","properties":{"email":{"type":"boolean","default":true},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300,"default":null},"whatsapp":{"type":"boolean","default":false}},"default":{"email":true,"room":null,"whatsapp":false}},"visibility":{"type":"object","properties":{"balance":{"type":"boolean","default":false},"budgets":{"type":"boolean","default":false},"breakdown":{"type":"boolean","default":false},"alerts":{"type":"boolean","default":false},"agent":{"type":"boolean","default":false}},"default":{"balance":false,"budgets":false,"breakdown":false,"alerts":false,"agent":false}},"version":{"type":"integer","minimum":0,"default":0},"updated_at":{"type":"string","nullable":true,"format":"date-time","default":null},"updated_by":{"type":"string","nullable":true,"default":null}},"required":["org_id","started_month"]}},"required":["account"]}},"required":["applied"]}]},"AdminCreditSettingsBody":{"type":"object","properties":{"monthlyAllowance":{"type":"integer","minimum":0,"maximum":1000000000},"capsOrg":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["soft","hard"]},"capsCeiling":{"type":"object","nullable":true,"properties":{"soft":{"type":"integer","minimum":0,"exclusiveMinimum":true},"hard":{"type":"integer","minimum":0,"exclusiveMinimum":true}}},"alertThresholdsPct":{"type":"array","items":{"type":"integer","minimum":1,"maximum":100},"maxItems":5},"onExhausted":{"type":"string","enum":["allow","lean","block"]},"overagePct":{"type":"integer","minimum":0,"maximum":100},"questionSoftAction":{"type":"string","enum":["warn","ask"]},"alertChannels":{"type":"object","properties":{"email":{"type":"boolean"},"room":{"type":"string","nullable":true,"minLength":3,"maxLength":300},"whatsapp":{"type":"boolean"}}},"visibility":{"type":"object","properties":{"balance":{"type":"boolean"},"budgets":{"type":"boolean"},"breakdown":{"type":"boolean"},"alerts":{"type":"boolean"},"agent":{"type":"boolean"}}},"expectedVersion":{"type":"integer","minimum":0},"reason":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"confirm":{"type":"boolean"}}},"AdminModuleUsage":{"type":"object","properties":{"month":{"type":"string"},"available":{"type":"boolean","description":"False until the env has its module views (first daily run): rows are empty."},"modules":{"type":"array","items":{"type":"object","properties":{"moduleRef":{"type":"string"},"moduleKind":{"type":"string"},"moduleId":{"type":"string"},"orgs":{"type":"number"},"turns":{"type":"number"},"calls":{"type":"number"},"channelTurns":{"type":"number"},"credits":{"type":"number"}},"required":["moduleRef","moduleKind","moduleId","orgs","turns","calls","channelTurns","credits"]}},"rows":{"type":"array","items":{"type":"object","properties":{"moduleRef":{"type":"string"},"moduleKind":{"type":"string"},"moduleId":{"type":"string"},"instanceId":{"type":"string","nullable":true},"orgId":{"type":"string","nullable":true},"orgName":{"type":"string","nullable":true},"env":{"type":"string","nullable":true},"turns":{"type":"number"},"calls":{"type":"number"},"channelTurns":{"type":"number"},"credits":{"type":"number"}},"required":["moduleRef","moduleKind","moduleId","instanceId","orgId","orgName","env","turns","calls","channelTurns","credits"]}}},"required":["month","available","modules","rows"]},"AdminSourceUsage":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"days":{"type":"number"},"available":{"type":"boolean","description":"False until the env has the CORE-60 warehouse columns: lists are empty."},"totals":{"type":"object","properties":{"calls":{"type":"number"},"uses":{"type":"number"},"errors":{"type":"number"},"rows":{"type":"number"},"bytesScanned":{"type":"number"}},"required":["calls","uses","errors","rows","bytesScanned"]},"sources":{"type":"array","items":{"type":"object","properties":{"moduleRef":{"type":"string"},"instanceId":{"type":"string","nullable":true},"connectorName":{"type":"string","nullable":true},"source":{"type":"string","nullable":true},"orgId":{"type":"string","nullable":true},"orgName":{"type":"string","nullable":true},"calls":{"type":"number"},"uses":{"type":"number"},"queries":{"type":"number"},"rows":{"type":"number"},"bytesScanned":{"type":"number"},"errors":{"type":"number"},"errorRate":{"type":"number"},"p50Ms":{"type":"number"},"p95Ms":{"type":"number"},"users":{"type":"number"},"errorKinds":{"type":"array","items":{"type":"string"}},"lastCallAt":{"type":"string","nullable":true},"lastOkAt":{"type":"string","nullable":true},"lastErrorAt":{"type":"string","nullable":true}},"required":["moduleRef","instanceId","connectorName","source","orgId","orgName","calls","uses","queries","rows","bytesScanned","errors","errorRate","p50Ms","p95Ms","users","errorKinds","lastCallAt","lastOkAt","lastErrorAt"]}},"tables":{"type":"array","items":{"type":"object","properties":{"moduleRef":{"type":"string"},"table":{"type":"string"},"orgId":{"type":"string","nullable":true},"calls":{"type":"number"},"errors":{"type":"number"},"rows":{"type":"number"},"bytesScanned":{"type":"number"},"p95Ms":{"type":"number"},"users":{"type":"number"},"lastCallAt":{"type":"string","nullable":true}},"required":["moduleRef","table","orgId","calls","errors","rows","bytesScanned","p95Ms","users","lastCallAt"]}},"slow":{"type":"array","items":{"type":"object","properties":{"at":{"type":"string"},"moduleRef":{"type":"string"},"instanceId":{"type":"string","nullable":true},"orgId":{"type":"string","nullable":true},"op":{"type":"string"},"tool":{"type":"string","nullable":true},"ok":{"type":"boolean"},"ms":{"type":"number"},"errorKind":{"type":"string","nullable":true},"errorCode":{"type":"string","nullable":true},"rows":{"type":"number","nullable":true},"tables":{"type":"array","items":{"type":"string"}},"channel":{"type":"string","nullable":true},"agentId":{"type":"string","nullable":true},"principalId":{"type":"string","nullable":true},"traceId":{"type":"string","nullable":true}},"required":["at","moduleRef","instanceId","orgId","op","tool","ok","ms","errorKind","errorCode","rows","tables","channel","agentId","principalId","traceId"]}},"failures":{"type":"array","items":{"type":"object","properties":{"moduleRef":{"type":"string"},"instanceId":{"type":"string","nullable":true},"errorKind":{"type":"string"},"errorCode":{"type":"string","nullable":true},"count":{"type":"number"},"orgs":{"type":"number"},"lastAt":{"type":"string","nullable":true}},"required":["moduleRef","instanceId","errorKind","errorCode","count","orgs","lastAt"]}},"dimensions":{"type":"array","items":{"type":"object","properties":{"dimension":{"type":"string","enum":["org","person","channel","agent"]},"key":{"type":"string","nullable":true},"label":{"type":"string","nullable":true},"calls":{"type":"number"},"errors":{"type":"number"},"rows":{"type":"number"},"bytesScanned":{"type":"number"}},"required":["dimension","key","label","calls","errors","rows","bytesScanned"]}},"silent":{"type":"array","items":{"type":"object","properties":{"connectorId":{"type":"string"},"orgId":{"type":"string"},"orgName":{"type":"string","nullable":true},"type":{"type":"string"},"name":{"type":"string"},"state":{"type":"string","nullable":true},"lastUseAt":{"type":"string","nullable":true},"lastCallAt":{"type":"string","nullable":true},"lastOkAt":{"type":"string","nullable":true},"lastErrorAt":{"type":"string","nullable":true},"reason":{"type":"string","enum":["never_used","idle","failing"]}},"required":["connectorId","orgId","orgName","type","name","state","lastUseAt","lastCallAt","lastOkAt","lastErrorAt","reason"]}},"daily":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"calls":{"type":"number"},"errors":{"type":"number"},"rows":{"type":"number"},"bytesScanned":{"type":"number"}},"required":["day","calls","errors","rows","bytesScanned"]}}},"required":["from","to","days","available","totals","sources","tables","slow","failures","dimensions","silent","daily"]},"AdminSourceReport":{"type":"object","properties":{"text":{"type":"string"},"sent":{"type":"boolean"},"channel":{"type":"string"},"available":{"type":"boolean"},"watch":{"type":"object","nullable":true,"properties":{"failing":{"type":"number"},"silent":{"type":"number"}},"required":["failing","silent"]}},"required":["text","sent","channel","available","watch"]},"AdminMeta":{"type":"object","properties":{"manifest":{"type":"object","properties":{"name":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"version":{"type":"string","minLength":1},"kind":{"type":"string","enum":["service","worker","app"]},"owner":{"type":"string","minLength":1},"description":{"type":"string","maxLength":500},"surfaces":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["mcp","rest"]},"path":{"type":"string","minLength":1},"auth":{"type":"string","enum":["bearer","api_key","firebase","oauth2","none"]}},"required":["kind","path","auth"]},"default":[]},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"default":[]},"models":{"type":"array","items":{"type":"string"},"default":[]},"tools":{"type":"array","items":{"type":"string"},"default":[]},"dataStores":{"type":"array","items":{"type":"string"},"default":[]},"emits":{"type":"array","items":{"type":"string"},"default":[]},"flags":{"type":"array","items":{"type":"string"},"default":[]},"killSwitches":{"type":"array","items":{"type":"string"},"default":[]},"consumers":{"type":"array","items":{"type":"string"},"default":[]}},"required":["name","version","kind","owner"]},"runtime":{"type":"object","properties":{"version":{"type":"string"},"env":{"type":"string"},"region":{"type":"string"},"project":{"type":"string"},"service":{"type":"string"},"revision":{"type":"string"},"mcp":{"type":"string","enum":["enabled","disabled"]}},"required":["version","env","region","mcp"]}},"required":["manifest","runtime"]},"FeatureCatalogRow":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["console","canary","capability"]},"default":{"type":"boolean"},"plans":{"type":"array","items":{"type":"string"}},"hint":{"type":"string"}},"required":["id","kind","default","hint"]},"FeatureOrgImpact":{"type":"object","properties":{"orgId":{"type":"string"},"name":{"type":"string"},"changes":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"from":{"type":"boolean"},"to":{"type":"boolean"},"fromSource":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]},"toSource":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"required":["id","from","to","fromSource","toSource"]}}},"required":["orgId","name","changes"]},"FeatureReportRow":{"type":"object","properties":{"orgId":{"type":"string"},"name":{"type":"string"},"kind":{"type":"string"},"status":{"type":"string"},"profile":{"type":"string"},"plan":{"type":"string"},"version":{"type":"integer"},"overrides":{"type":"object","additionalProperties":{"type":"boolean"}},"redundant":{"type":"array","items":{"type":"string"}},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"sources":{"type":"object","additionalProperties":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"profileMissing":{"type":"boolean"}},"required":["orgId","name","kind","status","plan","version","overrides","redundant","flags","sources"]},"OrgAgentsView":{"type":"object","properties":{"agents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"status":{"type":"string","enum":["active","disabled"]},"defaultMode":{"type":"string","enum":["lean","full"]},"org":{"type":"object","nullable":true,"properties":{"agentId":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean","default":true},"persona":{"type":"string","maxLength":20000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"channelOverlays":{"type":"object","properties":{"web":{"type":"string","maxLength":10000},"mcp":{"type":"string","maxLength":10000},"rest":{"type":"string","maxLength":10000},"whatsapp":{"type":"string","maxLength":10000},"whatsapp_web":{"type":"string","maxLength":10000},"telegram":{"type":"string","maxLength":10000},"sms":{"type":"string","maxLength":10000},"slack":{"type":"string","maxLength":10000},"teams":{"type":"string","maxLength":10000},"email":{"type":"string","maxLength":10000},"voice":{"type":"string","maxLength":10000},"scheduled":{"type":"string","maxLength":10000}},"default":{}},"roomOverlays":{"type":"object","additionalProperties":{"type":"string","maxLength":10000},"default":{}},"toolDeny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"roles":{"type":"object","properties":{"lean":{"type":"string","enum":["fast","deep"]},"full":{"type":"string","enum":["fast","deep"]}},"default":{}},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["agentId","orgId"]}},"required":["id","name","description","channels","status","defaultMode","org"]}},"routing":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"defaultAgent":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$","default":"wizbi"},"channels":{"type":"object","properties":{"web":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"mcp":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"rest":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"whatsapp":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"whatsapp_web":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"telegram":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"sms":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"slack":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"teams":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"email":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"voice":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"scheduled":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"}},"default":{}},"rooms":{"type":"object","additionalProperties":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["orgId"]},"flags":{"type":"object","properties":{"routing":{"type":"boolean"},"customAgents":{"type":"boolean"},"deepModel":{"type":"boolean"}},"required":["routing","customAgents","deepModel"]},"canEdit":{"type":"boolean"}},"required":["agents","routing","flags","canEdit"]},"PutOrgAgentBody":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"persona":{"type":"string","maxLength":20000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"channelOverlays":{"type":"object","additionalProperties":{"type":"string","maxLength":10000},"default":{}},"roomOverlays":{"type":"object","additionalProperties":{"type":"string","maxLength":10000},"default":{}},"toolDeny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":100,"default":[]},"roles":{"type":"object","properties":{"lean":{"type":"string","enum":["fast","deep"]},"full":{"type":"string","enum":["fast","deep"]}},"default":{}},"note":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0},"confirm":{"type":"boolean","default":false}}},"PutAgentRoutingBody":{"type":"object","properties":{"defaultAgent":{"type":"string","minLength":1,"maxLength":48,"default":"wizbi"},"channels":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":48},"default":{}},"rooms":{"type":"object","additionalProperties":{"type":"string","minLength":1,"maxLength":48},"default":{}},"version":{"type":"integer","minimum":0},"confirm":{"type":"boolean","default":false}}},"AgentProfileView":{"type":"object","properties":{"id":{"type":"string"},"layers":{"type":"array","items":{"type":"object","properties":{"layer":{"type":"string","enum":["org","overlay"]},"text":{"type":"string"},"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}}},"required":["layer","text"]}},"defaultMode":{"type":"string","enum":["lean","full"]},"escalation":{"type":"boolean"}},"required":["id","layers","defaultMode","escalation"]},"ResolveAgentBody":{"type":"object","properties":{"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"],"default":"web"},"roomId":{"type":"string","maxLength":128}}},"LibraryConfirm":{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}},"LibraryOptionsBody":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"values":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]},"maxItems":500},"confirm":{"type":"boolean","default":false}},"required":["key","values"]},"BiFeed":{"type":"object","properties":{"lane":{"type":"string","enum":["for_you","saved","mine","rooms","org"]},"tags":{"type":"array","items":{"type":"object","properties":{"tag":{"type":"string"},"count":{"type":"integer"}},"required":["tag","count"]}},"items":{"type":"array","items":{"$ref":"#/components/schemas/BiFeedItem"}},"caughtUp":{"type":"boolean"},"unseen":{"type":"integer"}},"required":["lane","tags","items","caughtUp","unseen"]},"BiFeedItem":{"type":"object","properties":{"card":{"$ref":"#/components/schemas/BiCard"},"state":{"$ref":"#/components/schemas/BiViewerState"},"reason":{"type":"string","enum":["official","shared_with_you","your_room","yours","saved","popular_in_org","topic_you_follow","important","new"]},"score":{"type":"number"},"unseen":{"type":"boolean"}},"required":["card","state","reason","score","unseen"]},"BiCard":{"type":"object","properties":{"kind":{"type":"string","enum":["insight","kpi","chart","table","list","text","image","compare","loop","milestone","external","question"]},"title":{"type":"string","minLength":1,"maxLength":200},"summary":{"type":"string","maxLength":400},"blocks":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["headline"]},"title":{"type":"string","minLength":1,"maxLength":200},"takeaway":{"type":"string","maxLength":400}},"required":["type","title"]},{"type":"object","properties":{"type":{"type":"string","enum":["stat"]},"label":{"type":"string","minLength":1,"maxLength":200},"value":{"type":"number"},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"},"prev":{"type":"number"},"period":{"type":"string","maxLength":80},"goodDirection":{"type":"string","enum":["up","down","none"],"default":"up"},"spark":{"type":"array","items":{"type":"number"},"maxItems":120}},"required":["type","label","value"]},{"type":"object","properties":{"type":{"type":"string","enum":["chart"]},"viz":{"type":"string","enum":["line","bar","hbar","stacked","area"]},"labels":{"type":"array","items":{"type":"string","maxLength":80},"maxItems":400},"series":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":80},"values":{"type":"array","items":{"type":"number","nullable":true},"maxItems":400}},"required":["name","values"]},"minItems":1,"maxItems":8},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"},"caption":{"type":"string","maxLength":300}},"required":["type","viz","labels","series"]},{"type":"object","properties":{"type":{"type":"string","enum":["table"]},"columns":{"type":"array","items":{"type":"string","maxLength":80},"minItems":1,"maxItems":12},"rows":{"type":"array","items":{"type":"array","items":{"anyOf":[{"type":"string","maxLength":300},{"type":"number"},{"nullable":true}]}},"maxItems":200},"caption":{"type":"string","maxLength":300}},"required":["type","columns","rows"]},{"type":"object","properties":{"type":{"type":"string","enum":["list"]},"items":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":200},"value":{"type":"number"},"note":{"type":"string","maxLength":200},"tone":{"type":"string","enum":["ok","warn","bad","none"],"default":"none"}},"required":["label"]},"minItems":1,"maxItems":25},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"}},"required":["type","items"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"]},"markdown":{"type":"string","minLength":1,"maxLength":4000}},"required":["type","markdown"]},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"url":{"type":"string","maxLength":2000,"format":"uri"},"alt":{"type":"string","maxLength":300},"caption":{"type":"string","maxLength":300}},"required":["type","url","alt"]},{"type":"object","properties":{"type":{"type":"string","enum":["callout"]},"tone":{"type":"string","enum":["why","action","warn"]},"text":{"type":"string","minLength":1,"maxLength":600}},"required":["type","tone","text"]}]},"minItems":1,"maxItems":12},"producer":{"type":"object","properties":{"kind":{"type":"string","enum":["user","org","room","report","alert","proactive","library","system"]},"id":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":120},"official":{"type":"boolean","default":false},"engine":{"type":"string","maxLength":80},"runId":{"type":"string","minLength":1,"maxLength":128}},"required":["kind"]},"audience":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["private"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["people"]},"uids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":200}},"required":["kind","uids"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rooms"]},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":50}},"required":["kind","groupIds"]},{"type":"object","properties":{"kind":{"type":"string","enum":["org"]}},"required":["kind"]}],"default":{"kind":"private"}},"provenance":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":160},"kind":{"type":"string","enum":["connector","library","file","chat","manual"]},"connectorId":{"type":"string","minLength":1,"maxLength":128},"object":{"type":"string","maxLength":200},"query":{"type":"string","maxLength":4000},"rows":{"type":"integer","minimum":0},"fetchedAt":{"type":"string","format":"date-time"},"dataAsOf":{"type":"string","maxLength":40}},"required":["name","kind"]},"maxItems":20,"default":[]},"verified":{"type":"object","properties":{"at":{"type":"string","format":"date-time"},"method":{"type":"string","maxLength":200},"ok":{"type":"boolean"}},"required":["at","method","ok"]},"question":{"type":"string","maxLength":2000},"threadId":{"type":"string","minLength":1,"maxLength":128},"turnId":{"type":"string","minLength":1,"maxLength":128},"parentCardId":{"type":"string","minLength":1,"maxLength":128},"ruleId":{"type":"string","minLength":1,"maxLength":128}},"default":{"sources":[]}},"topics":{"type":"array","items":{"type":"string","minLength":1,"maxLength":80},"maxItems":20,"default":[]},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":60},"maxItems":10,"default":[]},"importance":{"type":"number","minimum":0,"maximum":1,"default":0.5},"expiresAt":{"type":"string","format":"date-time"},"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"status":{"type":"string","enum":["active","archived","deleted","disputed","draft"]},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"stats":{"type":"object","properties":{"impressions":{"type":"integer","minimum":0,"default":0},"views":{"type":"integer","minimum":0,"default":0},"uniqueViewers":{"type":"integer","minimum":0,"default":0},"dwellMs":{"type":"integer","minimum":0,"default":0},"reactions":{"type":"object","properties":{"like":{"type":"integer","minimum":0},"important":{"type":"integer","minimum":0},"unsure":{"type":"integer","minimum":0},"handled":{"type":"integer","minimum":0}},"default":{}},"saves":{"type":"integer","minimum":0,"default":0},"pins":{"type":"integer","minimum":0,"default":0},"follows":{"type":"integer","minimum":0,"default":0},"asks":{"type":"integer","minimum":0,"default":0},"deepDives":{"type":"integer","minimum":0,"default":0},"remixes":{"type":"integer","minimum":0,"default":0},"shares":{"type":"object","properties":{"whatsapp":{"type":"integer","minimum":0},"link":{"type":"integer","minimum":0},"person":{"type":"integer","minimum":0},"room":{"type":"integer","minimum":0},"public":{"type":"integer","minimum":0}},"default":{}},"publicViews":{"type":"integer","minimum":0,"default":0},"dismisses":{"type":"integer","minimum":0,"default":0},"disputes":{"type":"integer","minimum":0,"default":0},"edits":{"type":"integer","minimum":0,"default":0},"lastViewedAt":{"type":"string","format":"date-time"}}},"dispute":{"type":"object","properties":{"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"},"text":{"type":"string","maxLength":2000},"count":{"type":"integer"}},"required":["by","at","text","count"]},"deleted":{"type":"object","properties":{"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"}},"required":["by","at"]}},"required":["kind","title","blocks","producer","id","orgId","status","version","createdAt","updatedAt","createdBy","stats"]},"BiViewerState":{"type":"object","nullable":true,"properties":{"cardId":{"type":"string","minLength":1,"maxLength":128},"uid":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"firstSeenAt":{"type":"string","format":"date-time"},"seenAt":{"type":"string","format":"date-time"},"views":{"type":"integer","minimum":0,"default":0},"dwellMs":{"type":"integer","minimum":0,"default":0},"reaction":{"type":"string","nullable":true,"enum":["like","important","unsure","handled",null],"default":null},"saved":{"type":"boolean","default":false},"dismissed":{"type":"boolean","default":false},"followed":{"type":"boolean","default":false},"shares":{"type":"integer","minimum":0,"default":0},"asks":{"type":"integer","minimum":0,"default":0}},"required":["cardId","uid","orgId"]},"BiEngager":{"type":"object","properties":{"cardId":{"type":"string","minLength":1,"maxLength":128},"uid":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"firstSeenAt":{"type":"string","format":"date-time"},"seenAt":{"type":"string","format":"date-time"},"views":{"type":"integer","minimum":0,"default":0},"dwellMs":{"type":"integer","minimum":0,"default":0},"reaction":{"type":"string","nullable":true,"enum":["like","important","unsure","handled",null],"default":null},"saved":{"type":"boolean","default":false},"dismissed":{"type":"boolean","default":false},"followed":{"type":"boolean","default":false},"shares":{"type":"integer","minimum":0,"default":0},"asks":{"type":"integer","minimum":0,"default":0},"name":{"type":"string","nullable":true}},"required":["cardId","uid","orgId","name"]},"BiCardInput":{"type":"object","properties":{"kind":{"type":"string","enum":["insight","kpi","chart","table","list","text","image","compare","loop","milestone","external","question"]},"title":{"type":"string","minLength":1,"maxLength":200},"summary":{"type":"string","maxLength":400},"blocks":{"type":"array","items":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["headline"]},"title":{"type":"string","minLength":1,"maxLength":200},"takeaway":{"type":"string","maxLength":400}},"required":["type","title"]},{"type":"object","properties":{"type":{"type":"string","enum":["stat"]},"label":{"type":"string","minLength":1,"maxLength":200},"value":{"type":"number"},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"},"prev":{"type":"number"},"period":{"type":"string","maxLength":80},"goodDirection":{"type":"string","enum":["up","down","none"],"default":"up"},"spark":{"type":"array","items":{"type":"number"},"maxItems":120}},"required":["type","label","value"]},{"type":"object","properties":{"type":{"type":"string","enum":["chart"]},"viz":{"type":"string","enum":["line","bar","hbar","stacked","area"]},"labels":{"type":"array","items":{"type":"string","maxLength":80},"maxItems":400},"series":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":80},"values":{"type":"array","items":{"type":"number","nullable":true},"maxItems":400}},"required":["name","values"]},"minItems":1,"maxItems":8},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"},"caption":{"type":"string","maxLength":300}},"required":["type","viz","labels","series"]},{"type":"object","properties":{"type":{"type":"string","enum":["table"]},"columns":{"type":"array","items":{"type":"string","maxLength":80},"minItems":1,"maxItems":12},"rows":{"type":"array","items":{"type":"array","items":{"anyOf":[{"type":"string","maxLength":300},{"type":"number"},{"nullable":true}]}},"maxItems":200},"caption":{"type":"string","maxLength":300}},"required":["type","columns","rows"]},{"type":"object","properties":{"type":{"type":"string","enum":["list"]},"items":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":200},"value":{"type":"number"},"note":{"type":"string","maxLength":200},"tone":{"type":"string","enum":["ok","warn","bad","none"],"default":"none"}},"required":["label"]},"minItems":1,"maxItems":25},"unit":{"type":"string","enum":["currency","percent","count","mw","kwh","days","none"],"default":"none"}},"required":["type","items"]},{"type":"object","properties":{"type":{"type":"string","enum":["text"]},"markdown":{"type":"string","minLength":1,"maxLength":4000}},"required":["type","markdown"]},{"type":"object","properties":{"type":{"type":"string","enum":["image"]},"url":{"type":"string","maxLength":2000,"format":"uri"},"alt":{"type":"string","maxLength":300},"caption":{"type":"string","maxLength":300}},"required":["type","url","alt"]},{"type":"object","properties":{"type":{"type":"string","enum":["callout"]},"tone":{"type":"string","enum":["why","action","warn"]},"text":{"type":"string","minLength":1,"maxLength":600}},"required":["type","tone","text"]}]},"minItems":1,"maxItems":12},"producer":{"type":"object","properties":{"kind":{"type":"string","enum":["user","org","room","report","alert","proactive","library","system"]},"id":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":120},"official":{"type":"boolean","default":false},"engine":{"type":"string","maxLength":80},"runId":{"type":"string","minLength":1,"maxLength":128}},"required":["kind"]},"audience":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["private"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["people"]},"uids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":200}},"required":["kind","uids"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rooms"]},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":50}},"required":["kind","groupIds"]},{"type":"object","properties":{"kind":{"type":"string","enum":["org"]}},"required":["kind"]}],"default":{"kind":"private"}},"provenance":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":160},"kind":{"type":"string","enum":["connector","library","file","chat","manual"]},"connectorId":{"type":"string","minLength":1,"maxLength":128},"object":{"type":"string","maxLength":200},"query":{"type":"string","maxLength":4000},"rows":{"type":"integer","minimum":0},"fetchedAt":{"type":"string","format":"date-time"},"dataAsOf":{"type":"string","maxLength":40}},"required":["name","kind"]},"maxItems":20,"default":[]},"verified":{"type":"object","properties":{"at":{"type":"string","format":"date-time"},"method":{"type":"string","maxLength":200},"ok":{"type":"boolean"}},"required":["at","method","ok"]},"question":{"type":"string","maxLength":2000},"threadId":{"type":"string","minLength":1,"maxLength":128},"turnId":{"type":"string","minLength":1,"maxLength":128},"parentCardId":{"type":"string","minLength":1,"maxLength":128},"ruleId":{"type":"string","minLength":1,"maxLength":128}},"default":{"sources":[]}},"topics":{"type":"array","items":{"type":"string","minLength":1,"maxLength":80},"maxItems":20,"default":[]},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":60},"maxItems":10,"default":[]},"importance":{"type":"number","minimum":0,"maximum":1,"default":0.5},"expiresAt":{"type":"string","format":"date-time"}},"required":["kind","title","blocks"]},"BiEventsBody":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["impression","view","dwell","react","unreact","save","unsave","follow","unfollow","ask","deep_dive","remix","share","public_view","dismiss","dispute","edit","delete"]},"surface":{"type":"string","enum":["feed","detail","dashboard","chat","public","story"],"default":"feed"},"device":{"type":"string","enum":["mobile","desktop"]},"dwellMs":{"type":"integer","minimum":0,"maximum":3600000},"channel":{"type":"string","enum":["whatsapp","link","person","room","public"]},"reaction":{"type":"string","enum":["like","important","unsure","handled"]},"target":{"type":"string","maxLength":2000}},"required":["type"]},"minItems":1,"maxItems":50}},"required":["events"]},"BiDashboard":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160},"description":{"type":"string","maxLength":600},"kind":{"type":"string","enum":["board","html","live"]},"audience":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["private"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["people"]},"uids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":200}},"required":["kind","uids"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rooms"]},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":50}},"required":["kind","groupIds"]},{"type":"object","properties":{"kind":{"type":"string","enum":["org"]}},"required":["kind"]}],"default":{"kind":"org"}},"official":{"type":"boolean","default":false},"cardIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":60,"default":[]},"queries":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"},"tool":{"type":"string","minLength":1,"maxLength":80,"default":"query_bq"},"args":{"type":"object","additionalProperties":{"nullable":true}},"shape":{"type":"string","enum":["rows","row","value","json"],"default":"rows"},"merge":{"type":"boolean","default":false}},"required":["name","args"]},"maxItems":24,"default":[]},"cacheSec":{"type":"integer","minimum":0,"maximum":86400,"default":600},"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"status":{"type":"string","enum":["active","deleted"]},"owner":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":160}},"required":["id"]},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0},"versions":{"type":"array","items":{"type":"object","properties":{"version":{"type":"integer","minimum":0,"exclusiveMinimum":true},"at":{"type":"string","format":"date-time"},"by":{"type":"string","minLength":1,"maxLength":128},"bytes":{"type":"integer","minimum":0},"sha256":{"type":"string","maxLength":80},"queries":{"type":"integer","minimum":0},"note":{"type":"string","maxLength":300}},"required":["version","at","by","bytes","sha256","queries"]},"maxItems":200,"default":[]},"stats":{"type":"object","properties":{"views":{"type":"integer","minimum":0,"default":0},"viewers":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":500,"default":[]},"lastViewedAt":{"type":"string","format":"date-time"}},"default":{"views":0,"viewers":[]}},"deleted":{"type":"object","properties":{"by":{"type":"string","minLength":1,"maxLength":128},"at":{"type":"string","format":"date-time"}},"required":["by","at"]},"canEdit":{"type":"boolean"}},"required":["title","kind","id","orgId","status","owner","createdBy","createdAt","updatedAt","version","canEdit"]},"BiDashboardInput":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160},"description":{"type":"string","maxLength":600},"kind":{"type":"string","enum":["board","html","live"]},"audience":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["private"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["people"]},"uids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":200}},"required":["kind","uids"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rooms"]},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":50}},"required":["kind","groupIds"]},{"type":"object","properties":{"kind":{"type":"string","enum":["org"]}},"required":["kind"]}],"default":{"kind":"org"}},"official":{"type":"boolean","default":false},"cardIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":60,"default":[]},"html":{"type":"string","maxLength":6000000},"queries":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"},"tool":{"type":"string","minLength":1,"maxLength":80,"default":"query_bq"},"args":{"type":"object","additionalProperties":{"nullable":true}},"shape":{"type":"string","enum":["rows","row","value","json"],"default":"rows"},"merge":{"type":"boolean","default":false}},"required":["name","args"]},"maxItems":24,"default":[]},"cacheSec":{"type":"integer","minimum":0,"maximum":86400,"default":600},"note":{"type":"string","maxLength":300}},"required":["title","kind"]},"BiDashboardPatch":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":160},"description":{"type":"string","maxLength":600},"audience":{"oneOf":[{"type":"object","properties":{"kind":{"type":"string","enum":["private"]}},"required":["kind"]},{"type":"object","properties":{"kind":{"type":"string","enum":["people"]},"uids":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":200}},"required":["kind","uids"]},{"type":"object","properties":{"kind":{"type":"string","enum":["rooms"]},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"minItems":1,"maxItems":50}},"required":["kind","groupIds"]},{"type":"object","properties":{"kind":{"type":"string","enum":["org"]}},"required":["kind"]}]},"official":{"type":"boolean"},"cardIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":60},"cacheSec":{"type":"integer","minimum":0,"maximum":86400}}},"BiDashboardPageBody":{"type":"object","properties":{"html":{"type":"string","minLength":1,"maxLength":6000000},"queries":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z_][A-Za-z0-9_]{0,63}$"},"tool":{"type":"string","minLength":1,"maxLength":80,"default":"query_bq"},"args":{"type":"object","additionalProperties":{"nullable":true}},"shape":{"type":"string","enum":["rows","row","value","json"],"default":"rows"},"merge":{"type":"boolean","default":false}},"required":["name","args"]},"maxItems":24},"note":{"type":"string","maxLength":300}},"required":["html"]},"BiLiveData":{"type":"object","properties":{"data":{"type":"object","additionalProperties":{"nullable":true}},"errors":{"type":"object","additionalProperties":{"type":"string"},"default":{}},"asOf":{"type":"string","format":"date-time"},"cached":{"type":"boolean"},"elapsedMs":{"type":"integer","minimum":0}},"required":["data","asOf","cached","elapsedMs"]},"RemoteConnectorRow":{"type":"object","properties":{"id":{"type":"string"},"service":{"type":"string"},"endpoint":{"type":"string"},"version":{"type":"string"},"major":{"type":"number"},"catalogVersion":{"type":"number"},"enabled":{"type":"boolean"},"hasLogo":{"type":"boolean"},"hasSkill":{"type":"boolean"},"tools":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"grade":{"type":"string"}},"required":["name","grade"]}},"syncedAt":{"type":"string"},"syncedBy":{"type":"string"}},"required":["id","service","endpoint","version","major","catalogVersion","enabled","hasLogo","hasSkill","tools","syncedAt","syncedBy"]},"RemoteConnectorSync":{"type":"object","properties":{"service":{"type":"string","format":"uri"},"card":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"}},"required":["service"]},"ConnectorPlaneRow":{"type":"object","properties":{"cardId":{"type":"string"},"endpoint":{"type":"string"},"service":{"type":"string"},"audience":{"type":"string"},"secrets":{"type":"string","enum":["core","customer"]},"setAt":{"type":"string"},"setBy":{"type":"string"}},"required":["cardId","endpoint","service","audience","secrets","setAt","setBy"]},"ConnectorPlaneSet":{"type":"object","properties":{"endpoint":{"type":"string","format":"uri"},"secrets":{"type":"string","enum":["core","customer"]},"confirm":{"type":"boolean","default":false}},"required":["endpoint","secrets"]},"SecurityView":{"type":"object","properties":{"consent":{"type":"object","properties":{"required":{"type":"boolean"},"accepted":{"type":"boolean"},"version":{"type":"string"},"termsVersion":{"type":"string"},"privacyVersion":{"type":"string"},"termsUrl":{"type":"string"},"privacyUrl":{"type":"string"},"current":{"type":"object","nullable":true,"properties":{"version":{"type":"string","minLength":1,"maxLength":32},"acceptedAt":{"type":"string","format":"date-time"},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"recordId":{"type":"string","maxLength":80}},"required":["version","acceptedAt","channel","method"]}},"required":["required","accepted","version","termsVersion","privacyVersion","termsUrl","privacyUrl","current"]},"mfa":{"$ref":"#/components/schemas/MfaStatus"},"session":{"type":"object","properties":{"signInProvider":{"type":"string","nullable":true},"signedInAt":{"type":"string","nullable":true},"sessionsValidAfter":{"type":"string","nullable":true}},"required":["signInProvider","signedInAt","sessionsValidAfter"]},"signInMethods":{"type":"array","items":{"type":"string"}},"signIn":{"type":"object","nullable":true,"properties":{"orgId":{"type":"string"},"orgName":{"type":"string"},"method":{"type":"string","nullable":true,"enum":["google","microsoft","email_code","phone_code","sso",null]},"allowed":{"type":"array","items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]}},"ok":{"type":"boolean"}},"required":["orgId","orgName","method","allowed","ok"]}},"required":["consent","mfa","session","signInMethods","signIn"]},"MfaStatus":{"type":"object","properties":{"enrolled":{"type":"boolean"},"methods":{"type":"array","items":{"type":"string","enum":["totp","sms","recovery"]}},"totpEnrolledAt":{"type":"string"},"smsPhone":{"type":"string"},"recoveryRemaining":{"type":"number"},"locked":{"type":"boolean"},"required":{"type":"boolean"},"satisfied":{"type":"boolean"},"enforced":{"type":"boolean"},"available":{"type":"boolean"}},"required":["enrolled","methods","recoveryRemaining","locked","required","satisfied","enforced","available"]},"ConsentBody":{"type":"object","properties":{"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"version":{"type":"string","minLength":1,"maxLength":32},"accept":{"type":"boolean","enum":[true]},"surface":{"type":"string","enum":["console","oauth_consent"],"default":"console"},"locale":{"type":"string","maxLength":35},"clientId":{"type":"string","maxLength":500}},"required":["accept"]},"RecoveryCodes":{"type":"object","properties":{"recoveryCodes":{"type":"array","items":{"type":"string"}}},"required":["recoveryCodes"]},"MfaCodeBody":{"type":"object","properties":{"code":{"type":"string","minLength":6,"maxLength":12}},"required":["code"]},"MfaPhoneProofBody":{"type":"object","properties":{"phoneIdToken":{"type":"string","minLength":20}},"required":["phoneIdToken"]},"MfaStepUpBody":{"anyOf":[{"type":"object","properties":{"method":{"type":"string","enum":["totp","recovery"]},"code":{"type":"string","minLength":6,"maxLength":12}},"required":["method","code"]},{"type":"object","properties":{"method":{"type":"string","enum":["sms"]},"phoneIdToken":{"type":"string","minLength":20}},"required":["method","phoneIdToken"]}]},"RevokeSessionsResult":{"type":"object","properties":{"revokedSessions":{"type":"number"},"revokedTokens":{"type":"number"}},"required":["revokedSessions","revokedTokens"]},"RevokeSessionsBody":{"type":"object","properties":{"includeTokens":{"type":"boolean","default":false}}},"MemberSessions":{"type":"object","properties":{"sessions":{"type":"array","items":{"$ref":"#/components/schemas/MemberSession"}},"sessionsValidAfter":{"type":"string","nullable":true}},"required":["sessions","sessionsValidAfter"]},"MemberSession":{"type":"object","properties":{"id":{"type":"string"},"provider":{"type":"string","nullable":true},"channel":{"type":"string"},"ip":{"type":"string","nullable":true},"lastIp":{"type":"string","nullable":true},"userAgent":{"type":"string","nullable":true},"firstSeenAt":{"type":"string"},"lastSeenAt":{"type":"string"},"active":{"type":"boolean"}},"required":["id","provider","channel","ip","lastIp","userAgent","firstSeenAt","lastSeenAt","active"]},"OrgMfaStatus":{"type":"object","properties":{"policy":{"type":"string","enum":["admins","all"]},"trustIdp":{"type":"boolean"},"enforced":{"type":"boolean"},"admins":{"type":"object","properties":{"total":{"type":"integer"},"enrolled":{"type":"integer"},"missing":{"type":"integer"}},"required":["total","enrolled","missing"]},"everyone":{"type":"object","nullable":true,"properties":{"total":{"type":"integer"},"enrolled":{"type":"integer"},"missing":{"type":"integer"}},"required":["total","enrolled","missing"]},"people":{"type":"array","items":{"$ref":"#/components/schemas/MfaPersonStatus"}}},"required":["policy","trustIdp","enforced","admins","everyone","people"]},"MfaPersonStatus":{"type":"object","properties":{"principalId":{"type":"string"},"displayName":{"type":"string"},"email":{"type":"string"},"role":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]},"admin":{"type":"boolean"},"enrolled":{"type":"boolean"},"methods":{"type":"array","items":{"type":"string","enum":["totp","sms"]}},"enrolledAt":{"type":"string","nullable":true,"format":"date-time"},"lastUsedAt":{"type":"string","nullable":true,"format":"date-time"},"lastMethod":{"type":"string","nullable":true,"enum":["totp","sms","recovery",null]},"locked":{"type":"boolean"}},"required":["principalId","displayName","role","admin","enrolled","methods","enrolledAt","lastUsedAt","lastMethod","locked"]},"MfaResetPreview":{"type":"object","properties":{"principalId":{"type":"string"},"displayName":{"type":"string"},"methods":{"type":"array","items":{"type":"string","enum":["totp","sms"]}},"effect":{"type":"string","enum":["factors_removed_reenrol"]}},"required":["principalId","displayName","methods","effect"]},"MfaResetBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false,"description":"false = return a preview only; true = apply the change."}}},"OrgSecurity":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]},"resolved":{"type":"object","properties":{"admin":{"type":"object","properties":{"signIn":{"type":"object","properties":{"allowed":{"type":"array","items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]}},"unrestricted":{"type":"boolean"},"disabled":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]},"by":{"type":"string","enum":["platform","org","role","module"]}},"required":["method","by"]}},"open":{"type":"boolean"}},"required":["allowed","unrestricted","disabled","open"]},"mfa":{"type":"object","properties":{"required":{"type":"boolean"},"requiredBy":{"type":"string","nullable":true,"enum":["platform","org","role","module",null]},"trustIdp":{"type":"boolean"}},"required":["required","requiredBy","trustIdp"]}},"required":["signIn","mfa"]},"member":{"type":"object","properties":{"signIn":{"type":"object","properties":{"allowed":{"type":"array","items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]}},"unrestricted":{"type":"boolean"},"disabled":{"type":"array","items":{"type":"object","properties":{"method":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]},"by":{"type":"string","enum":["platform","org","role","module"]}},"required":["method","by"]}},"open":{"type":"boolean"}},"required":["allowed","unrestricted","disabled","open"]},"mfa":{"type":"object","properties":{"required":{"type":"boolean"},"requiredBy":{"type":"string","nullable":true,"enum":["platform","org","role","module",null]},"trustIdp":{"type":"boolean"}},"required":["required","requiredBy","trustIdp"]}},"required":["signIn","mfa"]}},"required":["admin","member"]},"offered":{"type":"array","items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]}},"ssoReady":{"type":"boolean"}},"required":["resolved","offered","ssoReady"]},"OrgSecurityInput":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"]},"mfaTrustIdp":{"type":"boolean"},"externalAgentWrite":{"type":"boolean"},"signIn":{"type":"object","properties":{"methods":{"type":"array","nullable":true,"items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]},"minItems":1,"maxItems":20},"byRole":{"type":"object","properties":{"admin":{"type":"object","nullable":true,"properties":{"methods":{"type":"array","nullable":true,"items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]},"minItems":1,"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","nullable":true,"properties":{"methods":{"type":"array","nullable":true,"items":{"type":"string","enum":["google","microsoft","email_code","phone_code","sso"]},"minItems":1,"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}}}}},"OrgLegal":{"type":"object","properties":{"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}},"texts":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he","en","pt"]},"noticeVersion":{"type":"string"},"terms":{"type":"object","properties":{"version":{"type":"string"},"termsVersion":{"type":"string"},"privacyVersion":{"type":"string"},"termsUrl":{"type":"string"},"privacyUrl":{"type":"string"},"dpaVersion":{"type":"string"},"dpaUrl":{"type":"string"},"consentRequired":{"type":"boolean"}},"required":["version","termsVersion","privacyVersion","termsUrl","privacyUrl","consentRequired"]},"orgAcceptance":{"type":"object","properties":{"accepted":{"type":"boolean"},"current":{"type":"object","nullable":true,"properties":{"id":{"type":"string","minLength":1,"maxLength":80},"kind":{"type":"string","enum":["person","org"]},"principalId":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"orgIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200,"default":[]},"role":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"termsUrl":{"type":"string","maxLength":500},"privacyUrl":{"type":"string","maxLength":500},"dpaVersion":{"type":"string","minLength":1,"maxLength":32},"dpaUrl":{"type":"string","maxLength":500},"acceptedAt":{"type":"string","format":"date-time"},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"userAgent":{"type":"string","nullable":true,"maxLength":400,"default":null},"locale":{"type":"string","nullable":true,"maxLength":35,"default":null},"clientId":{"type":"string","maxLength":500}},"required":["id","kind","principalId","orgId","termsVersion","privacyVersion","termsUrl","privacyUrl","acceptedAt","surface","channel","method"]}},"required":["accepted","current"]}},"required":["aiDisclosure","texts","noticeVersion","terms","orgAcceptance"]},"OrgLegalAcceptBody":{"type":"object","properties":{"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"accept":{"type":"boolean","enum":[true]},"locale":{"type":"string","maxLength":35}},"required":["termsVersion","privacyVersion","accept"]},"LegalAcceptances":{"type":"object","properties":{"acceptances":{"type":"array","items":{"$ref":"#/components/schemas/LegalAcceptanceRow"}}},"required":["acceptances"]},"LegalAcceptanceRow":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":80},"kind":{"type":"string","enum":["person","org"]},"principalId":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","nullable":true,"minLength":1,"maxLength":128},"orgIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200,"default":[]},"role":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"termsUrl":{"type":"string","maxLength":500},"privacyUrl":{"type":"string","maxLength":500},"dpaVersion":{"type":"string","minLength":1,"maxLength":32},"dpaUrl":{"type":"string","maxLength":500},"acceptedAt":{"type":"string","format":"date-time"},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"userAgent":{"type":"string","nullable":true,"maxLength":400,"default":null},"locale":{"type":"string","nullable":true,"maxLength":35,"default":null},"clientId":{"type":"string","maxLength":500},"principal":{"type":"object","properties":{"displayName":{"type":"string","nullable":true},"email":{"type":"string","nullable":true}},"required":["displayName","email"]}},"required":["id","kind","principalId","orgId","termsVersion","privacyVersion","termsUrl","privacyUrl","acceptedAt","surface","channel","method","principal"]},"SsoView":{"type":"object","properties":{"config":{"type":"object","nullable":true,"properties":{"orgId":{"type":"string"},"enabled":{"type":"boolean","default":false},"protocol":{"type":"string","enum":["saml","oidc"]},"providerId":{"type":"string"},"preset":{"type":"string","enum":["entra","google_workspace","oidc","saml"]},"entra":{"type":"object","properties":{"tid":{"type":"string"}},"required":["tid"]},"googleWorkspace":{"type":"object","properties":{"customerId":{"type":"string"},"primaryDomain":{"type":"string"}},"required":["customerId"]},"saml":{"type":"object","properties":{"idpEntityId":{"type":"string","minLength":1,"maxLength":1024},"ssoUrl":{"type":"string","format":"uri"},"certificates":{"type":"array","items":{"type":"string","minLength":32},"minItems":1,"maxItems":5}},"required":["idpEntityId","ssoUrl","certificates"]},"oidc":{"type":"object","properties":{"issuer":{"type":"string","format":"uri"},"clientId":{"type":"string","minLength":1,"maxLength":512},"hasSecret":{"type":"boolean","default":false}},"required":["issuer","clientId"]},"required":{"type":"boolean","default":false},"jit":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string"},"maxItems":20,"default":[]}},"default":{"enabled":true,"role":"member","groupIds":[]}},"domains":{"type":"array","items":{"type":"object","properties":{"domain":{"type":"string","minLength":3,"maxLength":253},"token":{"type":"string"},"verified":{"type":"boolean","default":false},"verifiedAt":{"type":"string","format":"date-time"},"verifiedBy":{"type":"string"},"verifiedVia":{"type":"string","enum":["dns","super_admin","microsoft_tenant","google_workspace"]}},"required":["domain","token"]},"maxItems":20,"default":[]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string"}},"required":["orgId","createdAt","updatedAt"]},"serviceProvider":{"type":"object","properties":{"entityId":{"type":"string"},"acsUrl":{"type":"string"},"redirectUri":{"type":"string"}},"required":["entityId","acsUrl","redirectUri"]},"available":{"type":"boolean"},"status":{"type":"string","enum":["connected","attention","available"]},"attentionReason":{"type":"string","enum":["microsoft_disconnected","google_workspace_disconnected","no_verified_domains","disabled"]},"scim":{"type":"object","properties":{"available":{"type":"boolean"},"enabled":{"type":"boolean"},"baseUrl":{"type":"string"},"prefix":{"type":"string"},"createdAt":{"type":"string"},"lastUsedAt":{"type":"string"}},"required":["available","enabled","baseUrl"]}},"required":["config","serviceProvider","available","status","scim"]},"SsoDomainClaim":{"type":"object","properties":{"domain":{"type":"object","properties":{"domain":{"type":"string","minLength":3,"maxLength":253},"token":{"type":"string"},"verified":{"type":"boolean","default":false},"verifiedAt":{"type":"string","format":"date-time"},"verifiedBy":{"type":"string"},"verifiedVia":{"type":"string","enum":["dns","super_admin","microsoft_tenant","google_workspace"]}},"required":["domain","token"]},"txtName":{"type":"string"},"txtValue":{"type":"string"}},"required":["domain","txtName","txtValue"]},"TenantConnection":{"type":"object","properties":{"provider":{"type":"string","enum":["microsoft","google_workspace","slack"]},"status":{"type":"string","enum":["connected","attention","available"]},"attentionReason":{"type":"string","enum":["domains_skipped","no_domains","channel_not_bound"]},"available":{"type":"boolean"},"connected":{"type":"boolean"},"appClientId":{"type":"string"},"tenants":{"type":"array","items":{"type":"object","properties":{"tenantId":{"type":"string"},"displayName":{"type":"string"},"status":{"type":"string","enum":["active","disconnected"]},"verifiedDomains":{"type":"array","items":{"type":"string"}},"skippedDomains":{"type":"array","items":{"type":"object","properties":{"domain":{"type":"string"},"reason":{"type":"string"}},"required":["domain","reason"]}},"connectedAt":{"type":"string"},"connectedBy":{"type":"string"},"disconnectedAt":{"type":"string"}},"required":["tenantId","status","verifiedDomains","skippedDomains","connectedAt","connectedBy"]}}},"required":["provider","status","available","connected","tenants"]},"TenantConnectLink":{"type":"object","properties":{"consentUrl":{"type":"string"},"expiresAt":{"type":"string"},"redirectUri":{"type":"string"},"requiredRoles":{"type":"array","items":{"type":"string"}}},"required":["consentUrl","expiresAt","redirectUri","requiredRoles"]},"GoogleWorkspaceConnectLink":{"type":"object","properties":{"consentUrl":{"type":"string"},"expiresAt":{"type":"string"},"redirectUri":{"type":"string"},"requiredRoles":{"type":"array","items":{"type":"string"}}},"required":["consentUrl","expiresAt","redirectUri","requiredRoles"]},"SlackInstallLink":{"type":"object","properties":{"installUrl":{"type":"string"},"expiresAt":{"type":"string"},"redirectUri":{"type":"string"},"scopes":{"type":"array","items":{"type":"string"}}},"required":["installUrl","expiresAt","redirectUri","scopes"]},"TelemetryProbe":{"type":"object","properties":{"ok":{"type":"boolean"},"turnId":{"type":"string"},"table":{"type":"string"},"writeMs":{"type":"number"},"readMs":{"type":"number"},"attempts":{"type":"number"},"error":{"type":"string"}},"required":["ok","turnId","table","writeMs","readMs","attempts"]},"DataErasureBody":{"type":"object","properties":{"confirm":{"type":"boolean","default":false},"confirmText":{"type":"string","maxLength":320},"reason":{"type":"string","maxLength":500}}},"LegalHoldBody":{"type":"object","properties":{"on":{"type":"boolean"},"reason":{"type":"string","minLength":1,"maxLength":500}},"required":["on"]},"OrgDeletionBody":{"type":"object","properties":{"days":{"type":"integer","minimum":0,"maximum":60,"default":30},"suspend":{"type":"boolean","default":true},"reason":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false},"confirmSlug":{"type":"string","maxLength":100}}},"SigningRegistered":{"type":"object","properties":{"envelope":{"$ref":"#/components/schemas/SigningEnvelope"},"link":{"type":"string"},"sent":{"type":"boolean"}},"required":["envelope","link","sent"]},"SigningEnvelope":{"type":"object","properties":{"id":{"type":"string"},"quoteNumber":{"type":"string"},"title":{"type":"string"},"customer":{"type":"object","properties":{"legalName":{"type":"string"},"companyId":{"type":"string","nullable":true}},"required":["legalName","companyId"]},"orgId":{"type":"string","nullable":true},"signer":{"type":"object","properties":{"email":{"type":"string"},"name":{"type":"string","nullable":true}},"required":["email","name"]},"locale":{"type":"string","enum":["he","en"]},"status":{"type":"string","enum":["open","signed","void"]},"expiresAt":{"type":"string"},"rendered":{"type":"object","properties":{"sha256":{"type":"string"},"bytes":{"type":"number"},"pages":{"type":"number"}},"required":["sha256","bytes","pages"]},"original":{"type":"object","properties":{"sha256":{"type":"string"},"bytes":{"type":"number"},"pages":{"type":"number"}},"required":["sha256","bytes","pages"]},"signed":{"type":"object","nullable":true,"properties":{"sha256":{"type":"string"},"bytes":{"type":"number"},"pages":{"type":"number"},"at":{"type":"string"}},"required":["sha256","bytes","pages","at"]},"fields":{"type":"array","items":{"type":"object","properties":{"party":{"type":"string","enum":["wizbi","customer"]},"field":{"type":"string","enum":["name","signature","date"]},"page":{"type":"number"},"rect":{"type":"array","items":{"type":"number"}}},"required":["party","field","page","rect"]}},"legal":{"type":"object","properties":{"documents":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"version":{"type":"string"},"url":{"type":"string"},"pdfs":{"type":"array","items":{"type":"object","properties":{"lang":{"type":"string"},"url":{"type":"string"},"sha256":{"type":"string"}},"required":["lang","url","sha256"]}}},"required":["key","version","url","pdfs"]}}},"required":["documents"]},"wizbiSignature":{"type":"object","nullable":true,"properties":{"principalId":{"type":"string"},"name":{"type":"string"},"title":{"type":"string"},"at":{"type":"string"}},"required":["principalId","name","title","at"]},"firstOpenedAt":{"type":"string","nullable":true},"codeSentAt":{"type":"string","nullable":true},"createdBy":{"type":"string"},"createdAt":{"type":"string"},"voidedAt":{"type":"string","nullable":true}},"required":["id","quoteNumber","title","customer","orgId","signer","locale","status","expiresAt","rendered","original","signed","fields","legal","wizbiSignature","firstOpenedAt","codeSentAt","createdBy","createdAt","voidedAt"]},"SigningRegister":{"type":"object","properties":{"pdfBase64":{"type":"string","minLength":100,"maxLength":21000000},"quoteNumber":{"type":"string","minLength":1,"maxLength":60},"title":{"type":"string","minLength":1,"maxLength":200},"customer":{"type":"object","properties":{"legalName":{"type":"string","minLength":1,"maxLength":200},"companyId":{"type":"string","nullable":true,"maxLength":40}},"required":["legalName"]},"orgId":{"type":"string","nullable":true,"maxLength":80},"signer":{"type":"object","properties":{"email":{"type":"string","maxLength":254,"format":"email"},"name":{"type":"string","nullable":true,"maxLength":120}},"required":["email"]},"locale":{"type":"string","enum":["he","en"]},"validUntil":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"clauseText":{"type":"string","minLength":1,"maxLength":4000},"wizbiSigner":{"type":"object","nullable":true,"properties":{"name":{"type":"string","minLength":1,"maxLength":120},"title":{"type":"string","minLength":1,"maxLength":120}},"required":["name","title"]},"send":{"type":"boolean"}},"required":["pdfBase64","quoteNumber","title","customer","signer","clauseText"]}},"parameters":{}},"paths":{"/healthz":{"get":{"tags":["ops"],"summary":"Liveness probe","responses":{"200":{"description":"The service is up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/health":{"get":{"tags":["ops"],"summary":"Service health","responses":{"200":{"description":"The service is up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Health"}}}}}}},"/api/meta":{"get":{"tags":["ops"],"summary":"Public runtime facts","description":"Build version, environment, MCP on/off and a revision fingerprint. The manifest and the GCP facts are at /api/admin/meta (super_admin).","responses":{"200":{"description":"Public runtime facts.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meta"}}}}}}},"/api/hooks/monitoring":{"post":{"tags":["ops"],"summary":"Cloud Monitoring / Billing → Slack","description":"Pub/Sub push endpoint. Verifies the Google OIDC token of the push subscription, decodes the Monitoring incident or Billing budget payload, and posts to the matching #core-* channel.","security":[{"oidc":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PubSubPush"}}}},"responses":{"200":{"description":"Routed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MonitoringHookResult"}}}},"401":{"description":"Missing or invalid OIDC token."},"403":{"description":"Token is valid but not the push identity."},"502":{"description":"Slack refused the message; Pub/Sub will retry."},"503":{"description":"Hook disabled (MONITORING_PUSH_SA unset)."}}}},"/api/oauth/register":{"post":{"tags":["oauth"],"summary":"Dynamic client registration (RFC 7591)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"client_name":{"type":"string","minLength":1,"maxLength":200},"redirect_uris":{"type":"array","items":{"type":"string","format":"uri"},"minItems":1,"maxItems":20},"token_endpoint_auth_method":{"type":"string","enum":["none","client_secret_post","client_secret_basic"],"default":"none"},"grant_types":{"type":"array","items":{"type":"string"},"default":["authorization_code"]},"response_types":{"type":"array","items":{"type":"string"},"default":["code"]},"scope":{"type":"string","maxLength":500},"client_uri":{"type":"string","format":"uri"},"logo_uri":{"type":"string","format":"uri"},"contacts":{"type":"array","items":{"type":"string"},"maxItems":10},"software_id":{"type":"string","maxLength":200},"software_version":{"type":"string","maxLength":100},"application_type":{"type":"string","maxLength":32}},"required":["redirect_uris"]}}}},"responses":{"201":{"description":"Registered; `client_secret` appears once for confidential clients.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid metadata.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/oauth/authorize":{"get":{"tags":["oauth"],"summary":"Validate the authorization request and send the browser to the sign-in page (JSON when Accept: application/json)","parameters":[{"schema":{"type":"string"},"required":true,"name":"response_type","in":"query"},{"schema":{"type":"string"},"required":true,"name":"client_id","in":"query"},{"schema":{"type":"string"},"required":true,"name":"redirect_uri","in":"query"},{"schema":{"type":"string"},"required":false,"name":"code_challenge","in":"query"},{"schema":{"type":"string"},"required":false,"name":"code_challenge_method","in":"query"},{"schema":{"type":"string"},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string"},"required":false,"name":"state","in":"query"},{"schema":{"type":"string"},"required":false,"name":"resource","in":"query"},{"schema":{"type":"string"},"required":false,"name":"iss","in":"query"}],"responses":{"200":{"description":"Validated parameters (JSON clients).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"302":{"description":"Redirect to the sign-in page — or, once the client and its redirect URI are valid, back to the client with `error`, `state` and `iss` (RFC 6749 §4.1.2.1, RFC 9207)."},"400":{"description":"Invalid request (unknown client, unregistered redirect URI).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/oauth/authorize/complete":{"post":{"tags":["oauth"],"summary":"Second phase: a Firebase ID token plus the original parameters → code, choose_org, or a preview of the scopes","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id_token":{"type":"string","minLength":1},"org_id":{"type":"string"},"response_type":{"type":"string"},"client_id":{"type":"string"},"redirect_uri":{"type":"string"},"code_challenge":{"type":"string"},"code_challenge_method":{"type":"string"},"scope":{"type":"string"},"state":{"type":"string"},"resource":{"type":"string"},"iss":{"type":"string"},"preview":{"type":"boolean"}},"required":["id_token","response_type","client_id","redirect_uri"]}}}},"responses":{"200":{"description":"`{status:\"ok\", redirect, scope}`, `{status:\"choose_org\", orgs}` or `{status:\"preview\", scope, requestedScope}`.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"401":{"description":"Bad ID token or no identifier.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/oauth/token":{"post":{"tags":["oauth"],"summary":"authorization_code (PKCE) or refresh_token (rotating) → an hour-long wz_ access token and a wzr_ refresh token","responses":{"200":{"description":"Token (`Cache-Control: no-store`).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"invalid_grant / invalid_request / unsupported_grant_type / invalid_scope / invalid_target.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"invalid_client.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/oauth/revoke":{"post":{"tags":["oauth"],"summary":"Revoke a token (RFC 7009): a wzr_ refresh token ends its grant, a wz_ access token only itself","responses":{"200":{"description":"Revoked or ignored (unknown tokens and other clients’ tokens).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"invalid_client: a client named itself and failed authentication.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/oauth/userinfo":{"get":{"tags":["oauth"],"summary":"Who connected: `sub`, `email`, `email_verified` (an access token of a grant that asked for openid or email)","responses":{"200":{"description":"Claims.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"401":{"description":"invalid_token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope: the grant did not ask for openid or email.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["oauth"],"summary":"Who connected: `sub`, `email`, `email_verified` (an access token of a grant that asked for openid or email)","responses":{"200":{"description":"Claims.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"401":{"description":"invalid_token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope: the grant did not ask for openid or email.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/oauth-authorization-server":{"get":{"tags":["oauth"],"summary":"Authorization server metadata (RFC 8414) on the public origin","responses":{"200":{"description":"Metadata.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"404":{"description":"No public host to advertise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/oauth-protected-resource":{"get":{"tags":["oauth"],"summary":"Protected resource metadata (RFC 9728) on the public origin","responses":{"200":{"description":"Metadata.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"404":{"description":"No public host to advertise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/oauth-protected-resource/api/mcp":{"get":{"tags":["oauth"],"summary":"Protected resource metadata (RFC 9728) of /api/mcp (admin surface)","responses":{"200":{"description":"Metadata.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"404":{"description":"No public host to advertise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/oauth-protected-resource/api/mcp/standard":{"get":{"tags":["oauth"],"summary":"Protected resource metadata (RFC 9728) of /api/mcp/standard (standard surface)","responses":{"200":{"description":"Metadata.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"404":{"description":"No public host to advertise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/oauth-protected-resource/admin":{"get":{"tags":["oauth"],"summary":"Protected resource metadata (RFC 9728) of /admin (admin surface)","responses":{"200":{"description":"Metadata.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"404":{"description":"No public host to advertise.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/oauth-grants":{"get":{"tags":["oauth"],"summary":"The apps and agents connected to my account over OAuth (grants), newest first","responses":{"200":{"description":"Grants.","content":{"application/json":{"schema":{"type":"object","properties":{"grants":{"type":"array","items":{"$ref":"#/components/schemas/OAuthGrant"}}},"required":["grants"]}}}}}}},"/api/me/oauth-grants/{grantId}":{"delete":{"tags":["oauth"],"summary":"Disconnect one of my OAuth grants: its refresh token and access tokens stop at once","parameters":[{"schema":{"type":"string","pattern":"^grt_[0-9a-f]{24}$"},"required":true,"name":"grantId","in":"path"}],"responses":{"200":{"description":"Revoked (idempotent).","content":{"application/json":{"schema":{"type":"object","properties":{"grant":{"$ref":"#/components/schemas/OAuthGrant"}},"required":["grant"]}}}},"404":{"description":"Not my grant.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/oauth-grants":{"get":{"tags":["oauth"],"summary":"Apps and agents connected to this organization over OAuth (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Grants.","content":{"application/json":{"schema":{"type":"object","properties":{"grants":{"type":"array","items":{"$ref":"#/components/schemas/OAuthGrant"}}},"required":["grants"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/oauth-grants/{grantId}":{"delete":{"tags":["oauth"],"summary":"Disconnect an OAuth grant of this organization (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^grt_[0-9a-f]{24}$"},"required":true,"name":"grantId","in":"path"}],"responses":{"200":{"description":"Revoked (idempotent).","content":{"application/json":{"schema":{"type":"object","properties":{"grant":{"$ref":"#/components/schemas/OAuthGrant"}},"required":["grant"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a grant of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/oauth-clients":{"get":{"tags":["oauth"],"summary":"OAuth clients registered by this organization (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Clients.","content":{"application/json":{"schema":{"type":"object","properties":{"clients":{"type":"array","items":{"$ref":"#/components/schemas/OAuthClient"}}},"required":["clients"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["oauth"],"summary":"Register an OAuth client for MCP access (org_admin; secret shown once)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOAuthClientBody"}}}},"responses":{"201":{"description":"Registered.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/OAuthClient"},{"type":"object","properties":{"clientSecret":{"type":"string"}}}]}}}},"400":{"description":"Invalid metadata.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/oauth-clients/{id}":{"delete":{"tags":["oauth"],"summary":"Delete an OAuth client of this organization (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a client of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/.well-known/ai-catalog.json":{"get":{"tags":["ops"],"summary":"AI Catalog of this host (MCP Server Card, and an A2A Agent Card when served)","responses":{"200":{"description":"The catalog.","content":{"application/ai-catalog+json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"304":{"description":"Not modified (`If-None-Match`)."},"404":{"description":"No public host to advertise."}}}},"/server-card":{"get":{"tags":["ops"],"summary":"MCP Server Card of the standard surface (on the MCP host: `<mcp-url>/server-card`)","responses":{"200":{"description":"The Server Card.","content":{"application/mcp-server-card+json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"304":{"description":"Not modified (`If-None-Match`)."},"404":{"description":"No public host to advertise, or not the MCP host."}}}},"/.well-known/mcp/server-card.json":{"get":{"tags":["ops"],"summary":"MCP Server Card (alias for scanners: /.well-known/mcp/server-card.json)","responses":{"200":{"description":"The Server Card.","content":{"application/mcp-server-card+json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"304":{"description":"Not modified (`If-None-Match`)."},"404":{"description":"No public host to advertise, or not the MCP host."}}}},"/.well-known/mcp":{"get":{"tags":["ops"],"summary":"MCP Server Card (alias for scanners: /.well-known/mcp)","responses":{"200":{"description":"The Server Card.","content":{"application/mcp-server-card+json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"304":{"description":"Not modified (`If-None-Match`)."},"404":{"description":"No public host to advertise, or not the MCP host."}}}},"/.well-known/agent-card.json":{"get":{"tags":["ops"],"summary":"A2A 1.0 Agent Card — only when an A2A endpoint is configured (A2A_INTERFACE_URL)","responses":{"200":{"description":"The Agent Card.","content":{"application/a2a+json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"304":{"description":"Not modified (`If-None-Match`)."},"404":{"description":"No A2A endpoint on this deployment."}}}},"/.well-known/openai-apps-challenge":{"get":{"tags":["ops"],"summary":"OpenAI apps domain verification token (OPENAI_APPS_CHALLENGE), text/plain","responses":{"200":{"description":"The token.","content":{"text/plain":{"schema":{"type":"string"}}}},"404":{"description":"Not configured."}}}},"/api/auth/code/start":{"post":{"tags":["auth"],"summary":"Send a 6-digit sign-in code to an e-mail, or tell the browser to run phone OTP","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthCodeStartBody"}}}},"responses":{"200":{"description":"Accepted (generic — never reveals whether the address is allowed).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthCodeStartResponse"}}}},"400":{"description":"Not an e-mail or a phone.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Outbound mail is not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/code/verify":{"post":{"tags":["auth"],"summary":"Exchange the e-mailed code for a Firebase custom token","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthCodeVerifyBody"}}}},"responses":{"200":{"description":"Signed in: `signInWithCustomToken(customToken)` in the browser.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthCodeVerifyResponse"}}}},"400":{"description":"Wrong, expired or burnt code (`invalid_code`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"This account is not allowed to sign in yet (`signin_restricted`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/link/start":{"post":{"tags":["auth"],"summary":"Microsoft without a verified e-mail: mail a one-time code to prove the address (Bearer = the Microsoft ID token)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthLinkStartBody"}}}},"responses":{"200":{"description":"A code was (or would have been) mailed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthLinkStartResponse"}}}},"400":{"description":"Not a Microsoft sign-in, or no address.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The account already has a verified e-mail.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/link/verify":{"post":{"tags":["auth"],"summary":"Prove the address with the code; it is linked to this Microsoft identity for good","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthLinkVerifyBody"}}}},"responses":{"200":{"description":"Linked: call /api/me again.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthLinkVerifyResponse"}}}},"400":{"description":"Wrong, expired or burnt code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed (`signin_restricted`, `sso_required`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/auth/blocking/before-create":{"post":{"tags":["auth"],"summary":"Identity Platform blocking hook: beforeCreate","description":"Called by Identity Platform only (ADR-0051). The JWT in the body is the credential: Google-signed, issuer = this project, audience = the registered function URI. Answers 200 `{}` to allow and 403 `{error:{status:\"PERMISSION_DENIED\",message:\"wizbi:<code>\"}}` to refuse. Off by default (`AUTH_BLOCKING_CREATE` / `AUTH_BLOCKING_SIGN_IN`).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthBlockingRequest"}}}},"responses":{"200":{"description":"Allowed (or, with the peer header, this environment's decision)."},"400":{"description":"No JWT in the body."},"401":{"description":"Not a genuine Identity Platform blocking token of this project."},"403":{"description":"Refused: `wizbi:<code>` in `error.message`."}}}},"/api/auth/blocking/before-sign-in":{"post":{"tags":["auth"],"summary":"Identity Platform blocking hook: beforeSignIn","description":"Called by Identity Platform only (ADR-0051). The JWT in the body is the credential: Google-signed, issuer = this project, audience = the registered function URI. Answers 200 `{}` to allow and 403 `{error:{status:\"PERMISSION_DENIED\",message:\"wizbi:<code>\"}}` to refuse. Off by default (`AUTH_BLOCKING_CREATE` / `AUTH_BLOCKING_SIGN_IN`).","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthBlockingRequest"}}}},"responses":{"200":{"description":"Allowed (or, with the peer header, this environment's decision)."},"400":{"description":"No JWT in the body."},"401":{"description":"Not a genuine Identity Platform blocking token of this project."},"403":{"description":"Refused: `wizbi:<code>` in `error.message`."}}}},"/api/hooks/telegram/{bindingId}":{"post":{"tags":["webhooks"],"summary":"Telegram Bot API webhook","parameters":[{"schema":{"type":"string"},"required":true,"name":"bindingId","in":"path"}],"responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/slack/events":{"post":{"tags":["webhooks"],"summary":"Slack Events API","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/slack/interactive":{"post":{"tags":["webhooks"],"summary":"Slack interactive payloads","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/teams/messages":{"post":{"tags":["webhooks"],"summary":"Microsoft Teams (Bot Framework) messages","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/twilio/whatsapp":{"post":{"tags":["webhooks"],"summary":"Twilio WhatsApp inbound","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/twilio/sms":{"post":{"tags":["webhooks"],"summary":"Twilio SMS inbound","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/twilio/voice":{"post":{"tags":["webhooks"],"summary":"Twilio voice call → ConversationRelay TwiML","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/meta/whatsapp":{"get":{"tags":["webhooks"],"summary":"Meta webhook subscription handshake","parameters":[{"schema":{"type":"string"},"required":false,"name":"hub.mode","in":"query"},{"schema":{"type":"string"},"required":false,"name":"hub.verify_token","in":"query"},{"schema":{"type":"string"},"required":false,"name":"hub.challenge","in":"query"}],"responses":{"200":{"description":"Challenge echoed."},"403":{"description":"Verify token mismatch."},"503":{"description":"Disabled."}}},"post":{"tags":["webhooks"],"summary":"WhatsApp Cloud API inbound","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/wa-gateway/{bindingId}":{"post":{"tags":["webhooks"],"summary":"WhatsApp via the WizBI whatsapp-gateway (signed forward of a Meta change)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"bindingId","in":"path"}],"responses":{"200":{"description":"Acknowledged; messages run after the response, statuses are ignored."},"401":{"description":"Transport authentication failed (one body for every reason)."},"403":{"description":"The whatsapp-gateway channel module is off (`module_disabled`)."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/email/inbound":{"post":{"tags":["webhooks"],"summary":"Inbound email (Inbound Parse shape)","responses":{"200":{"description":"Acknowledged; the turn runs after the response."},"401":{"description":"Transport authentication failed."},"403":{"description":"Signature mismatch, or the channel module is off (`module_disabled`)."},"404":{"description":"No binding for this provider account."},"503":{"description":"Hook disabled (adapter not configured)."}}}},"/api/hooks/gowa/{bindingId}":{"post":{"tags":["webhooks"],"summary":"WhatsApp-Web (GOWA bridge) webhook — the turn runs inside the request","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"bindingId","in":"path"}],"responses":{"200":{"description":"Processed (answered, silent or dropped — the gate log says which)."},"401":{"description":"Transport authentication failed (one body for every reason)."},"403":{"description":"The whatsapp-web channel module is off (`module_disabled`)."},"503":{"description":"Not a wa-web instance (hook_disabled)."}}}},"/api/hooks/gowa/{bindingId}/health":{"get":{"tags":["webhooks"],"summary":"WhatsApp-Web bridge health: would a send work right now?","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"bindingId","in":"path"},{"schema":{"type":"string","enum":["0","1"]},"required":false,"name":"selfcheck","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":1440},"required":false,"name":"silentMin","in":"query"}],"responses":{"200":{"description":"The bridge answers and the configured slot is logged in."},"503":{"description":"Bridge unreachable, not paired, device mismatch, or not a wa-web instance."}}}},"/api/jobs/run":{"post":{"tags":["ops"],"summary":"Job worker (Cloud Tasks push, OIDC)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobEnvelope"}}}},"responses":{"200":{"description":"Handled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobRunResult"}}}},"401":{"description":"Not the task invoker.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"500":{"description":"Failed; retry.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobRunResult"}}}},"503":{"description":"Busy or disabled.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/jobs/tick":{"post":{"tags":["ops"],"summary":"Scheduler tick: enqueue due schedules, sweep lost work (Cloud Scheduler, OIDC)","responses":{"200":{"description":"Tick summary.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobsTickResult"}}}},"401":{"description":"Not the scheduler.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"]}}}}}}},"/api/ops/stream-probe":{"post":{"tags":["ops"],"summary":"Stream SSE ticks for N seconds (proxy / timeout diagnostic, project key)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"seconds":{"type":"integer","minimum":1,"maximum":300,"default":90}}}}}},"responses":{"200":{"description":"SSE: tick… then done.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"401":{"description":"No or wrong project key."},"503":{"description":"No project key configured."}}}},"/api/me":{"get":{"tags":["me"],"summary":"The signed-in principal, its memberships and organizations","responses":{"200":{"description":"Me.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["me"],"summary":"Update the signed-in principal (display name, language, notifications)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MePatchBody"}}}},"responses":{"200":{"description":"The principal.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["person","agent","room","service"]},"status":{"type":"string","enum":["active","pending","suspended"],"default":"active"},"displayName":{"type":"string","minLength":1,"maxLength":200},"phone":{"type":"string","pattern":"^\\+[1-9]\\d{6,14}$"},"email":{"type":"string","format":"email"},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"primaryOrgId":{"type":"string","minLength":1,"maxLength":128},"superAdmin":{"type":"boolean","default":false},"aliases":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string","enum":["firebase","phone","email","google","microsoft","slack","telegram","whatsapp","lid","api","channel","wa_bsuid"]},"externalId":{"type":"string","minLength":1,"maxLength":256},"verified":{"type":"boolean","default":false},"verifiedAt":{"type":"string","format":"date-time"},"linkedAt":{"type":"string","format":"date-time"}},"required":["provider","externalId"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"activeOrgId":{"type":"string","minLength":1,"maxLength":128},"lastSeenAt":{"type":"string","format":"date-time"},"presence":{"type":"object","properties":{"web":{"type":"string","format":"date-time"},"mcp":{"type":"string","format":"date-time"},"rest":{"type":"string","format":"date-time"},"whatsapp":{"type":"string","format":"date-time"},"whatsapp_web":{"type":"string","format":"date-time"},"telegram":{"type":"string","format":"date-time"},"sms":{"type":"string","format":"date-time"},"slack":{"type":"string","format":"date-time"},"teams":{"type":"string","format":"date-time"},"email":{"type":"string","format":"date-time"},"voice":{"type":"string","format":"date-time"},"scheduled":{"type":"string","format":"date-time"}},"default":{}},"demoSandbox":{"type":"boolean"},"lastSignInAt":{"type":"string","format":"date-time"},"notifications":{"type":"object","properties":{"digest":{"type":"string","enum":["daily","weekly","off"],"default":"weekly"},"alerts":{"type":"boolean","default":true}}},"consent":{"type":"object","properties":{"version":{"type":"string","minLength":1,"maxLength":32},"acceptedAt":{"type":"string","format":"date-time"},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"recordId":{"type":"string","maxLength":80}},"required":["version","acceptedAt","channel","method"]},"sessionsValidAfter":{"type":"string","format":"date-time"},"deletedAt":{"type":"string","format":"date-time"},"deletedBy":{"type":"string","maxLength":128},"emailAsserted":{"type":"boolean"},"phoneAsserted":{"type":"boolean"}},"required":["id","kind","displayName","createdAt"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/active-org":{"post":{"tags":["me"],"summary":"Set the channel-scoped active organization (non-destructive; null resets)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActiveOrgBody"}}}},"responses":{"200":{"description":"The new active org.","content":{"application/json":{"schema":{"type":"object","properties":{"activeOrgId":{"type":"string","nullable":true}},"required":["activeOrgId"]}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/orgs":{"get":{"tags":["me"],"summary":"My organizations, the primary org (★) first, with my role and the active org","responses":{"200":{"description":"My organizations.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyOrgs"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/primary-org":{"put":{"tags":["me"],"summary":"Set my primary organization (★): where my direct chats, MCP and unpinned tokens answer from","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrimaryOrgBody"}}}},"responses":{"200":{"description":"The new primary org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrimaryOrgChange"}}}},"403":{"description":"Not an organization I may enter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"org_not_found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/join":{"post":{"tags":["me"],"summary":"Redeem a JOIN code for the signed-in principal (transactional; grant with the burn)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinBody"}}}},"responses":{"200":{"description":"Joined.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JoinResponse"}}}},"404":{"description":"invite_code_invalid: unknown, revoked or expired code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"invite_code_exhausted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/phones":{"get":{"tags":["me"],"summary":"The phone numbers and WhatsApp ids WizBI recognises me by (an org admin manages them; self-service pairing comes later)","responses":{"200":{"description":"My phones.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MyPhones"}}}}}}},"/api/me/pairing":{"get":{"tags":["me"],"summary":"Is connecting my WhatsApp by a code offered here, and to which number","responses":{"200":{"description":"The door.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairingDoor"}}}}}}},"/api/me/pairing-code":{"post":{"tags":["me"],"summary":"A CONNECT- code (10 minutes, single use) to send from my phone to the WizBI WhatsApp number; it links that phone to me","responses":{"200":{"description":"The code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PairingCode"}}}},"400":{"description":"org_required: I am not an active member of any organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"pairing_unavailable: self pairing is off here.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/phones/{phone}":{"delete":{"tags":["me"],"summary":"Unlink one of my phone numbers: messages from it are no longer recognised as me (the next number becomes primary)","parameters":[{"schema":{"type":"string","minLength":3,"maxLength":40},"required":true,"name":"phone","in":"path"}],"responses":{"200":{"description":"Unlinked.","content":{"application/json":{"schema":{"type":"object","properties":{"removed":{"type":"boolean"},"primary":{"type":"string","nullable":true}},"required":["removed","primary"]}}}},"404":{"description":"Not one of my numbers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/connect/preview":{"get":{"tags":["me"],"summary":"What a /connect link is for, before signing in: the channel, the organization, a masked hint of the chat identity, the expiry and the sign-in methods the organization accepts","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"t","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectPreview"}}}},"503":{"description":"Linking is not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/channel-links":{"get":{"tags":["me"],"summary":"My connected chat identities (Teams, Slack, Telegram, WhatsApp…): channel, masked identity, when","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelLinks"}}}}}},"post":{"tags":["me"],"summary":"Connect the chat identity of a /connect link to my account (I must be an active member of the organization the chat belongs to)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelLinkBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelLinkResult"}}}},"400":{"description":"connect_link_invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"connect_not_member: not a member of the organization (`org`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"connect_link_used, or connect_already_linked (another account).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"410":{"description":"connect_link_expired.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"connect_unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/channel-links/{linkId}":{"delete":{"tags":["me"],"summary":"Disconnect one of my chat identities (the bot stops recognising it)","parameters":[{"schema":{"type":"string","minLength":3,"maxLength":300},"required":true,"name":"linkId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"removed":{"$ref":"#/components/schemas/ChannelLink"}},"required":["removed"]}}}},"404":{"description":"Not linked to me.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/identities":{"get":{"tags":["people"],"summary":"A member's chat identities linked through this organization's channels (org_admin, or the member)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelLinks"}}}},"403":{"description":"Neither an org admin nor the member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/identities/{linkId}":{"delete":{"tags":["people"],"summary":"Disconnect a member's chat identity linked through this organization (org_admin; two-step: `?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","minLength":3,"maxLength":300},"required":true,"name":"linkId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"allOf":[{"$ref":"#/components/schemas/ChannelLink"},{"type":"object","properties":{"action":{"type":"string","enum":["unlink"]}},"required":["action"]}]}},"required":["preview"]},{"type":"object","properties":{"applied":{"allOf":[{"$ref":"#/components/schemas/ChannelLink"},{"type":"object","properties":{"action":{"type":"string","enum":["unlink"]}},"required":["action"]}]}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such linked identity for this member in this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs":{"post":{"tags":["orgs"],"summary":"Create an organization; the caller becomes its org_admin (self sign-up — off by default: super admins only)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrgBody"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"runtimeIdentity":{"type":"string"},"filesBucket":{"type":"string"},"stagingBucket":{"type":"string"}},"default":{}},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}}},"required":["id","slug","name","createdAt"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Self sign-up is off: a super admin opens organizations.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}":{"get":{"tags":["orgs"],"summary":"One organization (members only) with member count and data-plane status","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationView"}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["orgs"],"summary":"Update an organization (org_admin; tier, status and kind are super_admin only)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchOrgBody"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"tier":{"type":"string","enum":["standard","dedicated","byoc"],"default":"standard"},"status":{"type":"string","enum":["active","suspended","archived"],"default":"active"},"kind":{"type":"string","enum":["customer","internal","demo","system","test","personal"]},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"region":{"type":"string","enum":["europe-west1"],"default":"europe-west1"},"branding":{"type":"object","properties":{"brand":{"type":"string","maxLength":32},"logoUrl":{"type":"string","format":"uri"}},"default":{}},"data":{"type":"object","properties":{"projectId":{"type":"string"},"datasetId":{"type":"string"},"runtimeIdentity":{"type":"string"},"filesBucket":{"type":"string"},"stagingBucket":{"type":"string"}},"default":{}},"plan":{"type":"object","properties":{"id":{"type":"string"},"quotas":{"type":"object","additionalProperties":{"type":"number"},"default":{}}},"required":["id"]},"retention":{"type":"object","properties":{"conversationDays":{"type":"integer","minimum":1,"maximum":3650}}},"timezone":{"type":"string","minLength":1,"maxLength":64},"greetingExamples":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":12},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0},"emailDomains":{"type":"array","items":{"type":"string"},"default":[]},"security":{"type":"object","properties":{"mfa":{"type":"string","enum":["admins","all"],"default":"admins"},"mfaTrustIdp":{"type":"boolean","default":false},"signIn":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"open":{"type":"boolean","default":false},"byRole":{"type":"object","properties":{"admin":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}},"member":{"type":"object","properties":{"methods":{"type":"array","items":{"type":"string"},"maxItems":20},"mfa":{"type":"object","properties":{"required":{"type":"boolean"}}}}}}}},"default":{"open":false}},"externalAgentWrite":{"type":"boolean","default":false},"lockedBy":{"type":"string","enum":["platform"]}}},"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}}},"required":["id","slug","name","createdAt"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/skill":{"get":{"tags":["orgs"],"summary":"The organization skill (markdown the agent reads on every turn)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The skill.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSkill"}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["orgs"],"summary":"Replace the organization skill (org_admin; two-step; stale version answers 409)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutSkillBody"}}}},"responses":{"200":{"description":"Preview or the new skill.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"$ref":"#/components/schemas/OrgSkill"}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/skill/versions":{"get":{"tags":["orgs"],"summary":"Skill history, newest first (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Versions.","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"$ref":"#/components/schemas/OrgSkillVersion"}}},"required":["versions"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/skill/versions/{version}":{"get":{"tags":["orgs"],"summary":"One historical skill version (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"version","in":"path"}],"responses":{"200":{"description":"The version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSkill"}}}},"404":{"description":"Unknown version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/skill/restore":{"post":{"tags":["orgs"],"summary":"Restore a historical version as a NEW version (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RestoreSkillBody"}}}},"responses":{"200":{"description":"Preview or the restored skill.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"$ref":"#/components/schemas/OrgSkill"}]}}}},"404":{"description":"Unknown version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people":{"get":{"tags":["people"],"summary":"Members (effective role, groups, presence per channel) and pending invitations","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"People.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/People"}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["people"],"summary":"Invite by e-mail or phone (identifier-keyed, one-shot) and tell them: an e-mail, or a WhatsApp / SMS for a phone, with a personal sign-in link (`send: false` = create only); or attach an existing principal","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddPersonBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/Preview"},{"$ref":"#/components/schemas/Applied"}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Phone belongs to another account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}":{"patch":{"tags":["people"],"summary":"Change role, membership status or groups (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchPersonBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/Preview"},{"$ref":"#/components/schemas/Applied"}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["people"],"summary":"Remove a member (two-step: `?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/Preview"},{"$ref":"#/components/schemas/Applied"}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/phones":{"get":{"tags":["people"],"summary":"A member's phone numbers (org_admin), and whether you may change them","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"Phones.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonPhones"}}}},"403":{"description":"Not an admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["people"],"summary":"Link a phone number to a member: WhatsApp, SMS and voice recognise them by it (two-step; a number of another account is refused with phone_taken)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddPersonPhoneBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role · target_protected · target_in_other_orgs.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_taken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/phones/{phone}":{"delete":{"tags":["people"],"summary":"Unlink a phone number from a member (two-step: `?confirm=true` applies); the next one becomes primary","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","minLength":3,"maxLength":40},"required":true,"name":"phone","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role · target_protected · target_in_other_orgs.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_taken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/account":{"delete":{"tags":["people"],"summary":"Delete a person's account everywhere: every membership, token, session, phone and sign-in (two-step: `?confirm=true` applies). An org admin may do it only for a person who belongs to this org alone; conversations stay under the org's retention","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role · target_protected · target_in_other_orgs.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_taken.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/invites/{id}":{"get":{"tags":["invites"],"summary":"One personal invitation (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Invitation.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"identifier":{"type":"object","properties":{"kind":{"type":"string","enum":["email","phone"]},"value":{"type":"string","minLength":3}},"required":["kind","value"]},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"status":{"type":"string","enum":["pending","consumed"],"default":"pending"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"},"expiresAt":{"type":"string","format":"date-time"},"consumedAt":{"type":"string","format":"date-time"},"consumedBy":{"type":"string","minLength":1,"maxLength":128},"linkKey":{"type":"string","minLength":16,"maxLength":64},"delivery":{"type":"object","properties":{"channel":{"type":"string","enum":["email","whatsapp","sms","manual"]},"status":{"type":"string","enum":["sent","failed","manual"]},"at":{"type":"string","format":"date-time"},"error":{"type":"string","maxLength":120},"attempts":{"type":"integer","minimum":0,"default":1}},"required":["channel","status","at"]}},"required":["id","orgId","identifier","createdBy","createdAt"]}}}},"404":{"description":"Unknown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["invites"],"summary":"Revoke a personal invitation (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"revoked":{"type":"string"}},"required":["revoked"]}}}},"404":{"description":"Unknown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/invites/{id}/resend":{"post":{"tags":["invites"],"summary":"Send a pending invitation again: e-mail, or WhatsApp / SMS for a phone (org_admin; two-step: `confirm: true` sends). At most once a minute, five times a day","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteResendBody"}}}},"responses":{"200":{"description":"Preview or result (`delivery`: channel, sent | failed | manual).","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/InviteResendPreview"},{"$ref":"#/components/schemas/InviteResendApplied"}]}}}},"404":{"description":"Unknown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"rate_limited (`retryAfter` seconds).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/invites/preview":{"get":{"tags":["invites"],"summary":"What an invitation link is for, before signing in: the organization name, e-mail or phone, and the sign-in methods the organization accepts","parameters":[{"schema":{"type":"string","maxLength":64},"required":false,"name":"k","in":"query"}],"responses":{"200":{"description":"Preview.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteLinkPreview"}}}}}}},"/api/orgs/{orgId}/invite-codes":{"get":{"tags":["invites"],"summary":"JOIN codes of the organization (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Codes.","content":{"application/json":{"schema":{"type":"object","properties":{"codes":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"code":{"type":"string","pattern":"^JOIN-[A-Z0-9]{4,16}$"},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"maxUses":{"type":"integer","minimum":0,"exclusiveMinimum":true},"uses":{"type":"integer","minimum":0,"default":0},"expiresAt":{"type":"string","format":"date-time"},"revokedAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"}},"required":["id","orgId","code","createdBy","createdAt"]}}},"required":["codes"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["invites"],"summary":"Create a shareable JOIN code (org_admin). It always expires: `expiresAt` or `expiresInDays`, default 14 days, at most 365","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInviteCodeBody"}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"code":{"type":"string","pattern":"^JOIN-[A-Z0-9]{4,16}$"},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":[]},"maxUses":{"type":"integer","minimum":0,"exclusiveMinimum":true},"uses":{"type":"integer","minimum":0,"default":0},"expiresAt":{"type":"string","format":"date-time"},"revokedAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"createdAt":{"type":"string","format":"date-time"}},"required":["id","orgId","code","createdBy","createdAt"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/invite-codes/{code}":{"delete":{"tags":["invites"],"summary":"Revoke a JOIN code (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":8},"required":true,"name":"code","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"revoked":{"type":"string"}},"required":["revoked"]}}}},"404":{"description":"Unknown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/invite-codes/redeem":{"post":{"tags":["invites"],"summary":"Redeem a JOIN code for the signed-in principal (transactional; grant with the burn)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemBody"}}}},"responses":{"200":{"description":"Joined.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RedeemResponse"}}}},"400":{"description":"invite_code_invalid (unknown, revoked, expired) · invite_code_exhausted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups":{"get":{"tags":["groups"],"summary":"Groups of the organization with their members","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Groups.","content":{"application/json":{"schema":{"type":"object","properties":{"groups":{"type":"array","items":{"$ref":"#/components/schemas/GroupWithMembers"}}},"required":["groups"]}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["groups"],"summary":"Create a group (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateGroupBody"}}}},"responses":{"200":{"description":"Preview.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","minLength":1,"maxLength":128},"resources":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1,"maxLength":128},"sharedBy":{"type":"string","minLength":1,"maxLength":128},"sharedAt":{"type":"string","format":"date-time"}},"required":["kind","id"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0}},"required":["id","orgId","slug","name","createdAt"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups/{groupId}":{"patch":{"tags":["groups"],"summary":"Rename / re-parent a group (org_admin or group_admin of it; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchGroupBody"}}}},"responses":{"200":{"description":"Preview or updated group.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","minLength":1,"maxLength":128},"resources":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1,"maxLength":128},"sharedBy":{"type":"string","minLength":1,"maxLength":128},"sharedAt":{"type":"string","format":"date-time"}},"required":["kind","id"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0}},"required":["id","orgId","slug","name","createdAt"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["groups"],"summary":"Delete a group and its memberships (org_admin; `?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"applied":{"type":"object","additionalProperties":{"nullable":true}}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Rooms are bound to this group (ADR-0035).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups/{groupId}/members":{"post":{"tags":["groups"],"summary":"Add a member to a group (org_admin or group_admin of it; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddGroupMemberBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"principalId":{"type":"string","minLength":1,"maxLength":128},"groupId":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"role":{"type":"string","enum":["group_admin","member"],"default":"member"},"addedBy":{"type":"string","minLength":1,"maxLength":128},"addedAt":{"type":"string","format":"date-time"},"temporaryUntil":{"type":"string","format":"date-time"}},"required":["principalId","groupId","orgId","addedAt"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group or not an org member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups/{groupId}/members/{principalId}":{"delete":{"tags":["groups"],"summary":"Remove a member from a group (org_admin or group_admin of it)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"The group with its remaining members.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GroupWithMembers"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups/{groupId}/resources":{"post":{"tags":["groups"],"summary":"Share a resource (connector) with a group (org_admin or group_admin of it; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ShareResourceBody"}}}},"responses":{"200":{"description":"Preview or the group with its resources.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","minLength":1,"maxLength":128},"resources":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1,"maxLength":128},"sharedBy":{"type":"string","minLength":1,"maxLength":128},"sharedAt":{"type":"string","format":"date-time"}},"required":["kind","id"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0}},"required":["id","orgId","slug","name","createdAt"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group or resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/groups/{groupId}/resources/{kind}/{id}":{"delete":{"tags":["groups"],"summary":"Stop sharing a resource with a group (`?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"groupId","in":"path"},{"schema":{"type":"string","enum":["connector"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or the group with its remaining resources.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"slug":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"parentGroupId":{"type":"string","minLength":1,"maxLength":128},"resources":{"type":"array","items":{"type":"object","properties":{"kind":{"type":"string","enum":["connector"]},"id":{"type":"string","minLength":1,"maxLength":128},"sharedBy":{"type":"string","minLength":1,"maxLength":128},"sharedAt":{"type":"string","format":"date-time"}},"required":["kind","id"]},"default":[]},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"schemaVersion":{"type":"integer","minimum":0}},"required":["id","orgId","slug","name","createdAt"]}]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown group.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/tokens":{"get":{"tags":["tokens"],"summary":"Tokens pinned to the organization (bounded at 200; own tokens unless org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Tokens.","content":{"application/json":{"schema":{"type":"object","properties":{"tokens":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-f]{64}$"},"prefix":{"type":"string","minLength":11,"maxLength":11},"principalId":{"type":"string","minLength":1,"maxLength":128},"orgIdOverride":{"type":"string","minLength":1,"maxLength":128},"channel":{"type":"string","maxLength":32},"allowedTools":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"default":["read"]},"expiresAt":{"type":"string","format":"date-time"},"revokedAt":{"type":"string","format":"date-time"},"lastUsedAt":{"type":"string","format":"date-time"},"usageCount":{"type":"integer","minimum":0,"default":0},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":120},"clientId":{"type":"string","maxLength":1024},"grantId":{"type":"string","maxLength":64},"audience":{"type":"string","maxLength":1024}},"required":["id","prefix","principalId","createdAt"]}},"cap":{"type":"number"}},"required":["tokens","cap"]}}}},"403":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["tokens"],"summary":"Mint a wz_ token pinned to the organization (shown once)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTokenBody"}}}},"responses":{"201":{"description":"Created — the raw token appears only in this response.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatedToken"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/tokens/{tokenId}":{"delete":{"tags":["tokens"],"summary":"Revoke one token by its id (sha256). Owner, org_admin of the pinned org, or super_admin.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^[0-9a-f]{64}$"},"required":true,"name":"tokenId","in":"path"}],"responses":{"200":{"description":"Revoked.","content":{"application/json":{"schema":{"type":"object","properties":{"revoked":{"type":"string"}},"required":["revoked"]}}}},"403":{"description":"Not the owner.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown token.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/policy":{"get":{"tags":["policy"],"summary":"The live access policy of an organization","description":"Admins see the policy and whether they may edit it; editing is super_admin only unless `orgAdminCanEdit`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The policy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPolicyResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}},"put":{"tags":["policy"],"summary":"Replace the policy (two-step)","description":"`confirm:false` returns a preview with the diff; `confirm:true` saves a new version. New or changed row rules need `canary.row_level` (ADR-0041) and must parse; every group a rule names must be in `groups`; `orgAdminCanEdit` is super_admin only.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutPolicyBody"}}}},"responses":{"200":{"description":"Preview or the saved policy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutPolicyResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/compile":{"post":{"tags":["policy"],"summary":"Compile an admin sentence into an enforceable proposal","description":"One model call at authoring time; nothing is saved. The proposal carries a ready `rule` for PUT and flags names the catalogue does not know.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompileBody"}}}},"responses":{"200":{"description":"The proposal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompileResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/simulate/{principalId}":{"get":{"tags":["policy"],"summary":"The effective policy of one principal (or room)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"Resolved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulateResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}},"post":{"tags":["policy"],"summary":"Would this question be allowed for that principal? (mechanical gate, no model call)","description":"Resolves the effective policy and runs the gate over the words of the question: a denied topic keyword, table or column name yields a deny Decision with the rule that bound it.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimulateBody"}}}},"responses":{"200":{"description":"The decision.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Decision"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/denials":{"get":{"tags":["policy"],"summary":"Recent denials (newest first)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":500},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1},"required":false,"name":"principalId","in":"query"}],"responses":{"200":{"description":"Denials.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DenialsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/versions":{"get":{"tags":["policy"],"summary":"Saved versions of the policy","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Versions, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VersionsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/restore":{"post":{"tags":["policy"],"summary":"Restore a saved version as a new version (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RestoreBody"}}}},"responses":{"200":{"description":"Preview or the saved policy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutPolicyResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/warnings":{"get":{"tags":["policy"],"summary":"What may surprise someone: empty groups the rules name, ending temporary grants","description":"An `all except [G]` rule over an empty G binds everyone (`exempt_group_empty`); a rule scoped to empty groups binds no one (`scoped_groups_empty`); temporary grants ending within 7 days (`grant_expiring`).","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Warnings (empty = nothing to fix).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyWarningsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/view-as/{principalId}":{"get":{"tags":["policy"],"summary":"View as: exactly what one member or room may use (admin; canary.view_as)","description":"Resolved as a turn would resolve it: the access profile (sources, tables, hidden columns, row filters bound to their attributes, topics) and the tools the agent would declare to them. Reads only.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"The view.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ViewAsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/view-as/{principalId}/query":{"post":{"tags":["policy"],"summary":"View as: would this query run for them, and as what SQL (nothing is executed)","description":"The same gates a turn applies (the coarse scan, then the AST gate with their row filters). The admin sees the verdict and the rewritten statement, never their rows.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ViewAsQueryBody"}}}},"responses":{"200":{"description":"The verdict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ViewAsQueryResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/proposals":{"get":{"tags":["policy"],"summary":"Proposed rules, newest first (inert until an admin applies one)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["pending","applied","dismissed"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"Proposals.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProposalsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/proposals/{proposalId}/apply":{"post":{"tags":["policy"],"summary":"Apply a proposed rule (two-step; a new policy version)","description":"`confirm:false` previews the rule added to the policy (validated exactly as the save) with `currentVersion`; `confirm:true` with that `version` saves a new version and marks the proposal applied (a policy that moved since is 409 `version_conflict`). A proposal is applied once.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"proposalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplyBody"}}}},"responses":{"200":{"description":"Preview or the applied proposal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApplyProposalResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/policy/proposals/{proposalId}/dismiss":{"post":{"tags":["policy"],"summary":"Dismiss a proposed rule (nothing changes in the policy)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"proposalId","in":"path"}],"responses":{"200":{"description":"The dismissed proposal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DismissProposalResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PolicyError"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/attributes":{"get":{"tags":["attributes"],"summary":"A member's attributes (ADR-0041): values, source, freshness","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"Attributes.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberAttributes"}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/attributes/{key}":{"put":{"tags":["attributes"],"summary":"Set or clear a manual attribute value (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_]{0,63}$"},"required":true,"name":"key","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAttributeBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AttributesPreview"},{"$ref":"#/components/schemas/AttributesApplied"}]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/attribute-sources":{"get":{"tags":["attributes"],"summary":"Where the org's member attributes come from (IdP claims, connector lookups)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Sources.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AttributeSourcesResponse"}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["attributes"],"summary":"Change the IdP claim mappings and connector lookups (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAttributeSourcesBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AttributesPreview"},{"$ref":"#/components/schemas/AttributesApplied"}]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/attribute-sources/refresh":{"post":{"tags":["attributes"],"summary":"Run the connector lookups now (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefreshAttributesBody"}}}},"responses":{"200":{"description":"Preview or the refresh report.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/AttributesPreview"},{"$ref":"#/components/schemas/AttributesApplied"}]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/rooms":{"get":{"tags":["policy"],"summary":"Rooms of the organization and the permission group each one reads as","description":"ADR-0035: a room = a permission group. A bound room reads exactly as its group; an unbound room fails closed to its own memberships (the strictest reading), never to the speaker.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Rooms.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}}}}},"/api/orgs/{orgId}/rooms/{room}/permission-group":{"put":{"tags":["policy"],"summary":"Bind a room to a permission group, or unbind it (two-step, versioned)","description":"`confirm:false` returns the preview; `confirm:true` saves a new policy version. `groupId: null` unbinds: the room falls back to its own memberships at the strictest reading.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"room","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutRoomGroupBody"}}}},"responses":{"200":{"description":"Preview or the saved binding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutRoomGroupResponse"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomsError"}}}}}}},"/api/orgs/{orgId}/rooms/{room}/whatsapp":{"get":{"tags":["rooms"],"summary":"The room's WhatsApp group as WhatsApp holds it, against the WizBI standard","description":"ADR-0101: join approval, who may add, lock, participants and admins, the invite link (never reset by a read), and what differs from the standard. Org admins of the org the room answers as; read only — nothing reaches the group.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"room","in":"path"}],"responses":{"200":{"description":"The state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppState"}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"404":{"description":"No such room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"409":{"description":"Paced, paused, or the group does not allow it now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"502":{"description":"WhatsApp refused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}}}}},"/api/orgs/{orgId}/rooms/{room}/whatsapp/actions":{"post":{"tags":["rooms"],"summary":"One admin action on the room’s WhatsApp group (two-step, paced); never adds a person","description":"ADR-0101: join_approval_on · admin_add_only · lock · reset_link · promote / demote an org person already in the group. `confirm:false` previews; `confirm:true` acts, at most one action a minute and ten an hour per number; a 403/429 from WhatsApp pauses the number for six hours.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"room","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppAction"}}}},"responses":{"200":{"description":"Preview or done.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["join_approval_on","admin_add_only","lock","reset_link","promote","demote","approve_request","reject_request"]},"from":{"nullable":true},"to":{"nullable":true},"person":{"type":"object","properties":{"principalId":{"type":"string"},"name":{"type":"string"}},"required":["principalId","name"]}},"required":["action"]},"done":{"type":"string","enum":["join_approval_on","admin_add_only","lock","reset_link","promote","demote","approve_request","reject_request"]},"inviteLink":{"type":"string","nullable":true},"state":{"$ref":"#/components/schemas/RoomWhatsAppState"}}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"404":{"description":"No such room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"409":{"description":"Paced, paused, or the group does not allow it now.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}},"502":{"description":"WhatsApp refused.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RoomWhatsAppError"}}}}}}},"/api/admin/whatsapp/groups":{"get":{"tags":["admin"],"summary":"Every WhatsApp group of every WizBI number, against the standard (super_admin, read only)","responses":{"200":{"description":"The groups.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminWhatsAppGroups"}}}}}}},"/api/orgs/{orgId}/whatsapp/groups":{"get":{"tags":["rooms"],"summary":"The organization's WhatsApp groups against the standard, with pending requests (org_admin)","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The groups.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgWhatsAppGroups"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgWhatsAppGroupsError"}}}},"403":{"description":"Not an admin of this org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgWhatsAppGroupsError"}}}}}}},"/api/orgs/{orgId}/knowledge":{"get":{"tags":["knowledge"],"summary":"Knowledge items of the organization (admins: shared knowledge; everyone: own memory)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"scopeRef","in":"query"},{"schema":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","enum":["core","source","learned","task"]},"required":false,"name":"layer","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"source","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":2000},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Items.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeItem"}}},"required":["items"]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["knowledge"],"summary":"Create a knowledge item (org_admin; two-step; lints on preview and write)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}":{"get":{"tags":["knowledge"],"summary":"One knowledge item","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeItem"}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["knowledge"],"summary":"Update a knowledge item as a new version (org_admin; two-step; stale version = 409)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}/versions":{"get":{"tags":["knowledge"],"summary":"Versions of a knowledge item, newest first (immutable)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Versions.","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeVersion"}}},"required":["versions"]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}/diff":{"get":{"tags":["knowledge"],"summary":"Line diff and changed fields between two versions","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":true,"name":"from","in":"query"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":true,"name":"to","in":"query"}],"responses":{"200":{"description":"The diff.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeDiff"}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}/transition":{"post":{"tags":["knowledge"],"summary":"Change the status (approve, activate, retire, reject, reopen) under the approval matrix","description":"Two-step. A member may only retire (forget) or reject their OWN user-scope items; everything else follows the policy of the store: the approval matrix of ADR-0037, or — when the org is governed automatically (ADR-0039) — org / source knowledge is activated by the governor only (`governed_scope`; a super_admin override remains). `knowledge_transition_denied` names the reason.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeTransitionBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}/restore":{"post":{"tags":["knowledge"],"summary":"Restore a historical version as a NEW version (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RestoreKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/knowledge/{id}/governance":{"post":{"tags":["knowledge"],"summary":"Pin or block one item (ADR-0039 kill switches; two-step)","description":"`pinned` (super_admin): the automatic governor never touches the item. `blocked` (org_admin or super_admin): nobody activates it; blocking a live item retires it in the same write. A reason is required; the write is a `governed` knowledge event. Personal (user-scope) items: super_admin only.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeGovernanceBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge":{"get":{"tags":["knowledge"],"summary":"Platform and source-type knowledge (super_admin)","parameters":[{"schema":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"scopeRef","in":"query"},{"schema":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","enum":["core","source","learned","task"]},"required":false,"name":"layer","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":256},"required":false,"name":"source","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":2000},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Items.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeItem"}}},"required":["items"]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["knowledge"],"summary":"Create a platform / source-type knowledge item (super_admin; two-step)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreatePlatformKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge/{id}":{"get":{"tags":["knowledge"],"summary":"One platform knowledge item (super_admin)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeItem"}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["knowledge"],"summary":"Update a platform knowledge item (super_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge/{id}/versions":{"get":{"tags":["knowledge"],"summary":"Versions of a platform knowledge item (super_admin)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Versions.","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeVersion"}}},"required":["versions"]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge/{id}/diff":{"get":{"tags":["knowledge"],"summary":"Diff two versions of a platform knowledge item (super_admin)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":true,"name":"from","in":"query"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":true,"name":"to","in":"query"}],"responses":{"200":{"description":"The diff.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeDiff"}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge/{id}/transition":{"post":{"tags":["knowledge"],"summary":"Change the status of a platform knowledge item (super_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeTransitionBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/knowledge/{id}/restore":{"post":{"tags":["knowledge"],"summary":"Restore a platform knowledge version as a NEW version (super_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RestoreKnowledgeBody"}}}},"responses":{"200":{"description":"Preview or the item.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/KnowledgePreview"},{"$ref":"#/components/schemas/KnowledgeWriteResult"}]}}}},"400":{"description":"Invalid request or a failed lint (`knowledge_lint_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, the transition is denied, or the feature is off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item or version (or one the caller may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/candidates":{"get":{"tags":["learning"],"summary":"Learning candidates of the organization (harvested or imported; org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["candidate","approved","active","retired","rejected"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["skill","fact","preference","alias","recipe","rule","gap"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","enum":["platform","source_type","org","source","group","room","user"]},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","enum":["harvest","import","all"]},"required":false,"name":"origin","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":2000},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Candidates.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/LearningCandidate"}}},"required":["items"]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/candidates/review":{"post":{"tags":["learning"],"summary":"Approve, activate or reject candidates in bulk (two-step; the approval matrix)","description":"Each id goes through `KnowledgeStore.transition` under the ADR-0037 matrix; the preview names, per id, whether it is allowed and why not. `reject` needs a reason.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LearningReviewBody"}}}},"responses":{"200":{"description":"Preview or results.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LearningPreview"},{"$ref":"#/components/schemas/LearningReviewResult"}]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/issues":{"get":{"tags":["learning"],"summary":"Learning issues of the organization, newest first (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["open","ack","resolved"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["tool_failed","refused","no_answer","slow","huge_context","discovery_loop","turn_error","user_reported","conflict","regression","contradicted","revalidation_due"]},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","enum":["real","scheduled","internal"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"since","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":2000},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Issues.","content":{"application/json":{"schema":{"type":"object","properties":{"issues":{"type":"array","items":{"$ref":"#/components/schemas/LearningIssue"}}},"required":["issues"]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/issues/{id}/status":{"post":{"tags":["learning"],"summary":"Acknowledge, resolve or reopen an issue (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LearningIssueStatusBody"}}}},"responses":{"200":{"description":"Preview or the issue.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LearningPreview"},{"type":"object","properties":{"issue":{"$ref":"#/components/schemas/LearningIssue"}},"required":["issue"]}]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/config":{"get":{"tags":["learning"],"summary":"Who counts as an internal tester (never counted, never harvested)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The config.","content":{"application/json":{"schema":{"type":"object","properties":{"config":{"$ref":"#/components/schemas/LearningConfig"}},"required":["config"]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["learning"],"summary":"Set the internal testers and markers (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LearningConfigBody"}}}},"responses":{"200":{"description":"Preview or the config.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/LearningPreview"},{"type":"object","properties":{"config":{"$ref":"#/components/schemas/LearningConfig"}},"required":["config"]}]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/learning/governance":{"get":{"tags":["learning"],"summary":"What the automatic governance decided, and why (ADR-0039; org_admin)","description":"The run records of `knowledge.govern` and `knowledge.watch`, newest day first: every item looked at, the decision, the reason, the evidence ids and the eval ref. Decisions about personal memory are counted, not listed (super_admin sees them).","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":200},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Runs.","content":{"application/json":{"schema":{"type":"object","properties":{"runs":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeGovernanceRun"}},"personal":{"type":"integer"}},"required":["runs","personal"]}}}},"400":{"description":"Invalid request (a wrong status edge, too many ids).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown issue.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/reports":{"get":{"tags":["reports"],"summary":"Scheduled reports and alerts — mine, or every one of the organization (admins)","description":"Each item: when it runs (in words), the next run, the last message, the last runs (sent / quiet / held / error) with credits, where it is delivered, and whether it is a report, an alert (deliver only when notable) or a one-time follow-up. Money is shown to a super_admin only.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["mine","org"],"default":"mine","description":"mine = items I own; org = every item of the organization (org admins only)."},"required":false,"description":"mine = items I own; org = every item of the organization (org admins only).","name":"scope","in":"query"}],"responses":{"200":{"description":"The items.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}},"post":{"tags":["reports"],"summary":"Schedule a report or an alert (two-step)","description":"The request is the person's own words; at each run the ONE brain runs it as its owner, read-only. `deliver_when: notable` makes it an alert. A recurring item first runs at its NEXT slot. Per-person caps, the per-chat hourly budget and duplicate detection are the chat tool's.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateReportBody"}}}},"responses":{"200":{"description":"Preview, or the created item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/destinations":{"get":{"tags":["reports"],"summary":"Where the caller may have a report or an alert delivered","description":"The caller's own private chats with a bot, and the chats their reports already deliver to (an org admin: every chat a report of the org delivers to). A group no report uses yet is set up by asking in that group.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The destinations.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/schedule-preview":{"post":{"tags":["reports"],"summary":"Preview a timing: the sentence and the next five runs","description":"Stores nothing. Times are in the caller's zone unless `timezone` is given.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportSchedulePreviewBody"}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/{id}":{"get":{"tags":["reports"],"summary":"One scheduled report or alert, with its run history","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"}],"responses":{"200":{"description":"The item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}},"patch":{"tags":["reports"],"summary":"Change a scheduled report or alert in place (two-step)","description":"Pass only what changes. An edit never triggers an extra run; the next slot moves only when the timing changed. \"Updated\" is said only about what was read back as stored.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateReportBody"}}}},"responses":{"200":{"description":"Preview, or the saved change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}},"delete":{"tags":["reports"],"summary":"Cancel a scheduled report or alert (two-step; the record is kept)","description":"To stop it for a while, pause it instead.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"],"default":"false","description":"false (default) = preview; true = cancel the item."},"required":false,"description":"false (default) = preview; true = cancel the item.","name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview, or cancelled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/{id}/runs":{"get":{"tags":["reports"],"summary":"Run history of a report: when, why, the outcome and the credits","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"The runs, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/{id}/pause":{"post":{"tags":["reports"],"summary":"Pause a scheduled report or alert (kept, will not run; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportConfirmBody"}}}},"responses":{"200":{"description":"Preview, or the saved change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/{id}/resume":{"post":{"tags":["reports"],"summary":"Resume a paused report or alert (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportConfirmBody"}}}},"responses":{"200":{"description":"Preview, or the saved change.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/{id}/run":{"post":{"tags":["reports"],"summary":"Run a report now, once, off-schedule (two-step: it is a real delivery)","description":"Delivered to its usual chat within a minute or two; the schedule is unchanged and a slot due in the same minutes does not run it twice.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The report id."},"required":true,"description":"The report id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportConfirmBody"}}}},"responses":{"200":{"description":"Preview, or queued.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/reports/timezone":{"put":{"tags":["reports"],"summary":"Set the time zone the caller's times mean (or the organization's, admins; two-step)","description":"Existing schedules keep their own zone.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportTimezoneBody"}}}},"responses":{"200":{"description":"Preview, or saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportsError"}}}}}}},"/api/orgs/{orgId}/alerts":{"get":{"tags":["reports"],"summary":"Alerts — mine, or every one of the organization (admins); raised first","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["mine","org"],"default":"mine"},"required":false,"name":"scope","in":"query"}],"responses":{"200":{"description":"The alerts.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}},"post":{"tags":["reports"],"summary":"Create an alert (two-step; the preview runs the source once on live data)","description":"A connector tool + a closed condition + a timing + a send policy. The preview shows the current value and whether the engine would raise now; nothing is stored until confirm.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAlertBody"}}}},"responses":{"200":{"description":"Preview, or the created alert.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}":{"get":{"tags":["reports"],"summary":"One alert: its rule, where its episode stands, and its log","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"events","in":"query"}],"responses":{"200":{"description":"The alert.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}},"patch":{"tags":["reports"],"summary":"Change an alert in place (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateAlertBody"}}}},"responses":{"200":{"description":"Preview, or the saved alert.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}},"delete":{"tags":["reports"],"summary":"Delete an alert (two-step; the record is kept)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"],"default":"false"},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview, or deleted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/test":{"post":{"tags":["reports"],"summary":"Run the source now and show what the engine decides (stores and sends nothing)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"responses":{"200":{"description":"The evaluation.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/ack":{"post":{"tags":["reports"],"summary":"Acknowledge the raised alert: no more reminders for this episode (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertConfirmBody"}}}},"responses":{"200":{"description":"Preview, or done.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/unshelve":{"post":{"tags":["reports"],"summary":"Unmute an alert (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertConfirmBody"}}}},"responses":{"200":{"description":"Preview, or done.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/pause":{"post":{"tags":["reports"],"summary":"Pause an alert: no checks until resumed (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertConfirmBody"}}}},"responses":{"200":{"description":"Preview, or done.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/resume":{"post":{"tags":["reports"],"summary":"Resume a paused alert (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertConfirmBody"}}}},"responses":{"200":{"description":"Preview, or done.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/alerts/{id}/shelve":{"post":{"tags":["reports"],"summary":"Mute an alert for N hours: still checked and logged, nothing sent (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128,"description":"The alert id."},"required":true,"description":"The alert id.","name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertShelveBody"}}}},"responses":{"200":{"description":"Preview, or shelved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertAnswer"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AlertsError"}}}}}}},"/api/orgs/{orgId}/chat":{"post":{"tags":["chat"],"summary":"Run one turn on the web channel (SSE)","description":"Streams the turn runner events as Server-Sent Events: text, tool_call, tool_result, media, escalated, done. Same pipeline as every other channel.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatBody"}}}},"responses":{"200":{"description":"SSE stream of turn events.","content":{"text/event-stream":{"schema":{"type":"string"}}}},"400":{"description":"An attachment URI outside the org’s uploads.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Context is for another org, or the thread is another person’s.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/chat/threads":{"get":{"tags":["chat"],"summary":"List the caller’s threads in this org","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Threads, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"threads":{"type":"array","items":{"$ref":"#/components/schemas/ChatThread"}}},"required":["threads"]}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Context is for another org.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/chat/threads/{id}":{"get":{"tags":["chat"],"summary":"One thread with its turns and summary","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The thread.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatThreadDetail"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Not the caller’s thread.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"404":{"description":"No such thread in this org.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/chat/uploads":{"post":{"tags":["chat"],"summary":"Upload a file for the next turn (multipart; field \"file\")","description":"Stores the file under the org in the uploads bucket and returns an attachment reference. Attach it to a turn as `attachments[].uri`. 25 MB max.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary"}},"required":["file"]}}}},"responses":{"200":{"description":"Stored.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadedAttachment"}}}},"400":{"description":"No file.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Context is for another org.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"413":{"description":"Too large.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"503":{"description":"Uploads not configured.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/activity/mcp":{"get":{"tags":["activity"],"summary":"AI-client (MCP) calls in this org: who, which client, what kind of step (org admins)","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"tool","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"onlyFailed","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Calls, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpToolCalls"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/activity":{"get":{"tags":["activity"],"summary":"Turns, denials or audit entries for this org","description":"Reads wizbi.agent_turn.v1 rows (kind=turns), policy denials (kind=denials) or admin audit entries (kind=audit). Members see their own rows; org admins see everyone’s. Audit is admin-only.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["turns","denials","audit"],"default":"turns"},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":1024},"required":false,"name":"conversation","in":"query"},{"schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"},"required":false,"name":"connectorId","in":"query"}],"responses":{"200":{"description":"Rows, newest first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/usage":{"get":{"tags":["activity"],"summary":"Usage per day for this org","description":"usage_daily rows (turns, tokens, credits, tool calls, denials) per principal and channel, with totals. Counts only — money is never returned. The org admins only (org_admin, super_admin); tokens for a super_admin only.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["day"],"default":"day"},"required":false,"name":"granularity","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"}],"responses":{"200":{"description":"Daily usage.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Usage"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/credits":{"get":{"tags":["activity"],"summary":"Credits used by this org in a month","description":"The monthly counter the usage ledger keeps (`usage_monthly`). Credits and turn counts only; money is never returned. The org admins only (org_admin, super_admin).","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}$"},"required":false,"name":"month","in":"query"}],"responses":{"200":{"description":"Credits.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Credits"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/usage/breakdown":{"get":{"tags":["activity"],"summary":"Messages or credits per day, by channel, person, group or data source","description":"One series per key (top N, the rest as `_other`). A member sees only their own messages; an org admin sees the organization. Counts and credits only — never money.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["channel","person","group","source"],"default":"channel","description":"channel · person (who spoke) · group (the groups of who spoke) · source (data sources the message read)"},"required":false,"description":"channel · person (who spoke) · group (the groups of who spoke) · source (data sources the message read)","name":"by","in":"query"},{"schema":{"type":"string","enum":["messages","credits"],"default":"messages","description":"messages (one per question) or credits (what the usage ledger charged)"},"required":false,"description":"messages (one per question) or credits (what the usage ledger charged)","name":"metric","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"First day, YYYY-MM-DD (UTC)."},"required":false,"description":"First day, YYYY-MM-DD (UTC).","name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"Last day, YYYY-MM-DD (UTC)."},"required":false,"description":"Last day, YYYY-MM-DD (UTC).","name":"to","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":20,"default":8},"required":false,"name":"top","in":"query"},{"schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$","description":"Only messages that read this data source (a connector id)."},"required":false,"description":"Only messages that read this data source (a connector id).","name":"connectorId","in":"query"}],"responses":{"200":{"description":"The breakdown.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsageBreakdown"}}}},"400":{"description":"Bad range.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/usage/summary":{"get":{"tags":["activity"],"summary":"Messages, credits, active people and denials over a period (the org's days)","description":"The home's four numbers for today, the last 7 or the last 30 days (the org's local days). Counts and credits only — never money. The org admins only (org_admin, super_admin).","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["today","7d","30d"],"default":"today","description":"today (since local midnight in the org's time zone) · 7d · 30d (local days, today included)"},"required":false,"description":"today (since local midnight in the org's time zone) · 7d · 30d (local days, today included)","name":"range","in":"query"}],"responses":{"200":{"description":"The summary.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsageSummary"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error","traceId"]}}}}}}},"/api/orgs/{orgId}/credits/visibility":{"get":{"tags":["credits"],"summary":"Which credit components the platform turned on for this organization","description":"Switches only (all off by default). Always answered to an org admin, so the console knows what to render; the components themselves answer `feature_disabled` while off.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditVisibilitySwitches"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credits/summary":{"get":{"tags":["credits"],"summary":"Credit balance, plan, per-question caps and 31 days of history","description":"Credits only. Needs the `balance` component on for the organization (else 403 `feature_disabled`).","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditSummary"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credits/breakdown":{"get":{"tags":["credits"],"summary":"Credits and messages by channel, person, group, source, agent, report or line type","description":"Top 20 keys by credits, the rest summed as `_other`. Labels are names (a person’s display name, a group, a source, an agent, a report, a line type) — never a phone, an e-mail, a model or a cost. `by=line`: `questions` (the answered messages) and the daily lines `memory` (\"Conversation memory\") and `data_transfer` (\"Data transfer\"); a daily line counts 0 messages. Default range: this month so far (Israel time), at most 92 days. Needs the `breakdown` component.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["channel","person","group","source","agent","report","line","module"],"default":"channel"},"required":false,"name":"by","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD (Israel time)."},"required":false,"description":"YYYY-MM-DD (Israel time).","name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$","description":"YYYY-MM-DD (Israel time)."},"required":false,"description":"YYYY-MM-DD (Israel time).","name":"to","in":"query"},{"schema":{"type":"string","enum":["he","en","pt"],"default":"he","description":"The language of module names (`by=module`)."},"required":false,"description":"The language of module names (`by=module`).","name":"lang","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBreakdown"}}}},"400":{"description":"Bad range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credit-budgets":{"get":{"tags":["credits"],"summary":"Credit budgets, what each consumed this period, and the per-question caps","description":"Needs the `budgets` component.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBudgets"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["credits"],"summary":"Create or replace a credit budget","description":"A limit on what the org, a group, a member, a channel or an AI worker (agent) may consume per day or month. `warn` alerts; `cap` runs through the overage (default 20 %), then keeps basic chat alive and blocks heavy work until the period turns; `block` refuses further questions at the limit. Alerts at 70 / 80 / 90 / 100 % by default. The scope id must belong to the organization. Needs the `budgets` component. Audited `credits.budget.put`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBudgetPutBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBudgetPutResult"}}}},"400":{"description":"Invalid budget (a scope id that is not a channel name).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such budget, group or member in this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credit-budgets/{budgetId}":{"delete":{"tags":["credits"],"summary":"Remove a credit budget","description":"Needs the `budgets` component. Audited `credits.budget.delete`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":true,"name":"budgetId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBudgetDeleted"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such budget in this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credit-caps":{"put":{"tags":["credits"],"summary":"Set the organization’s own per-question credit caps","description":"`{soft, hard}` (soft warns the person, hard stops the question) or null for the defaults. The value is stored as the org’s; the caps in force are bounded by the ceiling the platform set (`effective`). Needs the `budgets` component. Audited `credits.caps.put`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditCapsPutBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditCapsPutResult"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credits/trend":{"get":{"tags":["credits"],"summary":"Credits per day this month and last month, and the month’s forecast","description":"Credits only (Israel days). The forecast projects the month at the recent daily rate (the mean of the last up to 7 complete days) against the allowance plus granted credits, and names the day they run out at that rate. Needs the `balance` component.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditTrend"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credits/alerts":{"get":{"tags":["credits"],"summary":"The organization’s credit alerts (in-app feed), newest first","description":"One row per alert, each sent once per period: the balance and every budget at 70 / 80 / 90 / 100 % (or the thresholds set), a budget past its limit, inside its overage, at its cap (basic chat only) or blocking, the per-question caps, a heavy question paused for approval and approved. Where each alert went (e-mails, the team room, WhatsApp). Credit quantities only. Needs the `alerts` component.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditAlertFeed"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/credit-controls":{"get":{"tags":["credits"],"summary":"Credit alert thresholds, the soft-cap action and where alerts go","description":"Needs the `budgets` component.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditControls"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["credits"],"summary":"Set the credit alert thresholds, the soft-cap action and where alerts go","description":"`alertThresholdsPct` (up to 5, default 70/80/90/100) · `questionSoftAction`: `warn` (a note) or `ask` (a heavy question pauses at the soft cap and the person approves the rest) · `alertChannels`: e-mail on/off and a team room (one of `rooms`). WhatsApp alerts are the platform’s switch, not the org’s. `expectedVersion` refuses a write over a newer one (409). Needs the `budgets` component. Audited `credits.controls.put`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditControlsInput"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditControls"}}}},"400":{"description":"A room that is not one of the org’s team rooms.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No resolved context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an org admin (`forbidden`), or the component is off (`feature_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The settings changed since they were read (`version_conflict`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/catalog/report":{"post":{"tags":["catalog"],"summary":"The weekly module report: SLO breaches, unused and unprobed modules","description":"super_admin only. The week ending now, from the catalog, the module counters, the warehouse (p95) and the health history. `send: true` also posts the text to the platform Slack channel (never a customer channel). Counts only — never money.","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"send":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"The report.","content":{"application/json":{"schema":{"type":"object","properties":{"report":{"type":"object","additionalProperties":{"nullable":true}},"text":{"type":"string"},"sent":{"type":"boolean"},"channel":{"type":"string"}},"required":["report","text","sent","channel"]}}}},"400":{"description":"Bad range.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"401":{"description":"No identity.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"404":{"description":"Unknown module.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}}}}},"/api/admin/catalog/{kind}/{id}/metrics":{"get":{"tags":["catalog"],"summary":"A module’s calls, errors, latency, instances and health (platform view)","description":"super_admin only. Every organization; instances carry their org. Optional `orgId` narrows to one org. Counts only — never money.","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"instance","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"orgId","in":"query"}],"responses":{"200":{"description":"Metrics.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModuleMetrics"}}}},"400":{"description":"Bad range.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"401":{"description":"No identity.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"404":{"description":"Unknown module.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}}}}},"/api/orgs/{orgId}/catalog/{kind}/{id}/metrics":{"get":{"tags":["catalog"],"summary":"A module’s calls, errors, latency, instances and health in this organization","description":"Organization admins (and super_admin acting in the org). Only this organization’s calls, instances and health checks. Money is never included, for anyone.","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":200},"required":false,"name":"instance","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"Metrics.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModuleMetrics"}}}},"400":{"description":"Bad range.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"401":{"description":"No identity.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}},"404":{"description":"Unknown module.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"traceId":{"type":"string"}},"required":["error"]}}}}}}},"/api/connectors/catalog":{"get":{"tags":["connectors"],"summary":"Every connector type the platform offers","responses":{"200":{"description":"The catalog.","content":{"application/json":{"schema":{"type":"object","properties":{"connectors":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"version":{"type":"string","minLength":1,"maxLength":32,"default":"0.1.0"},"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","maxLength":200},"category":{"type":"string","enum":["warehouse","database","erp","saas","api","mcp","file","public-data"]},"authSchema":{"type":"object","properties":{"kind":{"type":"string","enum":["none","basic","bearer","api_key","oauth2_client_credentials","oauth2_refresh_token","oauth2_code","service_account","custom"],"default":"custom"},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-zA-Z][a-zA-Z0-9_]{0,63}$"},"label":{"type":"string","minLength":1,"maxLength":120},"type":{"type":"string","enum":["text","password","url","number","boolean","select","json","textarea"],"default":"text"},"required":{"type":"boolean","default":false},"secret":{"type":"boolean","default":false},"platformOnly":{"type":"boolean"},"platformHeld":{"type":"boolean"},"placeholder":{"type":"string","maxLength":200},"help":{"type":"string","maxLength":120},"options":{"type":"array","items":{"type":"string"}},"default":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]},"whereToFind":{"type":"object","properties":{"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"url":{"type":"string","format":"uri"}},"required":["url"]},"helpText":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"labelText":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"optionsFrom":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"pattern":{"type":"string","maxLength":200}},"required":["key","label"]},"default":[]},"oauth":{"type":"object","properties":{"authorizeUrl":{"type":"string","format":"uri"},"tokenUrl":{"type":"string","format":"uri"},"scopes":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"maxItems":50,"default":[]},"authorizeParams":{"type":"object","additionalProperties":{"type":"string","maxLength":200}},"pkce":{"type":"boolean","default":true},"clientIdSecret":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_-]{0,99}$"},"clientSecretSecret":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_-]{0,99}$"}},"required":["authorizeUrl","tokenUrl","clientIdSecret"]}},"default":{"kind":"custom","fields":[]}},"capabilities":{"type":"object","properties":{"test":{"type":"boolean","default":true},"discover":{"type":"boolean","default":false},"sync":{"type":"boolean","default":false},"live":{"type":"boolean","default":false},"write":{"type":"boolean","default":false},"rowFilter":{"type":"string","enum":["sql","filter","none"],"default":"none"}},"default":{"test":true,"discover":false,"sync":false,"live":false,"write":false,"rowFilter":"none"}},"grade":{"type":"string","enum":["read","write_with_grant","act_with_confirm"],"default":"read"},"regions":{"type":"array","items":{"type":"string","minLength":1},"minItems":1,"default":["europe-west1"]},"docsUrl":{"type":"string","format":"uri"},"syncStrategies":{"type":"array","items":{"type":"string","enum":["full","cursor","diff","webhook","upload"]},"default":["full"]},"rateLimits":{"type":"object","properties":{"requestsPerMinute":{"type":"integer","minimum":0,"exclusiveMinimum":true},"concurrency":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxRowsPerSync":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxPagesPerTable":{"type":"integer","minimum":0,"exclusiveMinimum":true}}},"cost":{"type":"object","properties":{"perSyncUsd":{"type":"number","minimum":0},"perQueryUsd":{"type":"number","minimum":0},"notes":{"type":"string","maxLength":500}}},"tags":{"type":"array","items":{"type":"string","maxLength":40},"default":[]},"status":{"type":"string","enum":["ga","beta","experimental"],"default":"beta"},"hasSkill":{"type":"boolean"},"labels":{"type":"object","properties":{"name":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["name","summary"]},"remote":{"type":"boolean"},"egressRegion":{"type":"string","minLength":1,"maxLength":40},"card":{"type":"object","properties":{"logoUrl":{"type":"string"},"brandColor":{"type":"string"},"vendor":{"type":"string"},"tools":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"grade":{"type":"string","enum":["read","write_with_grant","act_with_confirm"]},"defaultEnabled":{"type":"boolean"},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"internal":{"type":"boolean"}},"required":["name","grade"]}},"resources":{"type":"object","properties":{"levels":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"parent":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"list":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"selectable":{"type":"boolean","default":true}},"required":["type","label","list"]},"minItems":1,"maxItems":6},"defaultSelection":{"type":"string","enum":["none","all","recommended"],"default":"none"},"newResources":{"type":"string","enum":["ask","include","ignore"],"default":"ask"},"maxSelected":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":5000}},"required":["levels"]},"scope":{"type":"object","properties":{"required":{"type":"boolean","default":false},"levels":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"minItems":1,"maxItems":6},"pathLevels":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"maxItems":6}}},"schedule":{"type":"object","properties":{"default":{"type":"string","pattern":"^(?:manual|hourly|daily(?:@(?:[01]\\d|2[0-3]):[0-5]\\d)?|every:(?:[5-9]|[1-9]\\d{1,3})m)$"},"presets":{"type":"array","items":{"type":"string","pattern":"^(?:manual|hourly|daily(?:@(?:[01]\\d|2[0-3]):[0-5]\\d)?|every:(?:[5-9]|[1-9]\\d{1,3})m)$"},"minItems":1,"maxItems":12},"minimumMinutes":{"type":"integer","minimum":5,"maximum":1440,"default":15},"quietHoursUtc":{"type":"array","items":{"anyOf":[{"type":"integer","minimum":0,"maximum":23},{"type":"integer","minimum":1,"maximum":24}]},"minItems":2,"maxItems":2}},"required":["default","presets"]},"network":{"type":"object","properties":{"hosts":{"type":"array","items":{"type":"string","minLength":1,"maxLength":253},"maxItems":50,"default":[]},"staticEgress":{"type":"boolean","default":false},"path":{"type":"string","enum":["direct","bridge"],"default":"direct"}}},"identity":{"type":"object","properties":{"recommended":{"type":"string","enum":["service_user","personal_temporary","none"],"default":"service_user"},"accepts":{"type":"array","items":{"type":"string","enum":["service_user","personal_temporary","none"]},"minItems":1,"default":["service_user"]},"note":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}}},"upstream":{"type":"object","properties":{"apiVersion":{"type":"string"},"sunsetAt":{"type":"string"},"changelog":{"type":"string"}}}}}},"required":["id","name","category","hasSkill"]}}},"required":["connectors"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors":{"get":{"tags":["connectors"],"summary":"Connectors of an org","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The list.","content":{"application/json":{"schema":{"type":"object","properties":{"connectors":{"type":"array","items":{"$ref":"#/components/schemas/Connector"}}},"required":["connectors"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}},"post":{"tags":["connectors"],"summary":"Create a connector (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorCreate"}}}},"responses":{"200":{"description":"Preview (confirm=false).","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]}}}},"201":{"description":"Created (confirm=true).","content":{"application/json":{"schema":{"type":"object","properties":{"connector":{"$ref":"#/components/schemas/Connector"}},"required":["connector"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}":{"patch":{"tags":["connectors"],"summary":"Update name, schedule, enabled or fields","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorPatch"}}}},"responses":{"200":{"description":"Updated.","content":{"application/json":{"schema":{"type":"object","properties":{"connector":{"$ref":"#/components/schemas/Connector"}},"required":["connector"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}},"delete":{"tags":["connectors"],"summary":"Delete a connector and its secrets (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Confirm"}}}},"responses":{"200":{"description":"Preview or deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}},"deleted":{"type":"boolean"}}}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/test":{"post":{"tags":["connectors"],"summary":"Test the connection now","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorTest"}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/discover":{"post":{"tags":["connectors"],"summary":"Discover the source schema now","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Schema.","content":{"application/json":{"schema":{"type":"object","properties":{"tables":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","maxLength":4000},"columns":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"type":{"type":"string","minLength":1,"default":"STRING"},"description":{"type":"string","maxLength":1024},"nullable":{"type":"boolean"},"primaryKey":{"type":"boolean"}},"required":["name"]},"default":[]},"rowCountEstimate":{"type":"integer","minimum":0},"cursorColumn":{"type":"string"},"kind":{"type":"string","enum":["table","view"]}},"required":["name"]},"default":[]},"discoveredAt":{"type":"string","format":"date-time"},"truncated":{"type":"boolean","default":false}},"required":["discoveredAt"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/sync":{"post":{"tags":["connectors"],"summary":"Enqueue a sync job (idempotent per minute)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorSync"}}}},"responses":{"202":{"description":"Queued.","content":{"application/json":{"schema":{"type":"object","properties":{"job":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"principalId":{"type":"string","minLength":1,"maxLength":128},"connectorId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["test","discover","sync"]},"mode":{"type":"string","enum":["full","incremental"],"default":"full"},"since":{"type":"string","format":"date-time"},"tables":{"type":"array","items":{"type":"string"}},"trigger":{"type":"string","enum":["manual","schedule","webhook","retry","upload"],"default":"manual"},"idempotencyKey":{"type":"string","minLength":1,"maxLength":256},"status":{"type":"string","enum":["queued","running","succeeded","partial","failed","dead"],"default":"queued"},"attempts":{"type":"integer","minimum":0,"default":0},"maxAttempts":{"type":"integer","minimum":0,"exclusiveMinimum":true,"default":3},"notBefore":{"type":"string","format":"date-time"},"leaseUntil":{"type":"string","format":"date-time"},"dispatchedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"},"results":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"rows":{"type":"integer","minimum":0,"default":0},"ok":{"type":"boolean"},"error":{"type":"string","maxLength":1000},"errorCode":{"type":"string","maxLength":64}},"required":["name","ok"]},"default":[]},"rowsTotal":{"type":"integer","minimum":0,"default":0},"durationMs":{"type":"integer","minimum":0},"error":{"type":"string","nullable":true,"maxLength":2000},"errorCode":{"type":"string","maxLength":64},"errorParams":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"traceId":{"type":"string"}},"required":["id","orgId","principalId","connectorId","kind","idempotencyKey","createdAt"]},"created":{"type":"boolean"}},"required":["job","created"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/status":{"get":{"tags":["connectors"],"summary":"Connector state, the last discovered schema and recent jobs","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Status.","content":{"application/json":{"schema":{"type":"object","properties":{"connector":{"$ref":"#/components/schemas/Connector"},"schema":{"type":"object","nullable":true,"properties":{"tables":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string","maxLength":4000},"columns":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"type":{"type":"string","minLength":1,"default":"STRING"},"description":{"type":"string","maxLength":1024},"nullable":{"type":"boolean"},"primaryKey":{"type":"boolean"}},"required":["name"]},"default":[]},"rowCountEstimate":{"type":"integer","minimum":0},"cursorColumn":{"type":"string"},"kind":{"type":"string","enum":["table","view"]}},"required":["name"]},"default":[]},"discoveredAt":{"type":"string","format":"date-time"},"truncated":{"type":"boolean","default":false}},"required":["discoveredAt"]},"jobs":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["connector","schema","jobs"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/connectors/tick":{"post":{"tags":["connectors"],"summary":"Scheduler tick: requeue, schedule, run queued jobs","description":"Called by Cloud Scheduler with an OIDC token. Unset authorizer = disabled (503).","responses":{"200":{"description":"Tick summary.","content":{"application/json":{"schema":{"type":"object","properties":{"requeued":{"type":"number"},"scheduled":{"type":"number"},"claimed":{"type":"number"},"succeeded":{"type":"number"},"failed":{"type":"number"}},"required":["requeued","scheduled","claimed","succeeded","failed"]}}}},"400":{"description":"Bad request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"429":{"description":"Rate limited upstream.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"501":{"description":"Optional dependency missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"502":{"description":"Upstream failure.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}},"504":{"description":"Upstream timeout.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorsError"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/runs":{"get":{"tags":["sources"],"summary":"A source's run history, newest first (rows, tables, duration, trigger, errors)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":40},"required":false,"name":"before","in":"query"}],"responses":{"200":{"description":"The runs.","content":{"application/json":{"schema":{"type":"object","properties":{"runs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"principalId":{"type":"string","minLength":1,"maxLength":128},"connectorId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["test","discover","sync"]},"mode":{"type":"string","enum":["full","incremental"],"default":"full"},"since":{"type":"string","format":"date-time"},"tables":{"type":"array","items":{"type":"string"}},"trigger":{"type":"string","enum":["manual","schedule","webhook","retry","upload"],"default":"manual"},"idempotencyKey":{"type":"string","minLength":1,"maxLength":256},"status":{"type":"string","enum":["queued","running","succeeded","partial","failed","dead"],"default":"queued"},"attempts":{"type":"integer","minimum":0,"default":0},"maxAttempts":{"type":"integer","minimum":0,"exclusiveMinimum":true,"default":3},"notBefore":{"type":"string","format":"date-time"},"leaseUntil":{"type":"string","format":"date-time"},"dispatchedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"},"results":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"rows":{"type":"integer","minimum":0,"default":0},"ok":{"type":"boolean"},"error":{"type":"string","maxLength":1000},"errorCode":{"type":"string","maxLength":64}},"required":["name","ok"]},"default":[]},"rowsTotal":{"type":"integer","minimum":0,"default":0},"durationMs":{"type":"integer","minimum":0},"error":{"type":"string","nullable":true,"maxLength":2000},"errorCode":{"type":"string","maxLength":64},"errorParams":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"traceId":{"type":"string"}},"required":["id","orgId","principalId","connectorId","kind","idempotencyKey","createdAt"]}},"summary":{"type":"object","properties":{"lastSuccessAt":{"type":"string","format":"date-time"},"lastFailureAt":{"type":"string","format":"date-time"},"failures":{"type":"integer","minimum":0},"avgDurationMs":{"type":"integer","minimum":0}},"required":["failures"]},"next":{"type":"string","format":"date-time"}},"required":["runs","summary"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/tables":{"get":{"tags":["sources"],"summary":"A source's tables: rows, last change, freshness, description and the org's note","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The tables.","content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["landing","in_place","none"]},"tables":{"type":"array","items":{"type":"object","properties":{"table":{"type":"string","minLength":1},"sourceName":{"type":"string"},"kind":{"type":"string"},"rows":{"type":"integer","minimum":0},"lastModifiedAt":{"type":"string","format":"date-time"},"freshness":{"type":"string","enum":["fresh","stale","empty","unknown"]},"description":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"enriched":{"type":"boolean","default":false}},"required":["table","freshness"]}},"available":{"type":"array","items":{"type":"string"},"default":[]},"selection":{"type":"array","nullable":true,"items":{"type":"string"}},"selectable":{"type":"boolean"},"freshness":{"type":"object","properties":{"source":{"type":"string","enum":["fresh","stale","empty","unknown"]},"stale":{"type":"integer","minimum":0},"empty":{"type":"integer","minimum":0},"expectedEveryMs":{"type":"integer","minimum":0,"exclusiveMinimum":true}},"required":["source","stale","empty"]},"hidden":{"type":"integer","minimum":0,"default":0},"reachable":{"type":"boolean","default":true}},"required":["kind","tables","selection","selectable","freshness"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/tables/{table}":{"get":{"tags":["sources"],"summary":"One table of a source: its full schema and up to 50 sample rows (permissions apply)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":1024},"required":true,"name":"table","in":"path"}],"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","properties":{"table":{"type":"string"},"columns":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"description":{"type":"string"},"roles":{"type":"array","items":{"type":"string","enum":["pk","date","amount","join","id"]},"default":[]},"joinsTo":{"type":"array","items":{"type":"string"}}},"required":["name","type"]}},"sampleColumns":{"type":"array","items":{"type":"string"},"default":[]},"rows":{"type":"array","items":{"type":"array","items":{"nullable":true}},"default":[]},"sampleError":{"type":"string"},"removedColumns":{"type":"array","items":{"type":"string"},"default":[]},"description":{"type":"string","nullable":true},"note":{"type":"string","nullable":true},"rowCount":{"type":"integer","minimum":0},"lastModifiedAt":{"type":"string","format":"date-time"},"freshness":{"type":"string","enum":["fresh","stale","empty","unknown"]}},"required":["table","columns","freshness"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/tables/{table}/note":{"put":{"tags":["sources"],"summary":"Set or clear the organization's note on a table (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":1024},"required":true,"name":"table","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","nullable":true,"maxLength":2000}},"required":["note"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"table":{"type":"string"},"note":{"type":"string","nullable":true}},"required":["table","note"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/enrich":{"post":{"tags":["sources"],"summary":"Describe a source's tables: column roles (key, date, amount, join) and, on request, a model description (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"llm":{"type":"boolean","default":false},"lang":{"type":"string","enum":["he","en","pt"],"default":"he"},"tables":{"type":"array","items":{"type":"string","minLength":1,"maxLength":1024},"maxItems":200}}}}}},"responses":{"200":{"description":"Enriched.","content":{"application/json":{"schema":{"type":"object","properties":{"tables":{"type":"integer"},"described":{"type":"integer"},"roles":{"type":"object","additionalProperties":{"type":"integer"}}},"required":["tables","described","roles"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/selection":{"put":{"tags":["sources"],"summary":"Choose which tables / items of a source to sync (null = everything; org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"tables":{"type":"array","nullable":true,"items":{"type":"string","minLength":1,"maxLength":1024},"maxItems":2000}},"required":["tables"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"selection":{"type":"array","nullable":true,"items":{"type":"string"}}},"required":["selection"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sources/settings":{"get":{"tags":["sources"],"summary":"What the sources module offers this organization (upload limits, data identity)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Settings.","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"upload":{"type":"object","properties":{"enabled":{"type":"boolean"},"maxBytes":{"type":"integer"},"maxRows":{"type":"integer"},"formats":{"type":"array","items":{"type":"string"}}},"required":["enabled","maxBytes","maxRows","formats"]},"dataIdentity":{"type":"string"}},"required":["enabled","upload"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sources/uploads/preview":{"post":{"tags":["sources"],"summary":"Read an uploaded CSV / Excel file and show what would land (nothing is stored)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fileName":{"type":"string","minLength":1,"maxLength":255},"contentBase64":{"type":"string","minLength":1,"maxLength":13981022}},"required":["fileName","contentBase64"]}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","properties":{"fileName":{"type":"string"},"format":{"type":"string","enum":["csv","xlsx"]},"bytes":{"type":"integer","minimum":0},"sha256":{"type":"string"},"sheets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"columns":{"type":"array","items":{"type":"string"}},"headers":{"type":"array","items":{"type":"string"}},"rowCount":{"type":"integer","minimum":0},"sample":{"type":"array","items":{"type":"array","items":{"nullable":true}}},"truncated":{"type":"boolean","default":false}},"required":["name","columns","headers","rowCount","sample"]}},"duplicateOf":{"type":"object","nullable":true,"properties":{"connectorId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string"},"uploadedAt":{"type":"string","format":"date-time"}},"required":["connectorId","name"]},"similarTo":{"type":"object","nullable":true,"properties":{"connectorId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string"}},"required":["connectorId","name"]}},"required":["fileName","format","bytes","sha256","sheets","duplicateOf","similarTo"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sources/uploads":{"post":{"tags":["sources"],"summary":"Load an uploaded file as a source (two-step: confirm=false previews; replaces = a new version)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"fileName":{"type":"string","minLength":1,"maxLength":255},"contentBase64":{"type":"string","minLength":1,"maxLength":13981022},"confirm":{"type":"boolean","default":false},"name":{"type":"string","minLength":1,"maxLength":120},"replaces":{"type":"string","minLength":1,"maxLength":128},"allowDuplicate":{"type":"boolean","default":false}},"required":["fileName","contentBase64"]}}}},"responses":{"200":{"description":"Preview (confirm=false).","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"fileName":{"type":"string"},"format":{"type":"string","enum":["csv","xlsx"]},"bytes":{"type":"integer","minimum":0},"sha256":{"type":"string"},"sheets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"columns":{"type":"array","items":{"type":"string"}},"headers":{"type":"array","items":{"type":"string"}},"rowCount":{"type":"integer","minimum":0},"sample":{"type":"array","items":{"type":"array","items":{"nullable":true}}},"truncated":{"type":"boolean","default":false}},"required":["name","columns","headers","rowCount","sample"]}},"duplicateOf":{"type":"object","nullable":true,"properties":{"connectorId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string"},"uploadedAt":{"type":"string","format":"date-time"}},"required":["connectorId","name"]},"similarTo":{"type":"object","nullable":true,"properties":{"connectorId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string"}},"required":["connectorId","name"]}},"required":["fileName","format","bytes","sha256","sheets","duplicateOf","similarTo"]}},"required":["preview"]}}}},"201":{"description":"Loaded (confirm=true).","content":{"application/json":{"schema":{"type":"object","properties":{"connector":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"type":{"type":"string"},"state":{"type":"string"}},"required":["id","name","type","state"]},"job":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"principalId":{"type":"string","minLength":1,"maxLength":128},"connectorId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["test","discover","sync"]},"mode":{"type":"string","enum":["full","incremental"],"default":"full"},"since":{"type":"string","format":"date-time"},"tables":{"type":"array","items":{"type":"string"}},"trigger":{"type":"string","enum":["manual","schedule","webhook","retry","upload"],"default":"manual"},"idempotencyKey":{"type":"string","minLength":1,"maxLength":256},"status":{"type":"string","enum":["queued","running","succeeded","partial","failed","dead"],"default":"queued"},"attempts":{"type":"integer","minimum":0,"default":0},"maxAttempts":{"type":"integer","minimum":0,"exclusiveMinimum":true,"default":3},"notBefore":{"type":"string","format":"date-time"},"leaseUntil":{"type":"string","format":"date-time"},"dispatchedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"},"results":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"rows":{"type":"integer","minimum":0,"default":0},"ok":{"type":"boolean"},"error":{"type":"string","maxLength":1000},"errorCode":{"type":"string","maxLength":64}},"required":["name","ok"]},"default":[]},"rowsTotal":{"type":"integer","minimum":0,"default":0},"durationMs":{"type":"integer","minimum":0},"error":{"type":"string","nullable":true,"maxLength":2000},"errorCode":{"type":"string","maxLength":64},"errorParams":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}},"traceId":{"type":"string"}},"required":["id","orgId","principalId","connectorId","kind","idempotencyKey","createdAt"]},"tables":{"type":"array","items":{"type":"string"}}},"required":["connector","job","tables"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sources/uploads/{id}":{"delete":{"tags":["sources"],"summary":"Remove an uploaded file source with its tables and notes (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"name":{"type":"string"},"tables":{"type":"array","items":{"type":"string"}}},"required":["name","tables"]},"deleted":{"type":"boolean"}}}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connections":{"get":{"tags":["connections"],"summary":"The organization's connections and what needs attention (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The connections, most urgent first.","content":{"application/json":{"schema":{"type":"object","properties":{"connections":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"needsAttention":{"type":"boolean"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]}},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]},"lastOkAt":{"type":"string","format":"date-time"},"statusSince":{"type":"string","format":"date-time"}},"required":["id","kind","moduleRef","name","status","needsAttention","issues"]}},"attention":{"type":"integer","minimum":0}},"required":["connections","attention"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connections/{connectionId}":{"get":{"tags":["connections"],"summary":"One connection (org_admin; the technical record for super_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":300},"required":true,"name":"connectionId","in":"path"}],"responses":{"200":{"description":"The connection.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"needsAttention":{"type":"boolean"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]}},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]},"lastOkAt":{"type":"string","format":"date-time"},"statusSince":{"type":"string","format":"date-time"},"record":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":300},"orgId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string","minLength":1,"maxLength":160},"instanceId":{"type":"string","minLength":1,"maxLength":256},"name":{"type":"string","maxLength":200},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"statusSince":{"type":"string","format":"date-time"},"declared":{"type":"string","maxLength":64},"lastOkAt":{"type":"string","format":"date-time"},"lastError":{"type":"object","properties":{"code":{"type":"string","maxLength":64},"at":{"type":"string","format":"date-time"},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["code"]},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]},"default":[]},"consecutiveFailures":{"type":"integer","minimum":0,"default":0},"pausedAt":{"type":"string","format":"date-time"},"pausedReason":{"type":"string","enum":["auto","admin"]},"auth":{"type":"object","properties":{"kind":{"type":"string","enum":["none","secret","oauth","platform_app"]},"expiresAt":{"type":"string","format":"date-time"},"refreshedAt":{"type":"string","format":"date-time"},"rotatedAt":{"type":"string","format":"date-time"},"reauthRequired":{"type":"boolean"},"refreshError":{"type":"string","maxLength":64}},"required":["kind"]},"observedAt":{"type":"string","format":"date-time"}},"required":["id","orgId","kind","moduleRef","instanceId","name","status","declared","auth","observedAt"]}},"required":["id","kind","moduleRef","name","status","needsAttention","issues","record"]},{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"needsAttention":{"type":"boolean"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]}},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]},"lastOkAt":{"type":"string","format":"date-time"},"statusSince":{"type":"string","format":"date-time"}},"required":["id","kind","moduleRef","name","status","needsAttention","issues"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connections/{connectionId}/reconnect":{"post":{"tags":["connections"],"summary":"Where to connect it again (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":300},"required":true,"name":"connectionId","in":"path"}],"responses":{"200":{"description":"The console page to continue on.","content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string"},"bySupport":{"type":"boolean"}},"required":["to","bySupport"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connections/{connectionId}/resume":{"post":{"tags":["connections"],"summary":"Resume a paused data source: its scheduled work runs again, one test now (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":300},"required":true,"name":"connectionId","in":"path"}],"responses":{"200":{"description":"The connection after resuming.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"needsAttention":{"type":"boolean"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]}},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]},"lastOkAt":{"type":"string","format":"date-time"},"statusSince":{"type":"string","format":"date-time"}},"required":["id","kind","moduleRef","name","status","needsAttention","issues"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connections/{connectionId}/rotate":{"post":{"tags":["connections"],"summary":"Replace a data source's secret: a new version under the same name, proven by the source's own test, else the previous one is restored (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":300},"required":true,"name":"connectionId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"field":{"type":"string","minLength":1,"maxLength":64},"value":{"type":"string","minLength":1,"maxLength":8192}},"required":["field","value"]}}}},"responses":{"200":{"description":"Rotated, or rolled back.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"rolledBack":{"type":"boolean"}},"required":["ok"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/connections":{"get":{"tags":["connections"],"summary":"Every organization's connections, as kept by the sweep (super_admin)","responses":{"200":{"description":"All kept connections.","content":{"application/json":{"schema":{"type":"object","properties":{"connections":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string"},"name":{"type":"string"},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"needsAttention":{"type":"boolean"},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]}},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]},"lastOkAt":{"type":"string","format":"date-time"},"statusSince":{"type":"string","format":"date-time"},"record":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":300},"orgId":{"type":"string","minLength":1,"maxLength":128},"kind":{"type":"string","enum":["connector","channel","tenant"]},"moduleRef":{"type":"string","minLength":1,"maxLength":160},"instanceId":{"type":"string","minLength":1,"maxLength":256},"name":{"type":"string","maxLength":200},"status":{"type":"string","enum":["ok","needs_reauth","paused","error","disabled"]},"statusSince":{"type":"string","format":"date-time"},"declared":{"type":"string","maxLength":64},"lastOkAt":{"type":"string","format":"date-time"},"lastError":{"type":"object","properties":{"code":{"type":"string","maxLength":64},"at":{"type":"string","format":"date-time"},"params":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"}]}}},"required":["code"]},"issues":{"type":"array","items":{"type":"object","properties":{"code":{"type":"string","enum":["reauth_required","token_expiring","token_refresh_failed","repeated_failures","auto_paused","admin_paused","last_attempt_failed","setup_unfinished","session_lost","app_removed","missing_secret","account_disconnected","channel_not_bound","domains_skipped","secret_rotation_due","declared_pending"]},"severity":{"type":"string","enum":["action","warn","info"]},"since":{"type":"string","format":"date-time"},"action":{"type":"string","enum":["reconnect","resume","open","contact_support"]}},"required":["code","severity"]},"default":[]},"consecutiveFailures":{"type":"integer","minimum":0,"default":0},"pausedAt":{"type":"string","format":"date-time"},"pausedReason":{"type":"string","enum":["auto","admin"]},"auth":{"type":"object","properties":{"kind":{"type":"string","enum":["none","secret","oauth","platform_app"]},"expiresAt":{"type":"string","format":"date-time"},"refreshedAt":{"type":"string","format":"date-time"},"rotatedAt":{"type":"string","format":"date-time"},"reauthRequired":{"type":"boolean"},"refreshError":{"type":"string","maxLength":64}},"required":["kind"]},"observedAt":{"type":"string","format":"date-time"}},"required":["id","orgId","kind","moduleRef","instanceId","name","status","declared","auth","observedAt"]}},"required":["id","kind","moduleRef","name","status","needsAttention","issues","record"]}}},"required":["connections"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/connections/sweep":{"post":{"tags":["connections"],"summary":"Run the connections sweep now, for every org or one (super_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":false,"name":"orgId","in":"query"}],"responses":{"200":{"description":"The run counts.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"type":"number"}}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/channels/catalog":{"get":{"tags":["channels"],"summary":"Channel catalog","description":"Every channel type with its declared capabilities, the secret roles a binding must reference, and the webhook path.","responses":{"200":{"description":"Catalog.","content":{"application/json":{"schema":{"type":"object","properties":{"channels":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["channels"]}}}}}}},"/api/orgs/{orgId}/channels":{"get":{"tags":["channels"],"summary":"List channel bindings","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Bindings.","content":{"application/json":{"schema":{"type":"object","properties":{"bindings":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["bindings"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"403":{"description":"Not this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}}}},"post":{"tags":["channels"],"summary":"Create a channel binding (two-step)","description":"`confirm:false` returns a preview of the binding as it would be stored; `confirm:true` stores it.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelBindingCreate"}}}},"responses":{"200":{"description":"Preview.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}},"catalog":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}}},"required":["preview","catalog"]}}}},"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"binding":{"type":"object","additionalProperties":{"nullable":true}}},"required":["binding"]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"409":{"description":"A binding for this external id already exists.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}}}}},"/api/orgs/{orgId}/channels/{id}":{"patch":{"tags":["channels"],"summary":"Update a channel binding (two-step)","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelBindingPatch"}}}},"responses":{"200":{"description":"Preview or updated.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}},"binding":{"type":"object","additionalProperties":{"nullable":true}}}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"404":{"description":"No such binding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"409":{"description":"The new external id is bound elsewhere, the rooms would lose a group, or the rooms changed meanwhile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}}}},"delete":{"tags":["channels"],"summary":"Delete a channel binding (two-step via ?confirm=true)","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["0","1","true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}},"deleted":{"type":"string"}}}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"404":{"description":"No such binding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}}}}},"/api/orgs/{orgId}/channels/{id}/test":{"post":{"tags":["channels"],"summary":"Test a channel binding (org_admin)","description":"Checks the binding against the catalog (every required secret role referenced) and runs the injected live probe when one exists. A channel that runs on WizBI's own app (catalog `credentials: 'platform'`, e.g. Teams) has no secrets of its own: its test probes the platform app and checks the organization's connection, answered as `checks`.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Result.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"missingSecrets":{"type":"array","items":{"type":"string"}},"presentSecrets":{"type":"array","items":{"type":"string"}},"probe":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"credentials":{"type":"string","enum":["platform","binding"]},"checks":{"type":"array","items":{"$ref":"#/components/schemas/ChannelPlatformCheck"}}},"required":["ok","missingSecrets","presentSecrets","probe"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}},"404":{"description":"No such binding.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelsError"}}}}}}},"/api/orgs/{orgId}/channels/{id}/rooms":{"post":{"tags":["channels"],"summary":"Add one room to a channel binding (two-step); every other room stays as it is","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomAdd"}}}},"responses":{"200":{"description":"Preview or done.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["add","update","remove"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"before":{"type":"object","additionalProperties":{"nullable":true}},"roomsBefore":{"type":"integer"},"roomsAfter":{"type":"integer"},"identity":{"type":"object","properties":{"room":{"type":"string"},"groupId":{"type":"string","nullable":true}},"required":["room","groupId"]}},"required":["action","room","roomsBefore","roomsAfter"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"identity":{"type":"object","additionalProperties":{"nullable":true}},"removed":{"type":"string"},"binding":{"type":"object","additionalProperties":{"nullable":true}}}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"404":{"description":"No such binding or room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"409":{"description":"The room already exists, or the rooms changed meanwhile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}}}}},"/api/orgs/{orgId}/channels/{id}/rooms/{roomId}":{"patch":{"tags":["channels"],"summary":"Edit one room of a channel binding (two-step); every other room stays as it is","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":true,"name":"roomId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomPatch"}}}},"responses":{"200":{"description":"Preview or done.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["add","update","remove"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"before":{"type":"object","additionalProperties":{"nullable":true}},"roomsBefore":{"type":"integer"},"roomsAfter":{"type":"integer"},"identity":{"type":"object","properties":{"room":{"type":"string"},"groupId":{"type":"string","nullable":true}},"required":["room","groupId"]}},"required":["action","room","roomsBefore","roomsAfter"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"identity":{"type":"object","additionalProperties":{"nullable":true}},"removed":{"type":"string"},"binding":{"type":"object","additionalProperties":{"nullable":true}}}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"404":{"description":"No such binding or room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"409":{"description":"The room already exists, or the rooms changed meanwhile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}}}},"delete":{"tags":["channels"],"summary":"Remove one room from a channel binding (two-step via ?confirm=true)","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string"},"required":true,"name":"roomId","in":"path"},{"schema":{"type":"string","enum":["0","1","true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview or done.","content":{"application/json":{"schema":{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["add","update","remove"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"before":{"type":"object","additionalProperties":{"nullable":true}},"roomsBefore":{"type":"integer"},"roomsAfter":{"type":"integer"},"identity":{"type":"object","properties":{"room":{"type":"string"},"groupId":{"type":"string","nullable":true}},"required":["room","groupId"]}},"required":["action","room","roomsBefore","roomsAfter"]},"room":{"type":"object","additionalProperties":{"nullable":true}},"identity":{"type":"object","additionalProperties":{"nullable":true}},"removed":{"type":"string"},"binding":{"type":"object","additionalProperties":{"nullable":true}}}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"404":{"description":"No such binding or room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"409":{"description":"The room already exists, or the rooms changed meanwhile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}}}}},"/api/orgs/{orgId}/channels/{id}/rooms/identities":{"post":{"tags":["channels"],"summary":"Write the identity of every bound room that has none yet (two-step); nothing reaches any room","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomIdentities"}}}},"responses":{"200":{"description":"The rooms without an identity, or what was written.","content":{"application/json":{"schema":{"type":"object","properties":{"missing":{"type":"array","items":{"type":"object","properties":{"roomId":{"type":"string"},"room":{"type":"string"}},"required":["roomId","room"]}},"written":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["missing"]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"403":{"description":"Forbidden.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"404":{"description":"No such binding or room.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}},"409":{"description":"The room already exists, or the rooms changed meanwhile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelRoomsError"}}}}}}},"/api/orgs/{orgId}/channels/installs":{"get":{"tags":["channels"],"summary":"List channel app installs","description":"Where the WizBI provider app (Teams) is installed for this organization — bound to one of its channels or not yet — and whether its Microsoft 365 tenant is connected. Only installs already linked to the organization (its binding, or its Microsoft 365 tenant) are listed. Org admins.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Installs.","content":{"application/json":{"schema":{"type":"object","properties":{"installs":{"type":"array","items":{"$ref":"#/components/schemas/ChannelInstall"}}},"required":["installs"]}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelInstallsError"}}}},"403":{"description":"Not this organization, or not an org admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChannelInstallsError"}}}}}}},"/api/orgs/{orgId}/channels/teams/package":{"get":{"tags":["channels"],"summary":"Download link for the WizBI Teams app","description":"A short-lived link to the WizBI app for Microsoft Teams (`WizBI-Teams.zip`) — the file a Teams admin uploads (Teams admin center → Teams apps → Manage apps → Upload new app), or a person sideloads (Teams → Apps → Manage your apps → Upload an app). One package per environment; it holds no secret. Open the link in a browser within 15 minutes. Any member of the organization.","parameters":[{"schema":{"type":"string"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The link.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageLink"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageError"}}}},"403":{"description":"Not this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageError"}}}},"503":{"description":"Teams is not configured on this deployment (`microsoft_unavailable`), or the package version could not be assigned (`unavailable`, retry).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageError"}}}}}}},"/api/channels/teams/package.zip":{"get":{"tags":["channels"],"summary":"The WizBI Teams app package (zip)","description":"The Teams app package of this environment: `manifest.json` (Microsoft 365 app manifest 1.30) + `color.png` + `outline.png`, and — where the Copilot agent is configured — `declarativeAgent.json` + `ai-plugin.json`. For a signed-in member of an organization, or with a link from `GET /api/orgs/{orgId}/channels/teams/package`.","parameters":[{"schema":{"type":"string"},"required":false,"name":"org","in":"query"},{"schema":{"type":"string"},"required":false,"name":"exp","in":"query"},{"schema":{"type":"string"},"required":false,"name":"sig","in":"query"}],"responses":{"200":{"description":"The zip (`Content-Disposition: attachment; filename=\"WizBI-Teams.zip\"`).","content":{"application/zip":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Neither a session nor a live link.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageError"}}}},"503":{"description":"Teams is not configured on this deployment (`microsoft_unavailable`), or the package version could not be assigned (`unavailable`, retry).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TeamsPackageError"}}}}}}},"/api/admin/whoami":{"get":{"tags":["admin"],"summary":"The caller’s platform role and the admin safety rules (super_admin)","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"principalId":{"type":"string"},"email":{"type":"string","nullable":true},"role":{"type":"string"},"rules":{"type":"array","items":{"type":"string"}}},"required":["principalId","email","role","rules"]}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs":{"get":{"tags":["admin"],"summary":"Every organization with its member count (super_admin)","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"}],"responses":{"200":{"description":"Organizations.","content":{"application/json":{"schema":{"type":"object","properties":{"orgs":{"type":"array","items":{"$ref":"#/components/schemas/AdminOrgRow"}}},"required":["orgs"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["admin"],"summary":"Create an organization, optionally with its first org_admin (two-step)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreateOrgBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}":{"get":{"tags":["admin"],"summary":"One organization: members, sources, channels, tokens and 30-day usage","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgDetail"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["admin"],"summary":"Set what an organization is to WizBI (kind; super_admin, two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPatchOrgBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/sign-in":{"put":{"tags":["admin"],"summary":"The platform part of an organization’s sign-in: `open` (people in its VERIFIED domains sign in without an invitation and join as members) and `locked` (the org admin cannot change the policy). super_admin, two-step","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgSignInBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/members":{"post":{"tags":["admin"],"summary":"Add a member to any organization (attach or invite; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminAddMemberBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization or principal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Already a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/members/{principalId}":{"patch":{"tags":["admin"],"summary":"Change a member’s role or status in any organization (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminPatchMemberBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["admin"],"summary":"Remove a member from any organization (two-step: `?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/tokens":{"get":{"tags":["admin"],"summary":"wz_ tokens pinned to an organization (metadata only)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"tokens":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[0-9a-f]{64}$"},"prefix":{"type":"string","minLength":11,"maxLength":11},"principalId":{"type":"string","minLength":1,"maxLength":128},"orgIdOverride":{"type":"string","minLength":1,"maxLength":128},"channel":{"type":"string","maxLength":32},"allowedTools":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"type":"string","enum":["read","write","admin"]},"default":["read"]},"expiresAt":{"type":"string","format":"date-time"},"revokedAt":{"type":"string","format":"date-time"},"lastUsedAt":{"type":"string","format":"date-time"},"usageCount":{"type":"integer","minimum":0,"default":0},"createdAt":{"type":"string","format":"date-time"},"createdBy":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","maxLength":120},"clientId":{"type":"string","maxLength":1024},"grantId":{"type":"string","maxLength":64},"audience":{"type":"string","maxLength":1024}},"required":["id","prefix","principalId","createdAt"]}}},"required":["tokens"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["admin"],"summary":"Issue a wz_ token pinned to an organization, for a member or yourself (two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminIssueTokenBody"}}}},"responses":{"200":{"description":"Preview, or the result with the raw token (shown once).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/tokens/{tokenId}":{"delete":{"tags":["admin"],"summary":"Revoke a token of an organization (two-step: `?confirm=true` applies)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^[0-9a-f]{64}$"},"required":true,"name":"tokenId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminTwoStep"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such token in this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/threads":{"get":{"tags":["admin"],"summary":"Conversation threads of an organization (reason required; staff-access logged)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"threads":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["threads"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/threads/{id}":{"get":{"tags":["admin"],"summary":"One conversation thread with its turns (reason required; staff-access logged)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such thread.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/activity":{"get":{"tags":["admin"],"summary":"Raw activity of an organization: turns, denials or the AI-client call log (reason required; staff-access logged)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["turns","denials","mcp"],"default":"turns"},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":1024},"required":false,"name":"conversation","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string"},"rows":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["kind","rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/tool-calls":{"get":{"tags":["admin"],"summary":"MCP/tool-call log across organizations or of one (reason required; staff-access logged)","parameters":[{"schema":{"type":"string"},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"onlyFailed","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","maxLength":500,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log)."},"required":false,"description":"Why (required to apply a write and to read content; recorded in the audit / staff access log).","name":"reason","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/AdminToolCallRow"}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/denials":{"get":{"tags":["admin"],"summary":"Policy access denials across organizations or of one","parameters":[{"schema":{"type":"string"},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/AdminDenialRow"}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/gate-log":{"get":{"tags":["admin"],"summary":"Channel gate decisions (answered/ignored and by which rule; no message content)","parameters":[{"schema":{"type":"string"},"required":false,"name":"channel","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/AdminGateRow"}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/audit":{"get":{"tags":["admin"],"summary":"Admin audit log across organizations or of one","parameters":[{"schema":{"type":"string"},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"at":{"type":"string","format":"date-time"},"org_id":{"type":"string","minLength":1},"principal_id":{"type":"string","minLength":1},"principal_kind":{"type":"string"},"role":{"type":"string"},"channel":{"type":"string"},"trace_id":{"type":"string","minLength":1},"action":{"type":"string","minLength":1,"maxLength":120},"target":{"type":"object","properties":{"kind":{"type":"string","minLength":1},"id":{"type":"string","minLength":1}},"required":["kind","id"]},"confirm":{"type":"boolean"},"result":{"type":"string","enum":["preview","applied","denied","failed"]},"before":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"after":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}},"message":{"type":"string","nullable":true,"maxLength":500},"ip":{"type":"string","maxLength":64},"user_agent":{"type":"string","maxLength":300}},"required":["id","at","org_id","principal_id","principal_kind","role","channel","trace_id","action","target","confirm","result","before","after","message"]}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/staff-access":{"get":{"tags":["admin"],"summary":"Staff access log across organizations or of one","parameters":[{"schema":{"type":"string"},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string"},"required":false,"name":"actorId","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"at":{"type":"string","format":"date-time"},"expire_at":{"type":"string","format":"date-time"},"org_id":{"type":"string","minLength":1},"actor_id":{"type":"string","minLength":1},"actor_email":{"type":"string","nullable":true},"action":{"type":"string","enum":["org.enter","threads.list","thread.read","turns.read","tool_calls.read","data.read","members.read","write"]},"target":{"type":"object","nullable":true,"properties":{"kind":{"type":"string","minLength":1},"id":{"type":"string","minLength":1}},"required":["kind","id"]},"reason":{"type":"string","nullable":true,"maxLength":500},"channel":{"type":"string"},"via":{"type":"string","maxLength":200},"trace_id":{"type":"string"},"ip":{"type":"string","nullable":true},"detail":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}}},"required":["id","at","expire_at","org_id","actor_id","actor_email","action","target","reason","channel","via","trace_id","ip","detail"]}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals":{"get":{"tags":["admin"],"summary":"Search people across the platform (name, e-mail, phone, id)","parameters":[{"schema":{"type":"string","maxLength":200},"required":false,"name":"q","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":200},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"principals":{"type":"array","items":{"$ref":"#/components/schemas/AdminPrincipalRow"}}},"required":["principals"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals/{principalId}":{"get":{"tags":["admin"],"summary":"One person: identity and memberships in every organization","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"principal":{"type":"object","properties":{"id":{"type":"string"},"displayName":{"type":"string"},"email":{"type":"string","nullable":true},"phone":{"type":"string","nullable":true},"status":{"type":"string"},"superAdmin":{"type":"boolean"},"primaryOrgId":{"type":"string","nullable":true},"lastSeenAt":{"type":"string","nullable":true},"createdAt":{"type":"string"},"lang":{"type":"string"}},"required":["id","displayName","email","phone","status","superAdmin","primaryOrgId","lastSeenAt","createdAt","lang"]},"memberships":{"type":"array","items":{"type":"object","properties":{"orgId":{"type":"string"},"orgName":{"type":"string"},"role":{"type":"string","enum":["org_admin","member"]},"status":{"type":"string","enum":["active","invited","suspended"]},"addedAt":{"type":"string"},"lastSeenAt":{"type":"string","nullable":true}},"required":["orgId","orgName","role","status","addedAt","lastSeenAt"]}}},"required":["principal","memberships"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such principal.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/health":{"get":{"tags":["admin"],"summary":"Platform health: store, switches, counts, last-24h failures","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminHealth"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/usage":{"get":{"tags":["admin"],"summary":"Usage per organization per day (super_admin)","parameters":[{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"}],"responses":{"200":{"description":"Rows, oldest day first.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"$ref":"#/components/schemas/PlatformUsageRow"}}},"required":["rows"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/staff-access":{"get":{"tags":["activity"],"summary":"WizBI staff access to this organization (org_admin): who, what, when, why","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"at":{"type":"string","format":"date-time"},"expire_at":{"type":"string","format":"date-time"},"org_id":{"type":"string","minLength":1},"actor_id":{"type":"string","minLength":1},"actor_email":{"type":"string","nullable":true},"action":{"type":"string","enum":["org.enter","threads.list","thread.read","turns.read","tool_calls.read","data.read","members.read","write"]},"target":{"type":"object","nullable":true,"properties":{"kind":{"type":"string","minLength":1},"id":{"type":"string","minLength":1}},"required":["kind","id"]},"reason":{"type":"string","nullable":true,"maxLength":500},"channel":{"type":"string"},"via":{"type":"string","maxLength":200},"trace_id":{"type":"string"},"ip":{"type":"string","nullable":true},"detail":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}}},"required":["id","at","expire_at","org_id","actor_id","actor_email","action","target","reason","channel","via","trace_id","ip","detail"]}}},"required":["rows"]}}}},"403":{"description":"Not an org admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/credits":{"get":{"tags":["admin"],"summary":"Credits of every organization for a month, with anomalies (super_admin)","parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"required":false,"name":"month","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreditsOverview"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/credits":{"get":{"tags":["admin"],"summary":"One organization’s credit account, balance, caps, grants, history and budgets","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminOrgCredits"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/credits/grant":{"post":{"tags":["admin"],"summary":"Grant (or adjust) an organization’s credits (two-step with a nonce)","description":"Without `confirm`: `{ preview }` with the balance before/after and a single-use `nonce` (15 minutes, bound to the org, amount, kind and you). With `confirm: true` + the `nonce` + a `reason`: `{ applied: { grant, replay } }` — the same nonce again returns the same grant (`replay: true`). A refused confirm answers 409 `credit_grant_confirm_invalid {reason}`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreditGrantBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreditGrantResult"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The nonce is missing, unknown, expired, used or does not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/credit-settings":{"put":{"tags":["admin"],"summary":"Change an organization’s credit settings and visibility (two-step)","description":"Plan, monthly allowance, the org caps and the platform ceiling, alert thresholds, what happens when exhausted, and which components the org may see (`visibility`, all off by default). Without `confirm`: `{ preview: { before, after } }`; with `confirm: true` + `reason`: `{ applied: { account } }`. A stale `expectedVersion` answers 409 `version_conflict`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreditSettingsBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminCreditSettingsResult"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A newer version of the account exists.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/modules/usage":{"get":{"tags":["admin"],"summary":"Usage per module and organization for a month: turns, calls, credits (super_admin)","parameters":[{"schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"required":false,"name":"month","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminModuleUsage"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/sources/usage":{"get":{"tags":["admin"],"summary":"Usage and health per connector and data source: calls, rows, bytes, p95, errors, tables, silent sources (super_admin)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":92},"required":false,"name":"days","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":92},"required":false,"name":"silentDays","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":false,"name":"orgId","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSourceUsage"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/sources/report":{"post":{"tags":["admin"],"summary":"The weekly source report on demand; send=true posts it to the platform Slack channel (super_admin)","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"send":{"type":"boolean","default":false},"watch":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminSourceReport"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/meta":{"get":{"tags":["admin"],"summary":"Service manifest and runtime facts (super_admin)","description":"What this service declares about itself (agent.manifest.json) plus what it observes at runtime. Harvested into the capability catalog.","responses":{"200":{"description":"Manifest and runtime.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdminMeta"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/features":{"get":{"tags":["features"],"summary":"Every feature flag evaluated for the organization (server-side; the console renders it)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Evaluated flags.","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string"},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"sources":{"type":"object","additionalProperties":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"profile":{"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"missing":{"type":"boolean"}},"required":["id","version"]},"version":{"type":"string"}},"required":["orgId","plan","flags","sources","version"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/features":{"get":{"tags":["features"],"summary":"The flag catalog and the platform-wide defaults (super_admin)","responses":{"200":{"description":"Catalog and defaults.","content":{"application/json":{"schema":{"type":"object","properties":{"catalog":{"type":"array","items":{"$ref":"#/components/schemas/FeatureCatalogRow"}},"platform":{"type":"object","properties":{"defaults":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"profiles":{"type":"object","additionalProperties":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500},"flags":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["label"]},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}}}},"required":["catalog","platform"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["features"],"summary":"Replace the platform-wide flag defaults (super_admin)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"defaults":{"type":"object","additionalProperties":{"type":"boolean"}}},"required":["defaults"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"defaults":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"profiles":{"type":"object","additionalProperties":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500},"flags":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["label"]},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}}}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/features":{"get":{"tags":["features"],"summary":"An organization's plan, overrides and evaluated flags (super_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Flags.","content":{"application/json":{"schema":{"type":"object","properties":{"org":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","minLength":1,"maxLength":64,"default":"default"},"profile":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,31}$"},"overrides":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["orgId"]},"evaluated":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string"},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"sources":{"type":"object","additionalProperties":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"profile":{"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"missing":{"type":"boolean"}},"required":["id","version"]},"version":{"type":"string"}},"required":["orgId","plan","flags","sources","version"]},"catalog":{"type":"array","items":{"$ref":"#/components/schemas/FeatureCatalogRow"}}},"required":["org","evaluated","catalog"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["features"],"summary":"Replace an organization's plan, flag overrides and flag settings (super_admin; stale version answers 409)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","minLength":1,"maxLength":64},"profile":{"type":"string","nullable":true,"pattern":"^[a-z][a-z0-9_-]{0,31}$"},"overrides":{"type":"object","additionalProperties":{"type":"boolean"}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"note":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0}},"required":["overrides"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string","minLength":1,"maxLength":64,"default":"default"},"profile":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,31}$"},"overrides":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["orgId"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/features/preview":{"post":{"tags":["features"],"summary":"What a PUT of the organization's flags would change, without saving (super_admin): value changes and layer moves","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string","minLength":1,"maxLength":64},"profile":{"type":"string","nullable":true,"pattern":"^[a-z][a-z0-9_-]{0,31}$"},"overrides":{"type":"object","additionalProperties":{"type":"boolean"}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"note":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0}},"required":["overrides"]}}}},"responses":{"200":{"description":"The diff.","content":{"application/json":{"schema":{"type":"object","properties":{"before":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string"},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"sources":{"type":"object","additionalProperties":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"profile":{"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"missing":{"type":"boolean"}},"required":["id","version"]},"version":{"type":"string"}},"required":["orgId","plan","flags","sources","version"]},"after":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"plan":{"type":"string"},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"sources":{"type":"object","additionalProperties":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"settings":{"type":"object","properties":{"capability.catalog_assets":{"type":"object","properties":{"sources":{"type":"array","items":{"type":"string","maxLength":300,"pattern":"^gs:\\/\\/[a-z0-9][a-z0-9._-]{1,220}[a-z0-9]\\/(?:[^\\s?#\\\\]+\\/)?$"},"minItems":1,"maxItems":20}},"required":["sources"]},"capability.asset_viewer":{"type":"object","properties":{"embedHosts":{"type":"array","items":{"type":"string","maxLength":253,"pattern":"^(?!-)[a-z0-9-]{1,63}(?:\\.(?!-)[a-z0-9-]{1,63})+$"},"maxItems":20,"default":[]}},"additionalProperties":false}},"additionalProperties":false},"profile":{"type":"object","properties":{"id":{"type":"string"},"version":{"type":"integer"},"missing":{"type":"boolean"}},"required":["id","version"]},"version":{"type":"string"}},"required":["orgId","plan","flags","sources","version"]},"changes":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"from":{"type":"boolean"},"to":{"type":"boolean"},"fromSource":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]},"toSource":{"type":"string","enum":["org","profile","platform","plan","catalog","unknown"]}},"required":["id","from","to","fromSource","toSource"]}}},"required":["before","after","changes"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/features/profiles/{profileId}":{"put":{"tags":["features"],"summary":"Create or replace a feature profile (super_admin; versioned, stale version answers 409)","parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,31}$"},"required":true,"name":"profileId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500},"flags":{"type":"object","additionalProperties":{"type":"boolean"}},"note":{"type":"string","maxLength":500},"version":{"type":"integer","minimum":0}},"required":["label","flags"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"defaults":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"profiles":{"type":"object","additionalProperties":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500},"flags":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["label"]},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}}}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/features/profiles/{profileId}/preview":{"post":{"tags":["features"],"summary":"What saving these profile flags would change on every organization assigned to it, without saving (super_admin)","parameters":[{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_-]{0,31}$"},"required":true,"name":"profileId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"flags":{"type":"object","additionalProperties":{"type":"boolean"}}},"required":["flags"]}}}},"responses":{"200":{"description":"Affected organizations.","content":{"application/json":{"schema":{"type":"object","properties":{"assigned":{"type":"integer"},"impacts":{"type":"array","items":{"$ref":"#/components/schemas/FeatureOrgImpact"}}},"required":["assigned","impacts"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/features/report":{"get":{"tags":["features"],"summary":"What is on where: every organization with its profile, overrides and evaluated flags (super_admin)","responses":{"200":{"description":"The report.","content":{"application/json":{"schema":{"type":"object","properties":{"platform":{"type":"object","properties":{"defaults":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"profiles":{"type":"object","additionalProperties":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500},"flags":{"type":"object","additionalProperties":{"type":"boolean"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["label"]},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}}},"orgs":{"type":"array","items":{"$ref":"#/components/schemas/FeatureReportRow"}}},"required":["platform","orgs"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agents":{"get":{"tags":["agents"],"summary":"Agents available to the organization, its layer on each, and the routing (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Agents.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgAgentsView"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agents/{agentId}":{"put":{"tags":["agents"],"summary":"Replace the organization's layer on an agent: persona, overlays, narrowing (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":48},"required":true,"name":"agentId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutOrgAgentBody"}}}},"responses":{"200":{"description":"Preview or the saved layer.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"agentId":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean","default":true},"persona":{"type":"string","maxLength":20000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"channelOverlays":{"type":"object","properties":{"web":{"type":"string","maxLength":10000},"mcp":{"type":"string","maxLength":10000},"rest":{"type":"string","maxLength":10000},"whatsapp":{"type":"string","maxLength":10000},"whatsapp_web":{"type":"string","maxLength":10000},"telegram":{"type":"string","maxLength":10000},"sms":{"type":"string","maxLength":10000},"slack":{"type":"string","maxLength":10000},"teams":{"type":"string","maxLength":10000},"email":{"type":"string","maxLength":10000},"voice":{"type":"string","maxLength":10000},"scheduled":{"type":"string","maxLength":10000}},"default":{}},"roomOverlays":{"type":"object","additionalProperties":{"type":"string","maxLength":10000},"default":{}},"toolDeny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"roles":{"type":"object","properties":{"lean":{"type":"string","enum":["fast","deep"]},"full":{"type":"string","enum":["fast","deep"]}},"default":{}},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["agentId","orgId"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agents/{agentId}/versions":{"get":{"tags":["agents"],"summary":"History of the organization's layer on an agent (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":48},"required":true,"name":"agentId","in":"path"}],"responses":{"200":{"description":"Versions, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"type":"object","properties":{"version":{"type":"integer"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"note":{"type":"string"}},"required":["version"]}}},"required":["versions"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agents/{agentId}/versions/{version}":{"get":{"tags":["agents"],"summary":"One historical version of the organization's layer (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":48},"required":true,"name":"agentId","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":true,"name":"version","in":"path"}],"responses":{"200":{"description":"The version.","content":{"application/json":{"schema":{"type":"object","properties":{"agentId":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean","default":true},"persona":{"type":"string","maxLength":20000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"channelOverlays":{"type":"object","properties":{"web":{"type":"string","maxLength":10000},"mcp":{"type":"string","maxLength":10000},"rest":{"type":"string","maxLength":10000},"whatsapp":{"type":"string","maxLength":10000},"whatsapp_web":{"type":"string","maxLength":10000},"telegram":{"type":"string","maxLength":10000},"sms":{"type":"string","maxLength":10000},"slack":{"type":"string","maxLength":10000},"teams":{"type":"string","maxLength":10000},"email":{"type":"string","maxLength":10000},"voice":{"type":"string","maxLength":10000},"scheduled":{"type":"string","maxLength":10000}},"default":{}},"roomOverlays":{"type":"object","additionalProperties":{"type":"string","maxLength":10000},"default":{}},"toolDeny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"roles":{"type":"object","properties":{"lean":{"type":"string","enum":["fast","deep"]},"full":{"type":"string","enum":["fast","deep"]}},"default":{}},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string","maxLength":500}},"required":["agentId","orgId"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agent-routing":{"put":{"tags":["agents"],"summary":"Which agent answers on each channel and room (org_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAgentRoutingBody"}}}},"responses":{"200":{"description":"Preview or the saved routing.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"defaultAgent":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$","default":"wizbi"},"channels":{"type":"object","properties":{"web":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"mcp":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"rest":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"whatsapp":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"whatsapp_web":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"telegram":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"sms":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"slack":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"teams":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"email":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"voice":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"scheduled":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"}},"default":{}},"rooms":{"type":"object","additionalProperties":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"default":{}},"version":{"type":"integer","minimum":0,"default":0},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["orgId"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/agents/resolve":{"post":{"tags":["agents"],"summary":"The effective agent profile for a channel/room: which agent answers and its prompt layers (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResolveAgentBody"}}}},"responses":{"200":{"description":"The profile.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentProfileView"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/agents":{"get":{"tags":["agents"],"summary":"Every platform agent, built-in and stored (super_admin)","responses":{"200":{"description":"Agents.","content":{"application/json":{"schema":{"type":"object","properties":{"agents":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"name":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500,"default":""},"persona":{"type":"string","maxLength":40000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"tools":{"type":"object","properties":{"allow":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":["*"]},"deny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"connectors":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":["*"]}},"default":{"allow":["*"],"deny":[],"connectors":["*"]}},"modes":{"type":"object","properties":{"lean":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}},"full":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}}},"default":{"lean":{"role":"fast","includeOrgSkill":true},"full":{"role":"fast","includeOrgSkill":true}}},"defaultMode":{"type":"string","enum":["lean","full"],"default":"full"},"escalation":{"type":"boolean","default":true},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"default":[]},"audience":{"type":"string","enum":["everyone","org_admins"],"default":"everyone"},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]},"default":[]},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"status":{"type":"string","enum":["active","disabled"],"default":"active"},"version":{"type":"integer","minimum":0,"default":1},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","name"]}}},"required":["agents"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/agents/{agentId}":{"put":{"tags":["agents"],"summary":"Create or replace a platform agent (super_admin; two-step; stale version answers 409)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":48},"required":true,"name":"agentId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"agent":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"name":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500,"default":""},"persona":{"type":"string","maxLength":40000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"tools":{"type":"object","properties":{"allow":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":["*"]},"deny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"connectors":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":["*"]}},"default":{"allow":["*"],"deny":[],"connectors":["*"]}},"modes":{"type":"object","properties":{"lean":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}},"full":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}}},"default":{"lean":{"role":"fast","includeOrgSkill":true},"full":{"role":"fast","includeOrgSkill":true}}},"defaultMode":{"type":"string","enum":["lean","full"],"default":"full"},"escalation":{"type":"boolean","default":true},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"default":[]},"audience":{"type":"string","enum":["everyone","org_admins"],"default":"everyone"},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]},"default":[]},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"status":{"type":"string","enum":["active","disabled"],"default":"active"},"version":{"type":"integer","minimum":0,"default":1},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","name"]},"expectedVersion":{"type":"integer","minimum":0},"note":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false}},"required":["agent"]}}}},"responses":{"200":{"description":"Preview or the saved agent.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","additionalProperties":{"nullable":true}}},"required":["preview"]},{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9-]{1,47}$"},"name":{"type":"string","minLength":1,"maxLength":80},"description":{"type":"string","maxLength":500,"default":""},"persona":{"type":"string","maxLength":40000,"default":""},"layers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]{0,63}$","description":"Stable id, e.g. \"group\", \"dm\", \"guest\", \"shared_room\"."},"text":{"type":"string","maxLength":20000},"when":{"type":"object","properties":{"modes":{"type":"array","items":{"type":"string","enum":["lean","full"]}},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]}},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]}},"roles":{"type":"array","items":{"type":"string","enum":["member","group_admin","org_admin","super_admin"]}},"flag":{"type":"string","maxLength":80}},"default":{}}},"required":["id","text"]},"maxItems":40,"default":[]},"tools":{"type":"object","properties":{"allow":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":["*"]},"deny":{"type":"array","items":{"type":"string","minLength":1,"maxLength":200},"default":[]},"connectors":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"default":["*"]}},"default":{"allow":["*"],"deny":[],"connectors":["*"]}},"modes":{"type":"object","properties":{"lean":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}},"full":{"type":"object","properties":{"role":{"type":"string","enum":["fast","deep"],"default":"fast"},"maxRounds":{"type":"integer","minimum":1,"maximum":40},"thinkingBudget":{"type":"integer","minimum":-1,"maximum":32768},"toolCap":{"type":"integer","minimum":0,"maximum":200},"includeOrgSkill":{"type":"boolean","default":true}},"default":{"role":"fast","includeOrgSkill":true}}},"default":{"lean":{"role":"fast","includeOrgSkill":true},"full":{"role":"fast","includeOrgSkill":true}}},"defaultMode":{"type":"string","enum":["lean","full"],"default":"full"},"escalation":{"type":"boolean","default":true},"channels":{"type":"array","items":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"default":[]},"audience":{"type":"string","enum":["everyone","org_admins"],"default":"everyone"},"chatTypes":{"type":"array","items":{"type":"string","enum":["dm","group"]},"default":[]},"limits":{"type":"object","properties":{"turnsPerDay":{"type":"integer","minimum":0,"exclusiveMinimum":true},"maxMessageChars":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":100000}},"default":{}},"status":{"type":"string","enum":["active","disabled"],"default":"active"},"version":{"type":"integer","minimum":0,"default":1},"updatedAt":{"type":"string","format":"date-time"},"updatedBy":{"type":"string","minLength":1,"maxLength":128}},"required":["id","name"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/agents/{agentId}/versions":{"get":{"tags":["agents"],"summary":"History of a platform agent (super_admin)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":48},"required":true,"name":"agentId","in":"path"}],"responses":{"200":{"description":"Versions, newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"versions":{"type":"array","items":{"type":"object","properties":{"version":{"type":"integer"},"updatedAt":{"type":"string"},"updatedBy":{"type":"string"},"note":{"type":"string"}},"required":["version"]}}},"required":["versions"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/catalog":{"get":{"tags":["catalog"],"summary":"Every module of every kind with its platform switch, instances, usage and health","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":false,"name":"kind","in":"query"}],"responses":{"200":{"description":"The catalog.","content":{"application/json":{"schema":{"type":"object","properties":{"env":{"type":"string"},"modules":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"manifest":{"type":"object","properties":{"manifestVersion":{"type":"number","enum":[2]},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"status":{"type":"string","enum":["ga","beta","experimental","deprecated"]},"name":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"category":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,39}$"},"icon":{"type":"string","minLength":1,"maxLength":64},"owner":{"type":"string","enum":["core","core-agent","core-channels","core-data","core-files","core-identity","core-notify","core-platform"]},"costUnit":{"type":"string","enum":["none","call","token","message","query","byte_scanned","second","character","file"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"minCoreVersion":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"breakingChanges":{"type":"array","items":{"type":"object","properties":{"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeDeadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"migrationDocs":{"type":"string","minLength":1,"maxLength":200}},"required":["version","upgradeDeadline","message"]},"default":[]},"docs":{"type":"string","minLength":1,"maxLength":200},"configSchema":{"type":"object","additionalProperties":{"nullable":true},"default":{"type":"object","properties":{}}},"secrets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_.-]{0,99}$"},"required":{"type":"boolean","default":false},"description":{"type":"string","maxLength":500,"default":""},"scope":{"type":"string","enum":["instance","platform"],"default":"instance"},"rotationDays":{"type":"integer","minimum":1,"maximum":730},"lastRotated":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["name"]},"default":[]},"capabilities":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"dependsOn":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]},"health":{"type":"object","properties":{"probe":{"type":"string","enum":["test","http","self","none"],"default":"none"},"intervalMin":{"type":"integer","minimum":0,"maximum":1440,"default":0}},"default":{"probe":"none","intervalMin":0}},"slo":{"type":"object","properties":{"errorRate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1},"p95Ms":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":600000},"availability":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1}},"required":["errorRate","p95Ms","availability"]},"alerts":{"type":"object","properties":{"channel":{"type":"string","enum":["alerts","errors","security","dev"],"default":"alerts"}},"default":{"channel":"alerts"}},"metrics":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"toolProviders":{"type":"array","items":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"default":[]},"tools":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"default":[]},"defaults":{"type":"object","properties":{"platformEnabled":{"type":"boolean"},"orgEnabled":{"type":"boolean"}},"required":["platformEnabled","orgEnabled"]},"envs":{"type":"object","properties":{"local":{"type":"string","enum":["on","off","flag"]},"qa":{"type":"string","enum":["on","off","flag"]},"prod":{"type":"string","enum":["on","off","flag"]}},"required":["local","qa","prod"]},"flag":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"conformance":{"type":"object","properties":{"gaps":{"type":"object","additionalProperties":{"type":"string","minLength":20,"maxLength":500},"default":{}}}}},"required":["manifestVersion","kind","id","version","status","name","summary","category","icon","owner","costUnit","lifecycle","minCoreVersion","docs","defaults","envs"]},"manifestComplete":{"type":"boolean"},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"}},"required":["enabled","source","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]},"orgsDisabled":{"type":"integer","minimum":0,"default":0},"instances":{"type":"object","properties":{"total":{"type":"integer","minimum":0},"enabled":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0}},"required":["total","enabled"]},"usage7d":{"type":"object","nullable":true,"properties":{"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0},"p50Ms":{"type":"number","minimum":0},"lastCallAt":{"type":"string","format":"date-time"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0}},"required":["day","calls","errors"]},"default":[]},"costUsd":{"type":"number","minimum":0}},"required":["calls","errors"]},"health":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"checkedAt":{"type":"string","format":"date-time"},"errorCode":{"type":"string","maxLength":64},"instances":{"type":"integer","minimum":0},"failing":{"type":"integer","minimum":0}},"required":["status"]}},"required":["ref","manifest","manifestComplete","platform","effective","instances","usage7d","health"]}},"incomplete":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]}},"required":["env","modules"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/catalog/{kind}/{id}":{"get":{"tags":["catalog"],"summary":"One module and the history of its platform switch (super_admin)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Module.","content":{"application/json":{"schema":{"type":"object","properties":{"entry":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"manifest":{"type":"object","properties":{"manifestVersion":{"type":"number","enum":[2]},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"status":{"type":"string","enum":["ga","beta","experimental","deprecated"]},"name":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"category":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,39}$"},"icon":{"type":"string","minLength":1,"maxLength":64},"owner":{"type":"string","enum":["core","core-agent","core-channels","core-data","core-files","core-identity","core-notify","core-platform"]},"costUnit":{"type":"string","enum":["none","call","token","message","query","byte_scanned","second","character","file"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"minCoreVersion":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"breakingChanges":{"type":"array","items":{"type":"object","properties":{"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeDeadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"migrationDocs":{"type":"string","minLength":1,"maxLength":200}},"required":["version","upgradeDeadline","message"]},"default":[]},"docs":{"type":"string","minLength":1,"maxLength":200},"configSchema":{"type":"object","additionalProperties":{"nullable":true},"default":{"type":"object","properties":{}}},"secrets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_.-]{0,99}$"},"required":{"type":"boolean","default":false},"description":{"type":"string","maxLength":500,"default":""},"scope":{"type":"string","enum":["instance","platform"],"default":"instance"},"rotationDays":{"type":"integer","minimum":1,"maximum":730},"lastRotated":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["name"]},"default":[]},"capabilities":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"dependsOn":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]},"health":{"type":"object","properties":{"probe":{"type":"string","enum":["test","http","self","none"],"default":"none"},"intervalMin":{"type":"integer","minimum":0,"maximum":1440,"default":0}},"default":{"probe":"none","intervalMin":0}},"slo":{"type":"object","properties":{"errorRate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1},"p95Ms":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":600000},"availability":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1}},"required":["errorRate","p95Ms","availability"]},"alerts":{"type":"object","properties":{"channel":{"type":"string","enum":["alerts","errors","security","dev"],"default":"alerts"}},"default":{"channel":"alerts"}},"metrics":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"toolProviders":{"type":"array","items":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"default":[]},"tools":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"default":[]},"defaults":{"type":"object","properties":{"platformEnabled":{"type":"boolean"},"orgEnabled":{"type":"boolean"}},"required":["platformEnabled","orgEnabled"]},"envs":{"type":"object","properties":{"local":{"type":"string","enum":["on","off","flag"]},"qa":{"type":"string","enum":["on","off","flag"]},"prod":{"type":"string","enum":["on","off","flag"]}},"required":["local","qa","prod"]},"flag":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"conformance":{"type":"object","properties":{"gaps":{"type":"object","additionalProperties":{"type":"string","minLength":20,"maxLength":500},"default":{}}}}},"required":["manifestVersion","kind","id","version","status","name","summary","category","icon","owner","costUnit","lifecycle","minCoreVersion","docs","defaults","envs"]},"manifestComplete":{"type":"boolean"},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"}},"required":["enabled","source","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]},"orgsDisabled":{"type":"integer","minimum":0,"default":0},"instances":{"type":"object","properties":{"total":{"type":"integer","minimum":0},"enabled":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0}},"required":["total","enabled"]},"usage7d":{"type":"object","nullable":true,"properties":{"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0},"p50Ms":{"type":"number","minimum":0},"lastCallAt":{"type":"string","format":"date-time"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0}},"required":["day","calls","errors"]},"default":[]},"costUsd":{"type":"number","minimum":0}},"required":["calls","errors"]},"health":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"checkedAt":{"type":"string","format":"date-time"},"errorCode":{"type":"string","maxLength":64},"instances":{"type":"integer","minimum":0},"failing":{"type":"integer","minimum":0}},"required":["status"]}},"required":["ref","manifest","manifestComplete","platform","effective","instances","usage7d","health"]},"history":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"versions":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"tools":{"type":"object","additionalProperties":{"type":"boolean"}},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0},"previousEnabled":{"type":"boolean","nullable":true}},"required":["ref","kind","id","level","enabled","updatedBy","updatedAt","version","previousEnabled"]}}},"required":["ref","level","versions"]}},"required":["entry","history"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["catalog"],"summary":"Switch a module on/off for the whole platform (super_admin; two-step; reason)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"tool":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"reason":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["enabled"]}}}},"responses":{"200":{"description":"Preview (no confirm) or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"boolean","enum":[true]},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"current":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"next":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"]},"tool":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"changed":{"type":"boolean"},"impact":{"type":"object","properties":{"instances":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0},"dependents":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]}},"required":["instances"]},"requiresReason":{"type":"boolean"},"expectedVersion":{"type":"integer","minimum":0}},"required":["preview","ref","level","current","next","changed","impact","requiresReason","expectedVersion"]},{"type":"object","properties":{"preview":{"type":"boolean","enum":[false]},"state":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"tools":{"type":"object","additionalProperties":{"type":"boolean"}},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","kind","id","level","enabled","updatedBy","updatedAt","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]}},"required":["preview","state","effective"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/catalog":{"get":{"tags":["catalog"],"summary":"The modules the organization may use, its own switch, instances, usage and health","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":false,"name":"kind","in":"query"}],"responses":{"200":{"description":"The org catalog.","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"env":{"type":"string"},"modules":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"manifest":{"type":"object","properties":{"manifestVersion":{"type":"number","enum":[2]},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"status":{"type":"string","enum":["ga","beta","experimental","deprecated"]},"name":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"category":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,39}$"},"icon":{"type":"string","minLength":1,"maxLength":64},"owner":{"type":"string","enum":["core","core-agent","core-channels","core-data","core-files","core-identity","core-notify","core-platform"]},"costUnit":{"type":"string","enum":["none","call","token","message","query","byte_scanned","second","character","file"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"minCoreVersion":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"breakingChanges":{"type":"array","items":{"type":"object","properties":{"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeDeadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"migrationDocs":{"type":"string","minLength":1,"maxLength":200}},"required":["version","upgradeDeadline","message"]},"default":[]},"docs":{"type":"string","minLength":1,"maxLength":200},"configSchema":{"type":"object","additionalProperties":{"nullable":true},"default":{"type":"object","properties":{}}},"secrets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_.-]{0,99}$"},"required":{"type":"boolean","default":false},"description":{"type":"string","maxLength":500,"default":""},"scope":{"type":"string","enum":["instance","platform"],"default":"instance"},"rotationDays":{"type":"integer","minimum":1,"maximum":730},"lastRotated":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["name"]},"default":[]},"capabilities":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"dependsOn":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]},"health":{"type":"object","properties":{"probe":{"type":"string","enum":["test","http","self","none"],"default":"none"},"intervalMin":{"type":"integer","minimum":0,"maximum":1440,"default":0}},"default":{"probe":"none","intervalMin":0}},"slo":{"type":"object","properties":{"errorRate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1},"p95Ms":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":600000},"availability":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1}},"required":["errorRate","p95Ms","availability"]},"alerts":{"type":"object","properties":{"channel":{"type":"string","enum":["alerts","errors","security","dev"],"default":"alerts"}},"default":{"channel":"alerts"}},"metrics":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"toolProviders":{"type":"array","items":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"default":[]},"tools":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"default":[]},"defaults":{"type":"object","properties":{"platformEnabled":{"type":"boolean"},"orgEnabled":{"type":"boolean"}},"required":["platformEnabled","orgEnabled"]},"envs":{"type":"object","properties":{"local":{"type":"string","enum":["on","off","flag"]},"qa":{"type":"string","enum":["on","off","flag"]},"prod":{"type":"string","enum":["on","off","flag"]}},"required":["local","qa","prod"]},"flag":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"conformance":{"type":"object","properties":{"gaps":{"type":"object","additionalProperties":{"type":"string","minLength":20,"maxLength":500},"default":{}}}}},"required":["manifestVersion","kind","id","version","status","name","summary","category","icon","owner","costUnit","lifecycle","minCoreVersion","docs","defaults","envs"]},"available":{"type":"boolean"},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"}},"required":["enabled","source","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]},"instances":{"type":"object","properties":{"total":{"type":"integer","minimum":0},"enabled":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0}},"required":["total","enabled"]},"usage7d":{"type":"object","nullable":true,"properties":{"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0},"p50Ms":{"type":"number","minimum":0},"lastCallAt":{"type":"string","format":"date-time"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0}},"required":["day","calls","errors"]},"default":[]},"costUsd":{"type":"number","minimum":0}},"required":["calls","errors"]},"health":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"checkedAt":{"type":"string","format":"date-time"},"errorCode":{"type":"string","maxLength":64},"instances":{"type":"integer","minimum":0},"failing":{"type":"integer","minimum":0}},"required":["status"]},"audience":{"type":"object","properties":{"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"version":{"type":"integer","minimum":0}},"required":["blockedGroups","blockedRooms","version"]},"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"requestedAt":{"type":"string","format":"date-time"},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string"}},"required":["id","requestedAt","requestedBy"]}},"required":["ref","manifest","available","org","effective","instances","usage7d","health"]}},"plan":{"type":"object","properties":{"plan":{"type":"object","nullable":true,"properties":{"id":{"type":"string","enum":["solo","team","company","enterprise"]},"order":{"type":"integer","minimum":0,"exclusiveMinimum":true},"monthlyCredits":{"type":"integer","minimum":0},"users":{"type":"object","properties":{"included":{"type":"integer","nullable":true,"minimum":0},"max":{"type":"integer","nullable":true,"minimum":0}},"required":["included","max"]},"sources":{"type":"object","properties":{"max":{"type":"integer","nullable":true,"minimum":0}},"required":["max"]}},"required":["id","order","monthlyCredits","users","sources"]},"modules":{"type":"object","properties":{"entitled":{"type":"integer","minimum":0},"total":{"type":"integer","minimum":0}},"required":["entitled","total"]},"pendingRequests":{"type":"integer","minimum":0},"enforced":{"type":"boolean"}},"required":["plan","modules","pendingRequests"]}},"required":["orgId","env","modules"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/catalog/{kind}/{id}":{"get":{"tags":["catalog"],"summary":"One module and the history of the organization's switch (org_admin)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Module.","content":{"application/json":{"schema":{"type":"object","properties":{"entry":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"manifest":{"type":"object","properties":{"manifestVersion":{"type":"number","enum":[2]},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"status":{"type":"string","enum":["ga","beta","experimental","deprecated"]},"name":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"summary":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"category":{"type":"string","pattern":"^[a-z][a-z0-9-]{0,39}$"},"icon":{"type":"string","minLength":1,"maxLength":64},"owner":{"type":"string","enum":["core","core-agent","core-channels","core-data","core-files","core-identity","core-notify","core-platform"]},"costUnit":{"type":"string","enum":["none","call","token","message","query","byte_scanned","second","character","file"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"minCoreVersion":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"breakingChanges":{"type":"array","items":{"type":"object","properties":{"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeDeadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"migrationDocs":{"type":"string","minLength":1,"maxLength":200}},"required":["version","upgradeDeadline","message"]},"default":[]},"docs":{"type":"string","minLength":1,"maxLength":200},"configSchema":{"type":"object","additionalProperties":{"nullable":true},"default":{"type":"object","properties":{}}},"secrets":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","pattern":"^[A-Za-z][A-Za-z0-9_.-]{0,99}$"},"required":{"type":"boolean","default":false},"description":{"type":"string","maxLength":500,"default":""},"scope":{"type":"string","enum":["instance","platform"],"default":"instance"},"rotationDays":{"type":"integer","minimum":1,"maximum":730},"lastRotated":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["name"]},"default":[]},"capabilities":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"dependsOn":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]},"health":{"type":"object","properties":{"probe":{"type":"string","enum":["test","http","self","none"],"default":"none"},"intervalMin":{"type":"integer","minimum":0,"maximum":1440,"default":0}},"default":{"probe":"none","intervalMin":0}},"slo":{"type":"object","properties":{"errorRate":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1},"p95Ms":{"type":"integer","minimum":0,"exclusiveMinimum":true,"maximum":600000},"availability":{"type":"number","minimum":0,"exclusiveMinimum":true,"maximum":1}},"required":["errorRate","p95Ms","availability"]},"alerts":{"type":"object","properties":{"channel":{"type":"string","enum":["alerts","errors","security","dev"],"default":"alerts"}},"default":{"channel":"alerts"}},"metrics":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_.:-]{0,99}$"},"default":[]},"toolProviders":{"type":"array","items":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"default":[]},"tools":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"default":[]},"defaults":{"type":"object","properties":{"platformEnabled":{"type":"boolean"},"orgEnabled":{"type":"boolean"}},"required":["platformEnabled","orgEnabled"]},"envs":{"type":"object","properties":{"local":{"type":"string","enum":["on","off","flag"]},"qa":{"type":"string","enum":["on","off","flag"]},"prod":{"type":"string","enum":["on","off","flag"]}},"required":["local","qa","prod"]},"flag":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"conformance":{"type":"object","properties":{"gaps":{"type":"object","additionalProperties":{"type":"string","minLength":20,"maxLength":500},"default":{}}}}},"required":["manifestVersion","kind","id","version","status","name","summary","category","icon","owner","costUnit","lifecycle","minCoreVersion","docs","defaults","envs"]},"available":{"type":"boolean"},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"}},"required":["enabled","source","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]},"instances":{"type":"object","properties":{"total":{"type":"integer","minimum":0},"enabled":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0}},"required":["total","enabled"]},"usage7d":{"type":"object","nullable":true,"properties":{"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0},"p50Ms":{"type":"number","minimum":0},"lastCallAt":{"type":"string","format":"date-time"},"days":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"calls":{"type":"integer","minimum":0},"errors":{"type":"integer","minimum":0}},"required":["day","calls","errors"]},"default":[]},"costUsd":{"type":"number","minimum":0}},"required":["calls","errors"]},"health":{"type":"object","nullable":true,"properties":{"status":{"type":"string","enum":["ok","degraded","failing","unknown"]},"checkedAt":{"type":"string","format":"date-time"},"errorCode":{"type":"string","maxLength":64},"instances":{"type":"integer","minimum":0},"failing":{"type":"integer","minimum":0}},"required":["status"]},"audience":{"type":"object","properties":{"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"version":{"type":"integer","minimum":0}},"required":["blockedGroups","blockedRooms","version"]},"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"requestedAt":{"type":"string","format":"date-time"},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"note":{"type":"string"}},"required":["id","requestedAt","requestedBy"]}},"required":["ref","manifest","available","org","effective","instances","usage7d","health"]},"history":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"versions":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"tools":{"type":"object","additionalProperties":{"type":"boolean"}},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0},"previousEnabled":{"type":"boolean","nullable":true}},"required":["ref","kind","id","level","enabled","updatedBy","updatedAt","version","previousEnabled"]}}},"required":["ref","level","versions"]}},"required":["entry","history"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["catalog"],"summary":"Switch a module on/off for the organization (org_admin; two-step)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"tool":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"reason":{"type":"string","maxLength":500},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["enabled"]}}}},"responses":{"200":{"description":"Preview (no confirm) or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"boolean","enum":[true]},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"current":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"next":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"]},"tool":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"changed":{"type":"boolean"},"impact":{"type":"object","properties":{"instances":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0},"dependents":{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"default":[]}},"required":["instances"]},"requiresReason":{"type":"boolean"},"expectedVersion":{"type":"integer","minimum":0}},"required":["preview","ref","level","current","next","changed","impact","requiresReason","expectedVersion"]},{"type":"object","properties":{"preview":{"type":"boolean","enum":[false]},"state":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"level":{"type":"string","enum":["platform","org"]},"orgId":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"tools":{"type":"object","additionalProperties":{"type":"boolean"}},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","kind","id","level","enabled","updatedBy","updatedAt","version"]},"effective":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"id":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"enabled":{"type":"boolean"},"offReason":{"type":"string","nullable":true,"enum":["unknown_module","env_off","flag_off","platform_off","org_off","dependency_off","instance_off","sunset","upgrade_required","not_entitled","audience_off",null]},"blockedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"env":{"type":"string","enum":["on","off","flag"]},"platform":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0}},"required":["enabled","source","version"]},"org":{"type":"object","properties":{"enabled":{"type":"boolean"},"source":{"type":"string","enum":["state","default"]},"version":{"type":"integer","minimum":0},"orgId":{"type":"string","minLength":1,"maxLength":128}},"required":["enabled","source","version","orgId"]},"instance":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"enabled":{"type":"boolean"},"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeBy":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"required":["id","enabled"]},"lifecycle":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}},"required":["stage"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"audienceBlock":{"type":"string","enum":["room","group"]},"toolsOff":{"type":"array","items":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"}}},"required":["ref","kind","id","enabled","offReason","env","platform"]}},"required":["preview","state","effective"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/plans":{"get":{"tags":["catalog"],"summary":"The plans, their credits and limits, and the modules each includes (super_admin)","responses":{"200":{"description":"The plans.","content":{"application/json":{"schema":{"type":"object","properties":{"plans":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["solo","team","company","enterprise"]},"order":{"type":"integer","minimum":0,"exclusiveMinimum":true},"monthlyCredits":{"type":"integer","minimum":0},"users":{"type":"object","properties":{"included":{"type":"integer","nullable":true,"minimum":0},"max":{"type":"integer","nullable":true,"minimum":0}},"required":["included","max"]},"sources":{"type":"object","properties":{"max":{"type":"integer","nullable":true,"minimum":0}},"required":["max"]},"adds":{"anyOf":[{"type":"string","enum":["*"]},{"type":"array","items":{"anyOf":[{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},{"type":"string","enum":["connector:*","channel:*","agent:*","capability:*","auth-provider:*","tenant-integration:*","model-provider:*"]}]}}]},"modules":{"anyOf":[{"type":"string","enum":["*"]},{"type":"array","items":{"anyOf":[{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},{"type":"string","enum":["connector:*","channel:*","agent:*","capability:*","auth-provider:*","tenant-integration:*","model-provider:*"]}]}}]}},"required":["id","order","monthlyCredits","users","sources","adds","modules"]}},"profiles":{"type":"object","additionalProperties":{"anyOf":[{"type":"string","enum":["*"]},{"type":"array","items":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"}}]}}},"required":["plans","profiles"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/module-requests":{"get":{"tags":["catalog"],"summary":"Module requests of every organization, newest first (super_admin)","parameters":[{"schema":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"required":false,"name":"status","in":"query"}],"responses":{"200":{"description":"Requests.","content":{"application/json":{"schema":{"type":"object","properties":{"requests":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]}}},"required":["requests"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/module-requests/{requestId}/decide":{"post":{"tags":["catalog"],"summary":"Approve or reject a module request (super_admin; two-step)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"requestId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"decision":{"type":"string","enum":["approve","reject"]},"note":{"type":"string","maxLength":1000},"enableFlag":{"type":"boolean"},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["decision"]}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"boolean","enum":[true]},"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]},"decision":{"type":"string","enum":["approve","reject"]},"flagOff":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"needsFlag":{"type":"boolean"},"expectedVersion":{"type":"integer","minimum":0}},"required":["preview","request","decision","needsFlag","expectedVersion"]},{"type":"object","properties":{"preview":{"type":"boolean","enum":[false]},"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]},"grant":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"active":{"type":"boolean"},"requestId":{"type":"string","minLength":1,"maxLength":128},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","orgId","active","updatedBy","updatedAt","version"]}},"required":["preview","request"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/entitlements/{kind}/{id}":{"put":{"tags":["catalog"],"summary":"Grant or revoke a module for one organization beyond its plan (super_admin)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"active":{"type":"boolean"},"reason":{"type":"string","minLength":1,"maxLength":500},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["active","reason"]}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"boolean","enum":[true]},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"current":{"type":"object","properties":{"active":{"type":"boolean"},"version":{"type":"integer","minimum":0}},"required":["active","version"]},"next":{"type":"object","properties":{"active":{"type":"boolean"}},"required":["active"]},"before":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"after":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]},"expectedVersion":{"type":"integer","minimum":0}},"required":["preview","ref","orgId","current","next","before","after","expectedVersion"]},{"type":"object","properties":{"preview":{"type":"boolean","enum":[false]},"grant":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"active":{"type":"boolean"},"requestId":{"type":"string","minLength":1,"maxLength":128},"reason":{"type":"string","maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","orgId","active","updatedBy","updatedAt","version"]},"entitlement":{"type":"object","properties":{"entitled":{"type":"boolean"},"source":{"type":"string","enum":["unrestricted","unmanaged","plan","profile","grant","none"]},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"minPlan":{"type":"string","enum":["solo","team","company","enterprise"]}},"required":["entitled","source","plan"]}},"required":["preview","grant","entitlement"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/catalog/{kind}/{id}/request":{"post":{"tags":["catalog"],"summary":"Ask WizBI for a module the organization's plan does not include (org_admin)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","maxLength":1000}}}}}},"responses":{"200":{"description":"The request (an open one for the same module is returned as is).","content":{"application/json":{"schema":{"type":"object","properties":{"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]},"created":{"type":"boolean"}},"required":["request","created"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/module-requests":{"get":{"tags":["catalog"],"summary":"The organization's module requests, newest first (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Requests.","content":{"application/json":{"schema":{"type":"object","properties":{"requests":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]}}},"required":["requests"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/module-requests/{requestId}/cancel":{"post":{"tags":["catalog"],"summary":"Withdraw an open module request (org_admin)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"requestId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Cancelled.","content":{"application/json":{"schema":{"type":"object","properties":{"request":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":128},"orgId":{"type":"string","minLength":1,"maxLength":128},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"status":{"type":"string","enum":["pending","approved","rejected","cancelled"]},"note":{"type":"string","maxLength":1000},"requestedBy":{"type":"string","minLength":1,"maxLength":128},"requestedByEmail":{"type":"string","maxLength":320},"requestedAt":{"type":"string","format":"date-time"},"plan":{"type":"string","nullable":true,"enum":["solo","team","company","enterprise",null]},"decidedBy":{"type":"string","minLength":1,"maxLength":128},"decidedAt":{"type":"string","format":"date-time"},"decisionNote":{"type":"string","maxLength":1000},"flagEnabled":{"type":"string","pattern":"^(console|canary|capability|module)\\.[a-z0-9][a-z0-9_-]{0,62}$"},"version":{"type":"integer","minimum":0}},"required":["id","orgId","ref","status","requestedBy","requestedAt","plan","version"]}},"required":["request"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/catalog/{kind}/{id}/audience":{"put":{"tags":["catalog"],"summary":"The groups and rooms a module is blocked for (org_admin; two-step)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":500},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["blockedGroups","blockedRooms"]}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"boolean","enum":[true]},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"current":{"type":"object","properties":{"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"version":{"type":"integer","minimum":0}},"required":["blockedGroups","blockedRooms","version"]},"next":{"type":"object","properties":{"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128}}},"required":["blockedGroups","blockedRooms"]},"changed":{"type":"boolean"},"expectedVersion":{"type":"integer","minimum":0}},"required":["preview","ref","current","next","changed","expectedVersion"]},{"type":"object","properties":{"preview":{"type":"boolean","enum":[false]},"audience":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"orgId":{"type":"string","minLength":1,"maxLength":128},"blockedGroups":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":200,"default":[]},"blockedRooms":{"type":"array","items":{"type":"string","minLength":1,"maxLength":128},"maxItems":500,"default":[]},"updatedBy":{"type":"string","minLength":1,"maxLength":128},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","orgId","updatedBy","updatedAt","version"]}},"required":["preview","audience"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/catalog/{kind}/{id}/lifecycle":{"get":{"tags":["catalog"],"summary":"The lifecycle of one module: in force, manifest, platform override (super_admin)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Lifecycle.","content":{"application/json":{"schema":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"inForce":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"source":{"type":"string","enum":["manifest","override"]},"manifest":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"override":{"type":"object","nullable":true,"properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"lifecycle":{"type":"object","nullable":true,"properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"reason":{"type":"string","minLength":1,"maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":200},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","lifecycle","reason","updatedBy","updatedAt","version"]},"version":{"type":"string"},"minCoreVersion":{"type":"string"},"breakingChanges":{"type":"array","items":{"type":"object","properties":{"version":{"type":"string","pattern":"^\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?$"},"upgradeDeadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"migrationDocs":{"type":"string","minLength":1,"maxLength":200}},"required":["version","upgradeDeadline","message"]}}},"required":["ref","inForce","source","manifest","override","version","minCoreVersion","breakingChanges"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["catalog"],"summary":"Deprecate, sunset or restore a module on this deployment (super_admin; two-step)","parameters":[{"schema":{"type":"string","enum":["connector","channel","agent","capability","auth-provider","tenant-integration","model-provider"]},"required":true,"name":"kind","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"lifecycle":{"type":"object","nullable":true,"properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"reason":{"type":"string","minLength":1,"maxLength":500},"confirm":{"type":"boolean","default":false},"expectedVersion":{"type":"integer","minimum":0}},"required":["lifecycle","reason"]}}}},"responses":{"200":{"description":"Preview (no confirm) or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"current":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"next":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"source":{"type":"string","enum":["manifest","override"]},"newInstancesBlocked":{"type":"boolean"},"instances":{"type":"integer","minimum":0},"orgs":{"type":"integer","minimum":0},"expectedVersion":{"type":"integer","minimum":0}},"required":["ref","current","next","source","newInstancesBlocked","instances","orgs","expectedVersion"]},{"type":"object","properties":{"override":{"type":"object","properties":{"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"lifecycle":{"type":"object","nullable":true,"properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]},"reason":{"type":"string","minLength":1,"maxLength":500},"updatedBy":{"type":"string","minLength":1,"maxLength":200},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","minimum":0}},"required":["ref","lifecycle","reason","updatedBy","updatedAt","version"]},"inForce":{"type":"object","properties":{"stage":{"type":"string","enum":["active","deprecated","sunset"]},"deprecatedAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"sunsetAt":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"notice":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]}},"required":["stage"]}},"required":["override","inForce"]}]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/catalog/lifecycle/run":{"post":{"tags":["catalog"],"summary":"Run the daily lifecycle check now (super_admin; `asOf` in QA and local only)","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"asOf":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"dryRun":{"type":"boolean","default":false},"orgId":{"type":"string","minLength":1}}}}}},"responses":{"200":{"description":"What the check found.","content":{"application/json":{"schema":{"type":"object","properties":{"asOf":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"dryRun":{"type":"boolean"},"modules":{"type":"integer","minimum":0},"instances":{"type":"integer","minimum":0},"secretsChecked":{"type":"integer","minimum":0},"notices":{"type":"object","properties":{"open":{"type":"integer","minimum":0},"created":{"type":"integer","minimum":0},"refreshed":{"type":"integer","minimum":0},"resolved":{"type":"integer","minimum":0}},"required":["open","created","refreshed","resolved"]},"findings":{"type":"array","items":{"type":"object","properties":{"ref":{"type":"string"},"secret":{"type":"string"},"scope":{"type":"string","enum":["instance","platform"]},"state":{"type":"string","enum":["due_soon","overdue","unknown","missing"]},"orgId":{"type":"string"},"instanceId":{"type":"string"},"dueAt":{"type":"string"},"ageDays":{"type":"integer"},"rotationDays":{"type":"integer"}},"required":["ref","secret","scope","state"]}}},"required":["asOf","dryRun","modules","instances","secretsChecked","notices","findings"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/module-notices":{"get":{"tags":["catalog"],"summary":"What the organization's admins are told about retiring modules and secrets","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["0","1"]},"required":false,"name":"all","in":"query"}],"responses":{"200":{"description":"Notices.","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string","minLength":1,"maxLength":128},"notices":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z_]+~[a-z]+:[a-z0-9_-]+(?:~[A-Za-z0-9_.-]+)?$"},"orgId":{"type":"string","minLength":1},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["deprecated","sunset","upgrade","secret_rotation","secret_missing"]},"severity":{"type":"string","enum":["info","warning","critical"]},"instances":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","maxLength":200}},"required":["id"]},"maxItems":200},"deadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"secret":{"type":"string","maxLength":100},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"open":{"type":"boolean"},"firstSeenAt":{"type":"string","format":"date-time"},"lastSeenAt":{"type":"string","format":"date-time"},"resolvedAt":{"type":"string","format":"date-time"},"acknowledgedAt":{"type":"string","format":"date-time"},"acknowledgedBy":{"type":"string","minLength":1}},"required":["id","orgId","ref","kind","severity","instances","open","firstSeenAt","lastSeenAt"]}},"modules":{"type":"object","additionalProperties":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"default":{}}},"required":["orgId","notices"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/module-notices/{id}/ack":{"post":{"tags":["catalog"],"summary":"Mark a notice as seen (it stays until the condition is resolved)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":300},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Acknowledged.","content":{"application/json":{"schema":{"type":"object","properties":{"notice":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z_]+~[a-z]+:[a-z0-9_-]+(?:~[A-Za-z0-9_.-]+)?$"},"orgId":{"type":"string","minLength":1},"ref":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"kind":{"type":"string","enum":["deprecated","sunset","upgrade","secret_rotation","secret_missing"]},"severity":{"type":"string","enum":["info","warning","critical"]},"instances":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","maxLength":200}},"required":["id"]},"maxItems":200},"deadline":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"replacedBy":{"type":"string","pattern":"^(connector|channel|agent|capability|auth-provider|tenant-integration|model-provider):([a-z0-9](?:[a-z0-9_-]{0,62}[a-z0-9])?)$"},"secret":{"type":"string","maxLength":100},"message":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"required":["he","en","pt"]},"open":{"type":"boolean"},"firstSeenAt":{"type":"string","format":"date-time"},"lastSeenAt":{"type":"string","format":"date-time"},"resolvedAt":{"type":"string","format":"date-time"},"acknowledgedAt":{"type":"string","format":"date-time"},"acknowledgedBy":{"type":"string","minLength":1}},"required":["id","orgId","ref","kind","severity","instances","open","firstSeenAt","lastSeenAt"]}},"required":["notice"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the feature is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown agent or version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Stale version.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/library":{"get":{"tags":["library"],"summary":"The synced library catalog with the number of organizations that attached each item","responses":{"200":{"description":"The catalog.","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"kind":{"type":"string","enum":["dataset","mcp","hybrid"]},"status":{"type":"string","enum":["draft","beta","live","deprecated"]},"version":{"type":"integer","minimum":1,"default":1},"category":{"type":"string"},"icon":{"type":"string"},"title":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"summary":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"publisher":{"type":"array","items":{"type":"object","properties":{"name":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"url":{"type":"string"}},"required":["name"],"additionalProperties":{"nullable":true}},"default":[]},"license":{"type":"object","properties":{"name":{"type":"string"},"attribution":{"type":"string"},"commercial_use":{"type":"string","enum":["yes","no","unverified"]},"notes":{"type":"string"}},"required":["name","commercial_use"],"additionalProperties":{"nullable":true}},"pii":{"type":"object","properties":{"level":{"type":"string"},"notes":{"type":"string"}},"required":["level"],"additionalProperties":{"nullable":true}},"dataset":{"type":"string","nullable":true,"pattern":"^lib_[a-z0-9_]+$"},"refresh":{"type":"object","properties":{"mode":{"type":"string","enum":["scheduled","manual","frozen","live"]},"cadence":{"type":"string"},"sla_hours":{"type":"number"},"frozen_reason":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}}},"required":["mode"],"additionalProperties":{"nullable":true}},"coverage":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"notes":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}}},"additionalProperties":{"nullable":true}},"what_updates":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"join_keys":{"type":"array","items":{"type":"string"},"default":[]},"sample_questions":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"default":{}},"org_value":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"known_issues":{"type":"array","items":{"type":"string"},"default":[]},"options":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"default":[]},"pricing":{"type":"object","properties":{"subscription_credits_month":{"type":"number","minimum":0},"query":{"type":"string","enum":["cogs","free"]},"phase":{"type":"string"}},"required":["subscription_credits_month","query"],"additionalProperties":{"nullable":true}},"objects":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"sourceType":{"type":"string"}},"required":["name"]},"default":[]},"freshness":{"type":"object","properties":{"status":{"type":"string","enum":["ok","late","missing","manual","frozen","live","unknown"]},"lastModified":{"type":"string","nullable":true},"ageHours":{"type":"number","nullable":true},"checkedAt":{"type":"string","nullable":true}},"default":{"status":"unknown"},"required":["status"]},"syncedAt":{"type":"string"},"attachedOrgs":{"type":"integer","minimum":0}},"required":["id","kind","status","category","title","summary","license","pii","dataset","refresh","pricing","attachedOrgs"]}}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/library/sync":{"post":{"tags":["library"],"summary":"Copy the library catalog (`_meta`) into Core (super_admin)","description":"Reads items, objects and the latest freshness snapshot of the library project as the runtime identity and upserts `platform_library/{itemId}`. Items that do not validate and items no longer published are reported, never deleted.","responses":{"200":{"description":"What the sync did.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"read":{"type":"integer","minimum":0},"written":{"type":"integer","minimum":0},"items":{"type":"integer","minimum":0},"objects":{"type":"integer","minimum":0},"invalid":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"error":{"type":"string"}},"required":["id","error"]}},"stale":{"type":"array","items":{"type":"string"}},"syncedAt":{"type":"string"}},"required":["ok","read","written","items","invalid","stale","syncedAt"]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/library":{"get":{"tags":["library"],"summary":"The public data library as the caller sees it (every member)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The catalog, attached and visible flags.","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"canManage":{"type":"boolean"},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"kind":{"type":"string","enum":["dataset","mcp","hybrid"]},"status":{"type":"string","enum":["draft","beta","live","deprecated"]},"version":{"type":"integer","minimum":1,"default":1},"category":{"type":"string"},"icon":{"type":"string"},"title":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"summary":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"publisher":{"type":"array","items":{"type":"object","properties":{"name":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"url":{"type":"string"}},"required":["name"],"additionalProperties":{"nullable":true}},"default":[]},"license":{"type":"object","properties":{"name":{"type":"string"},"attribution":{"type":"string"},"commercial_use":{"type":"string","enum":["yes","no","unverified"]},"notes":{"type":"string"}},"required":["name","commercial_use"],"additionalProperties":{"nullable":true}},"pii":{"type":"object","properties":{"level":{"type":"string"},"notes":{"type":"string"}},"required":["level"],"additionalProperties":{"nullable":true}},"dataset":{"type":"string","nullable":true,"pattern":"^lib_[a-z0-9_]+$"},"refresh":{"type":"object","properties":{"mode":{"type":"string","enum":["scheduled","manual","frozen","live"]},"cadence":{"type":"string"},"sla_hours":{"type":"number"},"frozen_reason":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}}},"required":["mode"],"additionalProperties":{"nullable":true}},"coverage":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"notes":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}}},"additionalProperties":{"nullable":true}},"what_updates":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"join_keys":{"type":"array","items":{"type":"string"},"default":[]},"sample_questions":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}},"default":{}},"org_value":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"known_issues":{"type":"array","items":{"type":"string"},"default":[]},"options":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}},"default":[]},"objects":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"sourceType":{"type":"string"}},"required":["name"]},"default":[]},"freshness":{"type":"object","properties":{"status":{"type":"string","enum":["ok","late","missing","manual","frozen","live","unknown"]},"lastModified":{"type":"string","nullable":true},"ageHours":{"type":"number","nullable":true},"checkedAt":{"type":"string","nullable":true}},"default":{"status":"unknown"},"required":["status"]},"syncedAt":{"type":"string"},"attached":{"type":"boolean"},"connectorId":{"type":"string","nullable":true},"visibleToMe":{"type":"boolean"},"sharedWith":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"required":["id","name"]},"default":[]},"pendingRequests":{"type":"integer","minimum":0},"optionValues":{"type":"object","additionalProperties":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}},"default":{}}},"required":["id","kind","status","category","title","summary","license","pii","dataset","refresh","attached","connectorId","visibleToMe"]}}},"required":["enabled","canManage","items"]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/library/{itemId}/details":{"get":{"tags":["library"],"summary":"An item’s advanced details for the organization’s data people (org_admin)","description":"Where the data comes from and how to cite it, its licence, privacy level and known limitations, the dataset to query (`lib_<domain>`), its join keys, and every table and view with its fields (type, description, up to three example values). org_admin / super_admin only (403 `org_admin_required`); behind `canary.public_library` (403 `feature_disabled`). No identities, connector ids, internal project paths or pricing.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":120,"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"required":true,"name":"itemId","in":"path"}],"responses":{"200":{"description":"The item’s advanced details.","content":{"application/json":{"schema":{"type":"object","properties":{"itemId":{"type":"string"},"dataset":{"type":"string","nullable":true},"about":{"type":"object","properties":{"publishers":{"type":"array","items":{"type":"object","properties":{"name":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"url":{"type":"string"}},"required":["name"]},"default":[]},"attribution":{"type":"string"},"licenseName":{"type":"string"},"commercialUse":{"type":"string","enum":["yes","no","unverified"]},"cadence":{"type":"string"},"refreshMode":{"type":"string","enum":["scheduled","manual","frozen","live"]},"frozenReason":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"coverage":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"},"notes":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}}}},"whatUpdates":{"type":"object","properties":{"he":{"type":"string"},"en":{"type":"string"},"pt":{"type":"string"}},"required":["he"],"additionalProperties":{"nullable":true}},"privacyLevel":{"type":"string"},"privacyNote":{"type":"string"},"knownIssues":{"type":"array","items":{"type":"string"},"default":[]}},"required":["refreshMode"]},"joinKeys":{"type":"array","items":{"type":"string"},"default":[]},"objects":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"kind":{"type":"string","enum":["table","view"]},"description":{"type":"string","nullable":true},"rowCount":{"type":"integer","nullable":true,"minimum":0},"columns":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"description":{"type":"string","default":""},"samples":{"type":"array","items":{"type":"string"},"default":[]}},"required":["name","type"]},"default":[]}},"required":["name","kind","description","rowCount"]},"default":[]}},"required":["itemId","dataset","about"]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/library/{itemId}":{"post":{"tags":["library"],"summary":"Attach a library item to the organization (two-step; org_admin to apply)","description":"Without `confirm` answers the preview. With `confirm: true` (org_admin / super_admin) creates the `library` connector record and grants the organization’s own service account READER on the linked dataset; idempotent. Only admins see the item until it is shared with groups.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":120,"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"required":true,"name":"itemId","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LibraryConfirm"}}}},"responses":{"200":{"description":"Preview, or the attached item.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["attach","detach"]},"itemId":{"type":"string"},"dataset":{"type":"string","nullable":true},"identity":{"type":"string","nullable":true},"already":{"type":"boolean"},"visibleTo":{"type":"string","enum":["admins","unchanged"]}},"required":["action","itemId","dataset","identity","already","visibleTo"]}},"required":["preview"]},{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"itemId":{"type":"string"},"connectorId":{"type":"string","nullable":true},"attached":{"type":"boolean"}},"required":["ok","itemId","connectorId","attached"]}]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["library"],"summary":"Detach a library item (two-step; org_admin to apply)","description":"Without confirmation answers the preview. With `?confirm=true` (or `{confirm: true}`) removes the READER grant, the group shares of the record and the record itself.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":120,"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"required":true,"name":"itemId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"confirm","in":"query"}],"responses":{"200":{"description":"Preview, or the detached item.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["attach","detach"]},"itemId":{"type":"string"},"dataset":{"type":"string","nullable":true},"identity":{"type":"string","nullable":true},"already":{"type":"boolean"},"visibleTo":{"type":"string","enum":["admins","unchanged"]}},"required":["action","itemId","dataset","identity","already","visibleTo"]}},"required":["preview"]},{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"itemId":{"type":"string"},"connectorId":{"type":"string","nullable":true},"attached":{"type":"boolean"}},"required":["ok","itemId","connectorId","attached"]}]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/library/{itemId}/options/{key}/choices":{"get":{"tags":["library"],"summary":"Search the choices of an attached item’s option, e.g. companies to watch (org_admin)","description":"Up to 50 rows of the option’s `options_source` view matching `q` (label contains, value starts with), read as the organization’s own identity. org_admin / super_admin; 409 `library_not_attached` before attaching.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":120,"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"required":true,"name":"itemId","in":"path"},{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"required":true,"name":"key","in":"path"},{"schema":{"type":"string","maxLength":100},"required":false,"name":"q","in":"query"}],"responses":{"200":{"description":"Matching choices.","content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}}},"required":["key","choices"]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The item is not attached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/library/{itemId}/options":{"put":{"tags":["library"],"summary":"Set an attached item’s option for the organization, e.g. its watchlist (two-step; org_admin)","description":"Replaces the values of one option. Without `confirm` answers the preview (before, after, added, removed); with `confirm: true` saves them on the organization’s `library` record and audits `library.options_set`. The agent sees them as exact filters in its data knowledge.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","maxLength":120,"pattern":"^[a-z0-9]+(-[a-z0-9]+)*$"},"required":true,"name":"itemId","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LibraryOptionsBody"}}}},"responses":{"200":{"description":"Preview, or the saved values.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"type":"object","properties":{"action":{"type":"string","enum":["set_options"]},"itemId":{"type":"string"},"key":{"type":"string"},"before":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}},"after":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}},"added":{"type":"array","items":{"type":"string"}},"removed":{"type":"array","items":{"type":"string"}}},"required":["action","itemId","key","before","after","added","removed"]}},"required":["preview"]},{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"itemId":{"type":"string"},"key":{"type":"string"},"values":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}}},"required":["ok","itemId","key","values"]}]}}}},"400":{"description":"Invalid request, or the item has no dataset.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or the library is off for the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown item.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The item is not attached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The dataset grant could not be written.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The organization has no data identity yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/feed-bi/access":{"get":{"tags":["feed-bi"],"summary":"May the caller open Feed BI here (WizBI staff, or a listed viewer on an org with it on)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Open.","content":{"application/json":{"schema":{"type":"object","properties":{"open":{"type":"boolean","enum":[true]},"staff":{"type":"boolean"}},"required":["open","staff"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/feed-bi/feed":{"get":{"tags":["feed-bi"],"summary":"One lane of the feed for the caller: for_you (ranked, finite) · saved · mine · rooms · org","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["for_you","saved","mine","rooms","org"]},"required":false,"name":"lane","in":"query"},{"schema":{"type":"string","maxLength":60},"required":false,"name":"tag","in":"query"}],"responses":{"200":{"description":"The lane.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiFeed"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/feed-bi/cards/{id}":{"get":{"tags":["feed-bi"],"summary":"A card, the caller’s state with it, and — for whoever may manage it — who engaged","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The card.","content":{"application/json":{"schema":{"type":"object","properties":{"card":{"$ref":"#/components/schemas/BiCard"},"state":{"$ref":"#/components/schemas/BiViewerState"},"manage":{"type":"boolean"},"engagers":{"type":"array","items":{"$ref":"#/components/schemas/BiEngager"}}},"required":["card","state","manage"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["feed-bi"],"summary":"Soft-delete a card (kept for WizBI staff; producer, org admin or staff)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"card":{"$ref":"#/components/schemas/BiCard"}},"required":["card"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/feed-bi/cards":{"post":{"tags":["feed-bi"],"summary":"Publish a card — a person’s own, or (admins / staff) the org’s, a room’s or a producer’s","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiCardInput"}}}},"responses":{"201":{"description":"Published.","content":{"application/json":{"schema":{"type":"object","properties":{"card":{"$ref":"#/components/schemas/BiCard"}},"required":["card"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/feed-bi/cards/{id}/events":{"post":{"tags":["feed-bi"],"summary":"Record what the caller did with a card (impression, view, dwell, react, save, share, ask, dismiss, wrong…)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiEventsBody"}}}},"responses":{"200":{"description":"Recorded.","content":{"application/json":{"schema":{"type":"object","properties":{"state":{"$ref":"#/components/schemas/BiViewerState"},"stats":{"type":"object","properties":{"impressions":{"type":"integer","minimum":0,"default":0},"views":{"type":"integer","minimum":0,"default":0},"uniqueViewers":{"type":"integer","minimum":0,"default":0},"dwellMs":{"type":"integer","minimum":0,"default":0},"reactions":{"type":"object","properties":{"like":{"type":"integer","minimum":0},"important":{"type":"integer","minimum":0},"unsure":{"type":"integer","minimum":0},"handled":{"type":"integer","minimum":0}},"default":{}},"saves":{"type":"integer","minimum":0,"default":0},"pins":{"type":"integer","minimum":0,"default":0},"follows":{"type":"integer","minimum":0,"default":0},"asks":{"type":"integer","minimum":0,"default":0},"deepDives":{"type":"integer","minimum":0,"default":0},"remixes":{"type":"integer","minimum":0,"default":0},"shares":{"type":"object","properties":{"whatsapp":{"type":"integer","minimum":0},"link":{"type":"integer","minimum":0},"person":{"type":"integer","minimum":0},"room":{"type":"integer","minimum":0},"public":{"type":"integer","minimum":0}},"default":{}},"publicViews":{"type":"integer","minimum":0,"default":0},"dismisses":{"type":"integer","minimum":0,"default":0},"disputes":{"type":"integer","minimum":0,"default":0},"edits":{"type":"integer","minimum":0,"default":0},"lastViewedAt":{"type":"string","format":"date-time"}}},"recorded":{"type":"integer"}},"required":["state","stats","recorded"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or Feed BI is closed for this person or organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown card (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/dashboards":{"get":{"tags":["dashboards"],"summary":"The dashboards the caller may see: mine · shared with me · the organization’s","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["mine","shared","org"]},"required":false,"name":"scope","in":"query"}],"responses":{"200":{"description":"The list.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboards":{"type":"array","items":{"$ref":"#/components/schemas/BiDashboard"}}},"required":["dashboards"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["dashboards"],"summary":"Publish a dashboard — an HTML page, or a live page with named reads (org admin, staff)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiDashboardInput"}}}},"responses":{"201":{"description":"Published.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboard":{"$ref":"#/components/schemas/BiDashboard"}},"required":["dashboard"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/dashboards/{id}":{"get":{"tags":["dashboards"],"summary":"One dashboard (its page is read separately)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"It.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboard":{"$ref":"#/components/schemas/BiDashboard"},"cards":{"type":"array","items":{"nullable":true}}},"required":["dashboard","cards"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["dashboards"],"summary":"Change a dashboard’s title, audience, official mark or cache (who may manage it)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiDashboardPatch"}}}},"responses":{"200":{"description":"Changed.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboard":{"$ref":"#/components/schemas/BiDashboard"}},"required":["dashboard"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["dashboards"],"summary":"Soft-delete a dashboard (kept for WizBI staff)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboard":{"$ref":"#/components/schemas/BiDashboard"}},"required":["dashboard"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/dashboards/{id}/page":{"put":{"tags":["dashboards"],"summary":"A new version of the page (and of a live page’s reads); older versions are kept","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiDashboardPageBody"}}}},"responses":{"200":{"description":"The new version.","content":{"application/json":{"schema":{"type":"object","properties":{"dashboard":{"$ref":"#/components/schemas/BiDashboard"}},"required":["dashboard"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["dashboards"],"summary":"The page to show — the current version, or an older one for whoever manages it","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":0,"exclusiveMinimum":true},"required":false,"name":"version","in":"query"}],"responses":{"200":{"description":"The page.","content":{"application/json":{"schema":{"type":"object","properties":{"html":{"type":"string"},"version":{"type":"integer"},"kind":{"type":"string","enum":["board","html","live"]}},"required":["html","version","kind"]}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/dashboards/{id}/data":{"post":{"tags":["dashboards"],"summary":"Run a live page’s reads AS THE CALLER (their tools and access, read grade only), cached per viewer","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"force":{"type":"boolean"},"version":{"type":"integer","minimum":0,"exclusiveMinimum":true}}}}}},"responses":{"200":{"description":"The results.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BiLiveData"}}}},"400":{"description":"Invalid request.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not allowed, or dashboards are closed for this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown dashboard (or one the reader may not see).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/connectors/remote":{"get":{"tags":["connectors"],"summary":"The remote connector types synced from the connectors plane (super_admin)","responses":{"200":{"description":"The synced types.","content":{"application/json":{"schema":{"type":"object","properties":{"types":{"type":"array","items":{"$ref":"#/components/schemas/RemoteConnectorRow"}}},"required":["types"]}}}},"400":{"description":"Invalid request, or the card does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown remote connector type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The plane service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/connectors/remote/sync":{"post":{"tags":["connectors"],"summary":"Read one connector card from a plane service into the catalog (super_admin)","description":"Calls the service as the runtime identity: `/health`, `<endpoint>/manifest` (a v2 module with its tools), the logo (checked: a small inert SVG) and the skill. Stores a new version in `platform_connectors/{id}` and registers the type as a connector and a module (defaults from its manifest). A card named like a built-in type is refused.","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoteConnectorSync"}}}},"responses":{"200":{"description":"The synced type.","content":{"application/json":{"schema":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/RemoteConnectorRow"}},"required":["type"]}}}},"400":{"description":"Invalid request, or the card does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown remote connector type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The plane service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/connectors/remote/{id}":{"put":{"tags":["connectors"],"summary":"Switch one remote connector type on or off for the whole platform (super_admin)","parameters":[{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"]}}}},"responses":{"200":{"description":"The type after the switch.","content":{"application/json":{"schema":{"type":"object","properties":{"type":{"$ref":"#/components/schemas/RemoteConnectorRow"}},"required":["type"]}}}},"400":{"description":"Invalid request, or the card does not validate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown remote connector type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The plane service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/connector-planes":{"get":{"tags":["connectors"],"summary":"An org's dedicated connector planes (super_admin)","parameters":[{"schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The planes.","content":{"application/json":{"schema":{"type":"object","properties":{"orgId":{"type":"string"},"planes":{"type":"array","items":{"$ref":"#/components/schemas/ConnectorPlaneRow"}}},"required":["orgId","planes"]}}}},"400":{"description":"Invalid plane (not https, not a deterministic run.app URL, wrong env).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown organization, or the card is not in the catalog.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/connector-planes/{cardId}":{"put":{"tags":["connectors"],"summary":"Point one org's card at a dedicated plane (super_admin; preview, then confirm)","description":"The same catalog card, served by the org’s own plane (a customer GCP project). New connections of this card are stamped with the plane; with `secrets: customer` the setup form asks for no secret and Core sends none (`x-wizbi-connection-id` only). Existing connections keep their plane.","parameters":[{"schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"required":true,"name":"cardId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConnectorPlaneSet"}}}},"responses":{"200":{"description":"Preview (confirm=false) or applied.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid plane (not https, not a deterministic run.app URL, wrong env).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown organization, or the card is not in the catalog.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["connectors"],"summary":"Send one org's card back to the catalog's plane (super_admin; preview, then confirm)","parameters":[{"schema":{"type":"string","pattern":"^[A-Za-z0-9_-]{1,128}$"},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"required":true,"name":"cardId","in":"path"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Preview (confirm=false) or applied.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid plane (not https, not a deterministic run.app URL, wrong env).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"super_admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown organization, or the card is not in the catalog.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/resources":{"get":{"tags":["connectors"],"summary":"One level of a remote connection’s resources tree (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"required":true,"name":"level","in":"query"},{"schema":{"type":"string","maxLength":256},"required":false,"name":"parent","in":"query"}],"responses":{"200":{"description":"The items of that level.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":256},"name":{"type":"string","minLength":1,"maxLength":300},"badges":{"type":"object","additionalProperties":{"anyOf":[{"type":"string","maxLength":80},{"type":"number"}]}},"hasChildren":{"type":"boolean"}},"required":["id","name"]},"maxItems":5000},"truncated":{"type":"boolean"}},"required":["items"]}}}},"400":{"description":"Invalid request, or the card declares no such level, field or tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown connection, or not a remote connector.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The connector service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/options/{field}":{"get":{"tags":["connectors"],"summary":"The choices of one setup field, loaded from the source (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","pattern":"^[a-zA-Z][a-zA-Z0-9_]{0,63}$"},"required":true,"name":"field","in":"path"}],"responses":{"200":{"description":"The choices.","content":{"application/json":{"schema":{"type":"object","properties":{"options":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string","minLength":1,"maxLength":256},"label":{"type":"string","minLength":1,"maxLength":300}},"required":["value","label"]},"maxItems":2000}},"required":["options"]}}}},"400":{"description":"Invalid request, or the card declares no such level, field or tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown connection, or not a remote connector.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The connector service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/resources/selection":{"put":{"tags":["connectors"],"summary":"Save what a remote connection copies — before its first sync (org_admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"resources":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":5000},"default":{}},"newResources":{"type":"string","enum":["ask","include","ignore"]}}}}}},"responses":{"200":{"description":"The saved selection.","content":{"application/json":{"schema":{"type":"object","properties":{"selection":{"type":"object","properties":{"resources":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string","minLength":1,"maxLength":256},"maxItems":5000},"default":{}},"newResources":{"type":"string","enum":["ask","include","ignore"]}}}},"required":["selection"]}}}},"400":{"description":"Invalid request, or the card declares no such level, field or tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown connection, or not a remote connector.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The connector service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/identity":{"put":{"tags":["connectors"],"summary":"Say what the credential is: a dedicated service user, or a personal token (temporary)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["service_user","personal_temporary"]}},"required":["kind"]}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"identityKind":{"type":"string"}},"required":["identityKind"]}}}},"400":{"description":"Invalid request, or the card declares no such level, field or tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown connection, or not a remote connector.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The connector service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/{id}/actions/{tool}":{"put":{"tags":["connectors"],"summary":"Switch one write action of a remote connection on or off (org_admin)","description":"Write actions are off by default and switched on one by one (Omer, 18/10). Only a tool the card declares with a write grade can be switched; every call of it still asks for confirmation in the conversation.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$"},"required":true,"name":"tool","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"}},"required":["enabled"]}}}},"responses":{"200":{"description":"The actions now on.","content":{"application/json":{"schema":{"type":"object","properties":{"enabledActions":{"type":"array","items":{"type":"string"}}},"required":["enabledActions"]}}}},"400":{"description":"Invalid request, or the card declares no such level, field or tool.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown connection, or not a remote connector.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"The connector service did not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/connectors/oauth/start":{"post":{"tags":["connectors"],"summary":"Start connecting a remote connector with OAuth: the vendor’s consent link (org_admin)","description":"For a remote type whose card authenticates with the authorization code (`oauth2_code`). Answers the vendor’s authorize URL (valid 10 minutes, once); open it in the same browser tab. The vendor sends the browser back to the callback, which stores the token set in the organization’s secret store and lands on the console. `connectorId` reconnects an existing connection.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","pattern":"^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$"},"connectorId":{"type":"string","minLength":1,"maxLength":128},"name":{"type":"string","minLength":1,"maxLength":120}},"required":["type"]}}}},"responses":{"200":{"description":"The consent link.","content":{"application/json":{"schema":{"type":"object","properties":{"authorizeUrl":{"type":"string","format":"uri"},"expiresAt":{"type":"string","format":"date-time"}},"required":["authorizeUrl","expiresAt"]}}}},"400":{"description":"Not an OAuth (authorization code) remote type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"No context.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not an admin of this organization, or OAuth is off here.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown type or connection.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The connector module is deprecated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"501":{"description":"WizBI’s app at this vendor is not configured in this environment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/connectors/oauth/callback":{"get":{"tags":["connectors"],"summary":"OAuth redirect of a remote connector (browser only): stores the token set and redirects to the console","parameters":[{"schema":{"type":"string","maxLength":256},"required":false,"name":"state","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"code","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"error","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"error_description","in":"query"}],"responses":{"302":{"description":"Back to the console with the outcome."}}}},"/api/me/security":{"get":{"tags":["security"],"summary":"Consent and second-factor state of this person and this sign-in session","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SecurityView"}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/consent":{"post":{"tags":["security"],"summary":"Accept the current Terms of Service and Privacy Policy (an append-only record: who, org, both versions, time, surface, user agent, locale — never the IP)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsentBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string","minLength":1,"maxLength":32},"acceptedAt":{"type":"string","format":"date-time"},"channel":{"type":"string","enum":["web","mcp","rest","whatsapp","whatsapp_web","telegram","sms","slack","teams","email","voice","scheduled"]},"method":{"type":"string","enum":["checkbox","continued_use"]},"termsVersion":{"type":"string","minLength":1,"maxLength":32},"privacyVersion":{"type":"string","minLength":1,"maxLength":32},"surface":{"type":"string","enum":["console","oauth_consent","org_admin","channel"]},"recordId":{"type":"string","maxLength":80}},"required":["version","acceptedAt","channel","method"]}}}},"409":{"description":"Not the current versions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/totp/start":{"post":{"tags":["security"],"summary":"Start TOTP enrolment: a new secret and its otpauth:// URI (render as QR)","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"secret":{"type":"string"},"otpauthUri":{"type":"string"}},"required":["secret","otpauthUri"]}}}},"403":{"description":"A factor is enrolled: pass it first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Second-factor storage is not configured.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/totp/confirm":{"post":{"tags":["security"],"summary":"Finish TOTP enrolment with the first code; answers the recovery codes once","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MfaCodeBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoveryCodes"}}}},"400":{"description":"Wrong code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A factor is enrolled: pass it first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/sms/enroll":{"post":{"tags":["security"],"summary":"Enrol the SMS fallback with a phone number proven by a fresh Firebase phone sign-in","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MfaPhoneProofBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoveryCodes"}}}},"400":{"description":"Invalid or stale phone proof.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"A factor is enrolled: pass it first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/verify":{"post":{"tags":["security"],"summary":"The step-up: pass the second factor for this sign-in session","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MfaStepUpBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"satisfied":{"type":"boolean","enum":[true]}},"required":["satisfied"]}}}},"400":{"description":"Wrong code, or SMS while signed in with the phone (`mfa_sms_same_factor`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No factor enrolled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Locked after too many wrong codes.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/recovery":{"post":{"tags":["security"],"summary":"Replace the recovery codes (this session must have passed the second factor)","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RecoveryCodes"}}}},"403":{"description":"Pass the second factor first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/mfa/{method}":{"delete":{"tags":["security"],"summary":"Remove a second factor (this session must have passed the second factor)","parameters":[{"schema":{"type":"string","enum":["totp","sms"]},"required":true,"name":"method","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"enrolled":{"type":"boolean"}},"required":["enrolled"]}}}},"403":{"description":"Pass it first.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/sessions/revoke":{"post":{"tags":["security"],"summary":"Sign out everywhere: revoke every session of this person (optionally its API tokens)","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeSessionsBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevokeSessionsResult"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/sessions":{"get":{"tags":["security"],"summary":"Where a member is signed in: their sign-in sessions (org_admin, or the member)","description":"One row per sign-in (a Firebase session), newest activity first: provider, channel, the first and latest client address, the device, and whether it is still valid. Pair with `POST …/sign-out` to end them all. API tokens are listed under `/tokens`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MemberSessions"}}}},"403":{"description":"Neither an org admin nor the member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/sign-out":{"post":{"tags":["security"],"summary":"An org admin signs a member out of every session (never a super admin)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"includeTokens":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"revokedSessions":{"type":"number"},"revokedTokens":{"type":"number"}},"required":["revokedSessions","revokedTokens"]}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/security/mfa-status":{"get":{"tags":["security"],"summary":"Who has a second factor (authenticator app / SMS) registered and when it last passed — admins first (org_admin)","description":"One row per active member: role, whether a factor is registered, which, since when, and the last time a second factor passed (`lastUsedAt`, null when never or before it was recorded). `admins` counts org admins and above — the platform asks every one of them for a second factor; `everyone` counts every member and is present only when the org policy is `all`. A person who passes with the org IdP (`trustIdp`) or with Identity Platform MFA has no factor here. The phone of an SMS factor is never returned. Reset one with `POST …/people/{principalId}/mfa/reset`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgMfaStatus"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/people/{principalId}/mfa/reset":{"post":{"tags":["security"],"summary":"Reset a member's second factor: remove it and its recovery codes, so the next sign-in registers a new one (two-step)","description":"For a person who lost their phone. `confirm: false` previews (who, which factors); `confirm: true` removes every factor, the recovery codes and the lock, and ends every step-up the person passed, so the next request that needs a second factor asks them to register again. An org admin resets a member (not an admin) whose home organization is this one; an org admin of this org, a super admin, or someone whose home is another organization only a WizBI super admin resets (ADR-0045: after an identity check). Audited as `people.mfa.reset`.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MfaResetBody"}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"anyOf":[{"type":"object","properties":{"preview":{"$ref":"#/components/schemas/MfaResetPreview"}},"required":["preview"]},{"type":"object","properties":{"applied":{"allOf":[{"$ref":"#/components/schemas/MfaResetPreview"},{"type":"object","properties":{"endedSessions":{"type":"integer"}},"required":["endedSessions"]}]}},"required":["applied"]}]}}}},"403":{"description":"Insufficient role, or the person is an admin / belongs to another organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not a member.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/security":{"get":{"tags":["security"],"summary":"The org security policy: second factor, IdP trust, accepted sign-in methods (per role), open sign-in, platform lock","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurity"}}}}}},"put":{"tags":["security"],"summary":"Set the org security policy (org_admin): who must pass a second factor, whether the org IdP counts as one, which sign-in methods are accepted","description":"Fields left out keep their value. `signIn.open` and `lockedBy` are the platform’s (super_admin, `PUT /api/admin/orgs/{orgId}/sign-in`). A restricted policy is refused with 409 `signin_policy_lockout` when a role has no usable method, or when it would refuse the method the saving admin is signed in with (unless the org SSO is enabled, verified and allowed). A locked policy answers 403. Super admins are never refused by the policy.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurityInput"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgSecurity"}}}},"400":{"description":"A method the platform does not offer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role, or the platform locked this policy.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The policy would lock people out (`signin_policy_lockout`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/legal":{"get":{"tags":["security"],"summary":"The org AI-interaction notice, the current Terms / Privacy versions and the acceptance on behalf of the org","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgLegal"}}}}}},"put":{"tags":["security"],"summary":"Set the org AI-interaction notice (org_admin): on/off, per-language text, links, repeat, existing conversations","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"aiDisclosure":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"text":{"type":"object","properties":{"he":{"type":"string","minLength":1,"maxLength":500},"en":{"type":"string","minLength":1,"maxLength":500},"pt":{"type":"string","minLength":1,"maxLength":500}},"default":{}},"notifyExisting":{"type":"boolean","default":false}}}},"required":["aiDisclosure"]}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgLegal"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/legal/acceptance":{"post":{"tags":["security"],"summary":"Accept the current Terms of Service and Privacy Policy on behalf of the organization (org_admin; an append-only `org` record)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgLegalAcceptBody"}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgLegal"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Not the current versions.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/legal/acceptances":{"get":{"tags":["security"],"summary":"Terms / Privacy acceptance records of this org: on its behalf and by its members (org_admin; newest first; no IP is kept)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LegalAcceptances"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/legal/acceptances":{"get":{"tags":["security"],"summary":"Every Terms / Privacy acceptance record, by org or by person (super_admin; newest first)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":500,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":false,"name":"principalId","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LegalAcceptances"}}}},"403":{"description":"Super admin only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sso":{"get":{"tags":["sso"],"summary":"The org identity provider, its domains, the SP details and the SCIM state","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SsoView"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["sso"],"summary":"Create or update the org identity provider: `preset: entra` = one click on the connected Microsoft 365 tenant, `preset: google_workspace` = one click on the connected Google Workspace (only accounts of its verified domains sign in) — nothing else needed; `oidc` / `saml` = the free-form fields (the OIDC secret is never stored)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"preset":{"type":"string","enum":["entra","google_workspace","oidc","saml"]},"protocol":{"type":"string","enum":["saml","oidc"]},"enabled":{"type":"boolean","default":true},"saml":{"type":"object","properties":{"idpEntityId":{"type":"string","minLength":1,"maxLength":1024},"ssoUrl":{"type":"string","format":"uri"},"certificates":{"type":"array","items":{"type":"string","minLength":32,"maxLength":8192},"minItems":1,"maxItems":5}},"required":["idpEntityId","ssoUrl","certificates"]},"oidc":{"type":"object","properties":{"issuer":{"type":"string","format":"uri"},"clientId":{"type":"string","minLength":1,"maxLength":512},"clientSecret":{"type":"string","minLength":1,"maxLength":1024}},"required":["issuer","clientId"]},"required":{"type":"boolean","default":false},"jit":{"type":"object","properties":{"enabled":{"type":"boolean","default":true},"role":{"type":"string","enum":["org_admin","member"],"default":"member"},"groupIds":{"type":"array","items":{"type":"string"},"maxItems":20,"default":[]}}}}}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SsoView"}}}},"400":{"description":"Invalid configuration.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"SSO is not configured on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["sso"],"summary":"Remove the org identity provider and its routing (memberships stay)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SsoView"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sso/domains":{"post":{"tags":["sso"],"summary":"Claim an e-mail domain; answers the DNS TXT record that proves ownership","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"domain":{"type":"string","minLength":3,"maxLength":253}},"required":["domain"]}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SsoDomainClaim"}}}},"400":{"description":"Not a domain, or a public mail domain.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The domain belongs to another organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sso/domains/{domain}/verify":{"post":{"tags":["sso"],"summary":"Verify a claimed domain by its TXT record (`manual` = super admin break-glass)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":3,"maxLength":253},"required":true,"name":"domain","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"manual":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"domain":{"type":"string","minLength":3,"maxLength":253},"token":{"type":"string"},"verified":{"type":"boolean","default":false},"verifiedAt":{"type":"string","format":"date-time"},"verifiedBy":{"type":"string"},"verifiedVia":{"type":"string","enum":["dns","super_admin","microsoft_tenant","google_workspace"]}},"required":["domain","token"]}}}},"400":{"description":"The TXT record was not found yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The domain belongs to another organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/sso/domains/{domain}":{"delete":{"tags":["sso"],"summary":"Release a domain (sign-in routing for it stops)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":3,"maxLength":253},"required":true,"name":"domain","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SsoView"}}}}}}},"/api/admin/sso/entra/sync":{"post":{"tags":["sso"],"summary":"Re-write every Entra-preset SSO provider with the current WizBI Microsoft app (run after rotating its secret)","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"updated":{"type":"array","items":{"type":"string"}},"failed":{"type":"array","items":{"type":"object","properties":{"orgId":{"type":"string"},"error":{"type":"string"}},"required":["orgId","error"]}}},"required":["updated","failed"]}}}},"403":{"description":"Super admins only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"SSO or the Microsoft app is not configured on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/sso/google-workspace/sync":{"post":{"tags":["sso"],"summary":"Re-write every Google Workspace-preset SSO provider with the current WizBI Google OAuth client (run after rotating its secret)","responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"updated":{"type":"array","items":{"type":"string"}},"failed":{"type":"array","items":{"type":"object","properties":{"orgId":{"type":"string"},"error":{"type":"string"}},"required":["orgId","error"]}}},"required":["updated","failed"]}}}},"403":{"description":"Super admins only.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"SSO or the Google OAuth client is not configured on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/scim/token":{"post":{"tags":["sso"],"summary":"Create (or rotate) the org SCIM token — shown once, the previous one stops working","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"},"prefix":{"type":"string"},"baseUrl":{"type":"string"}},"required":["token","prefix","baseUrl"]}}}},"404":{"description":"SCIM is not enabled on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["sso"],"summary":"Revoke the org SCIM token (provisioning stops immediately)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"revoked":{"type":"number"}},"required":["revoked"]}}}}}}},"/api/orgs/{orgId}/integrations/microsoft":{"get":{"tags":["sso"],"summary":"Microsoft 365 connection of the org: connected tenant(s), their name, the domains verified through them, when and by whom","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["sso"],"summary":"Start connecting Microsoft 365: returns an admin-consent link (valid 15 minutes, once) that a Global Administrator, Privileged Role Administrator or Cloud Application Administrator of the Microsoft tenant must open in a browser. It cannot be completed through the API or MCP.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnectLink"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Microsoft 365 is not configured on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["sso"],"summary":"Disconnect Microsoft 365: domains verified only through it stop being verified, the Teams binding is disabled; the consent itself is removed by the customer in Entra","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":false,"name":"tenantId","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"That tenant is not connected to the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/integrations/microsoft/callback":{"get":{"tags":["sso"],"summary":"Microsoft admin-consent redirect (browser only): connects the tenant and redirects to the console","parameters":[{"schema":{"type":"string","maxLength":2048},"required":false,"name":"state","in":"query"},{"schema":{"type":"string","maxLength":64},"required":false,"name":"tenant","in":"query"},{"schema":{"type":"string","maxLength":16},"required":false,"name":"admin_consent","in":"query"},{"schema":{"type":"string","maxLength":2048},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"error","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"error_description","in":"query"},{"schema":{"type":"string","maxLength":2048},"required":false,"name":"error_uri","in":"query"}],"responses":{"302":{"description":"Back to the console with the outcome."}}}},"/api/orgs/{orgId}/integrations/google-workspace":{"get":{"tags":["sso"],"summary":"Google Workspace connection of the org: the connected Workspace (customer id, primary domain), the domains verified through it, when and by whom","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["sso"],"summary":"Start connecting Google Workspace: returns an authorization link (valid 15 minutes, once) that a super admin of the Google Workspace must open in a browser. WizBI reads the Workspace domains once (read-only) and keeps no Google token. It cannot be completed through the API or MCP.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GoogleWorkspaceConnectLink"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Google Workspace is not configured on this deployment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["sso"],"summary":"Disconnect Google Workspace: domains verified only through it stop being verified; refused (409) while company sign-in uses it. WizBI holds no Google token, so nothing is left at Google but the app entry the customer may remove in the Admin console","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":false,"name":"customerId","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"That Workspace is not connected to the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Company sign-in uses this Workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/integrations/google-workspace/callback":{"get":{"tags":["sso"],"summary":"Google Workspace authorization redirect (browser only): connects the Workspace and redirects to the console","parameters":[{"schema":{"type":"string","maxLength":2048},"required":false,"name":"state","in":"query"},{"schema":{"type":"string","maxLength":2048},"required":false,"name":"code","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"scope","in":"query"},{"schema":{"type":"string","maxLength":16},"required":false,"name":"authuser","in":"query"},{"schema":{"type":"string","maxLength":253},"required":false,"name":"hd","in":"query"},{"schema":{"type":"string","maxLength":64},"required":false,"name":"prompt","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"error","in":"query"},{"schema":{"type":"string","maxLength":4096},"required":false,"name":"error_description","in":"query"}],"responses":{"302":{"description":"Back to the console with the outcome."}}}},"/api/orgs/{orgId}/integrations/slack":{"get":{"tags":["channels"],"summary":"Slack connection of the org: the workspace WizBI is installed in, who installed it and when, and whether Add to Slack is available on this deployment","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["channels"],"summary":"Disconnect Slack: WizBI's token is revoked at Slack (the app leaves the workspace) and deleted, the Slack channel is disabled (kept, re-activated on reinstall)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":64},"required":false,"name":"teamId","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantConnection"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"That workspace is not connected to the organization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/integrations/slack/install":{"get":{"tags":["channels"],"summary":"Add to Slack: returns the install link (valid 15 minutes, once) that a person allowed to install apps in the Slack workspace must open in a browser. It cannot be completed through the API or MCP. `redirect=true` answers 302 to it instead.","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"redirect","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlackInstallLink"}}}},"302":{"description":"To Slack (with `redirect=true`)."},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Slack is not available on this deployment (`slack_unavailable`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/slack/oauth/callback":{"get":{"tags":["channels"],"summary":"Slack OAuth v2 redirect (browser only): connects the workspace and redirects to the console","parameters":[{"schema":{"type":"string","maxLength":2048},"required":false,"name":"state","in":"query"},{"schema":{"type":"string","maxLength":512},"required":false,"name":"code","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"error","in":"query"}],"responses":{"302":{"description":"Back to the console with the outcome."}}}},"/api/admin/orgs/{orgId}/erasure":{"post":{"tags":["admin"],"summary":"Step 1 of 2: plan a full organization erasure (dry run)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The stored request with its plan.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/erasure/{requestId}/confirm":{"post":{"tags":["admin"],"summary":"Step 2 of 2: execute a planned erasure (type the org slug back)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1},"required":true,"name":"requestId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"confirmSlug":{"type":"string","minLength":1}},"required":["confirmSlug"]}}}},"responses":{"200":{"description":"The erasure result.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals/{principalId}/knowledge-erasure":{"post":{"tags":["admin"],"summary":"Erase a person's knowledge: their memory items (+versions, events), evidence quoting them, their learning issues (dry run, then confirm)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"orgIds":{"type":"array","items":{"type":"string","minLength":1},"maxItems":500},"confirm":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Dry-run counts, or what was erased.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/retention":{"put":{"tags":["admin"],"summary":"Set how long conversation content is kept for an org (preview, then confirm)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"conversationDays":{"type":"integer","nullable":true,"minimum":1,"maximum":3650},"confirm":{"type":"boolean","default":false}},"required":["conversationDays"]}}}},"responses":{"200":{"description":"Preview or result.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/migrations":{"get":{"tags":["admin"],"summary":"Registered migrations with their last run and dry run","responses":{"200":{"description":"Migrations.","content":{"application/json":{"schema":{"type":"object","properties":{"migrations":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}}},"required":["migrations"]}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/migrations/{id}":{"post":{"tags":["admin"],"summary":"Run a migration: dry run by default; `dryRun:false` needs `confirm:true`","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"dryRun":{"type":"boolean","default":true},"confirm":{"type":"boolean","default":false},"restart":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"The run state (status `paused` = call again).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/telemetry/probe":{"post":{"tags":["admin"],"summary":"Write one probe row to BigQuery through the turn path and read it back","responses":{"200":{"description":"The row landed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelemetryProbe"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The row did not land (`telemetry_probe_failed`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/internal/telemetry/probe":{"post":{"tags":["admin"],"summary":"Scheduler: the hourly telemetry probe (OIDC as the scheduler SA)","responses":{"200":{"description":"The row landed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelemetryProbe"}}}},"401":{"description":"Not the scheduler.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"The row did not land (`telemetry_probe_failed`), or disabled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/data":{"get":{"tags":["data"],"summary":"My data requests: exports (with their download state) and erasures","responses":{"200":{"description":"Requests.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"401":{"description":"Unauthenticated.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/data/export":{"post":{"tags":["data"],"summary":"Request an export of my personal data (profile, identities, conversations, memory, files, settings, acceptances) — a zip, ready in minutes, downloadable for 7 days","responses":{"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/data/erasure":{"post":{"tags":["data"],"summary":"Erase my personal data everywhere: preview first (what is deleted, anonymized, kept and why), then confirm with my e-mail typed back. Signs me out; cannot be undone","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataErasureBody"}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/me/data/requests/{requestId}":{"get":{"tags":["data"],"summary":"One of my requests, with a fresh download link (one hour) when the export is ready","parameters":[{"schema":{"type":"string","pattern":"^dsr_[0-9a-f]{18}$"},"required":true,"name":"requestId","in":"path"}],"responses":{"200":{"description":"The request.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/data":{"get":{"tags":["data"],"summary":"The organization's data requests (exports, member erasures), its scheduled deletion and legal hold","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"Overview.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/data/export":{"post":{"tags":["data"],"summary":"Request an export of the organization's data (settings, members, groups, policy, knowledge, conversations, files, reports) — a zip downloadable for 7 days","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/data/members/{principalId}/export":{"post":{"tags":["data"],"summary":"Request an export of a member's data in this organization","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"responses":{"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/data/members/{principalId}/erasure":{"post":{"tags":["data"],"summary":"Erase a member's data in this organization (membership, their conversations, memory, files, reports): preview first, then confirm with the member's e-mail typed back. Their sign-in and other organizations are not touched","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataErasureBody"}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/orgs/{orgId}/data/requests/{requestId}":{"get":{"tags":["data"],"summary":"One of the organization's requests, with a fresh download link when ready","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"},{"schema":{"type":"string","pattern":"^dsr_[0-9a-f]{18}$"},"required":true,"name":"requestId","in":"path"}],"responses":{"200":{"description":"The request.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/data/requests":{"get":{"tags":["data"],"summary":"Every data request (filter by status, org or person)","parameters":[{"schema":{"type":"string","maxLength":20},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"orgId","in":"query"},{"schema":{"type":"string","maxLength":128},"required":false,"name":"principalId","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":500},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Requests.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/data/requests/{requestId}":{"get":{"tags":["data"],"summary":"A data request with its download link and certificate","parameters":[{"schema":{"type":"string","pattern":"^dsr_[0-9a-f]{18}$"},"required":true,"name":"requestId","in":"path"}],"responses":{"200":{"description":"The request.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/data/certificates/{certificateId}":{"get":{"tags":["data"],"summary":"A deletion certificate: what was deleted, anonymized and kept, when, by whom","parameters":[{"schema":{"type":"string","pattern":"^cert_[0-9a-f]{18}$"},"required":true,"name":"certificateId","in":"path"}],"responses":{"200":{"description":"The certificate.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/data/sweep":{"post":{"tags":["data"],"summary":"Run the daily data-rights sweep now: due org deletions, unfinished erasures, lost dispatches, expired exports (preview, then confirm)","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"boolean","default":false}}}}}},"responses":{"200":{"description":"Pending requests (preview) or the sweep result.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals/{principalId}/data/export":{"post":{"tags":["data"],"summary":"Export a person's data across every organization (a DSAR on their behalf)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"responses":{"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals/{principalId}/data/erasure":{"post":{"tags":["data"],"summary":"Erase a person's data everywhere (identity, every org): preview, then confirm with their e-mail typed back","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DataErasureBody"}}}},"responses":{"200":{"description":"The preview.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/principals/{principalId}/data/legal-hold":{"put":{"tags":["data"],"summary":"Put a legal hold on a person's data (suspends every erasure of it), or release it","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":128},"required":true,"name":"principalId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LegalHoldBody"}}}},"responses":{"200":{"description":"The hold.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/data/export":{"post":{"tags":["data"],"summary":"Export an organization's data (also a suspended one: offboarding)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"202":{"description":"The request (queued).","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/data/deletion":{"get":{"tags":["data"],"summary":"An organization's deletion: the preview (what to type, the window, holds) and the open schedule","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The deletion state.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["data"],"summary":"Schedule an organization deletion (soft first: suspended now, deleted on the date — at most 60 days; a legal hold suspends it). Preview, then confirm with the slug typed back","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrgDeletionBody"}}}},"responses":{"200":{"description":"The preview or the scheduled request.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["data"],"summary":"Cancel a scheduled organization deletion (restores the org status it had)","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"responses":{"200":{"description":"The cancelled request.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/orgs/{orgId}/data/legal-hold":{"put":{"tags":["data"],"summary":"Put a legal hold on an organization's data (suspends its deletion and its members' erasures in it), or release it","parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"orgId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LegalHoldBody"}}}},"responses":{"200":{"description":"The hold.","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"nullable":true}}}}},"400":{"description":"Invalid, or the confirmation did not match.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Insufficient role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Conflict, legal hold, or not ready.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Data rights are switched off here (`data_rights_disabled`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/data-exports/{requestId}":{"get":{"tags":["data"],"summary":"Download an export archive with a signed, time-limited link","parameters":[{"schema":{"type":"string","pattern":"^dsr_[0-9a-f]{18}$"},"required":true,"name":"requestId","in":"path"},{"schema":{"type":"string","maxLength":12},"required":true,"name":"exp","in":"query"},{"schema":{"type":"string","maxLength":100},"required":true,"name":"sig","in":"query"}],"responses":{"200":{"description":"The zip.","content":{"application/zip":{"schema":{"type":"string","format":"binary"}}}},"403":{"description":"The link is invalid or expired (`data_export_link_invalid`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"The export expired (`data_export_expired`).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Switched off.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/signing/envelopes":{"post":{"tags":["admin"],"summary":"Register a rendered order form for e-signature and get its one-time link (staff)","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SigningRegister"}}}},"responses":{"201":{"description":"OK.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SigningRegistered"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"get":{"tags":["admin"],"summary":"Order forms sent for signature, newest first (staff)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":500},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"envelopes":{"type":"array","items":{"$ref":"#/components/schemas/SigningEnvelope"}}},"required":["envelopes"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/signing/envelopes/{id}":{"get":{"tags":["admin"],"summary":"One envelope with its events and signature record (staff)","parameters":[{"schema":{"type":"string","pattern":"^env_[A-Za-z0-9]{20}$"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"envelope":{"$ref":"#/components/schemas/SigningEnvelope"},"events":{"type":"array","items":{"type":"object","additionalProperties":{"nullable":true}}},"signature":{"type":"object","nullable":true,"additionalProperties":{"nullable":true}}},"required":["envelope","events","signature"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/signing/envelopes/{id}/pdf":{"get":{"tags":["admin"],"summary":"Download an envelope PDF: rendered, original (shown to the signer) or signed (staff)","parameters":[{"schema":{"type":"string","pattern":"^env_[A-Za-z0-9]{20}$"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["rendered","original","signed"],"default":"signed"},"required":false,"name":"which","in":"query"}],"responses":{"200":{"description":"The PDF","content":{"application/pdf":{"schema":{"type":"string"}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/admin/signing/envelopes/{id}/void":{"post":{"tags":["admin"],"summary":"Cancel an open envelope; its link stops working at once (staff)","parameters":[{"schema":{"type":"string","pattern":"^env_[A-Za-z0-9]{20}$"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":200}},"required":["reason"]}}}},"responses":{"200":{"description":"OK.","content":{"application/json":{"schema":{"type":"object","properties":{"envelope":{"$ref":"#/components/schemas/SigningEnvelope"}},"required":["envelope"]}}}},"400":{"description":"Invalid request or reason missing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not a super_admin.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}