{"openapi":"3.1.0","jsonSchemaDialect":"https://json-schema.org/draft/2020-12/schema","info":{"title":"Feelcouch Projects Demo API","version":"1.47.0-demo","summary":"Read-only platform catalogue and status API","description":"Public read-only demonstration API. Every response contains static demo data and must not be treated as live production telemetry.","contact":{"name":"nikkvern","url":"https://dev.feelcouch.tech"}},"servers":[{"url":"/","description":"Current Feelcouch environment"}],"externalDocs":{"description":"Human-readable API reference","url":"/api-docs"},"tags":[{"name":"Platform","description":"Public read-only demo resources"},{"name":"Operations","description":"Unauthenticated runtime and deployment probes"},{"name":"Billing","description":"Private non-transacting plan and invoice reads"},{"name":"Account","description":"Participant self-service over the session cookie"},{"name":"Integrations","description":"Read-only bearer access scoped to one group"},{"name":"Telegram","description":"Mini App sign-in and Bot API webhook delivery"}],"paths":{"/api/trainer/live":{"get":{"tags":["Account"],"operationId":"getTrainerLive","summary":"Read own meetings, reminder preference and submitted cases","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Own scheduled meetings and case requests"},"401":{"description":"Participant session required"},"404":{"description":"Feature disabled"}}},"post":{"tags":["Account"],"operationId":"updateTrainerLive","summary":"Update reminders or explicitly share a case with the assigned facilitator","security":[{"sessionCookie":[]}],"description":"Exact configured Origin, bounded 32 KiB body and rate limits. Cases require active trainer access, membership and confirmShare. UUID requests are idempotent; private diary content is never included automatically.","responses":{"200":{"description":"Saved preference or case"},"400":{"description":"Invalid payload"},"401":{"description":"Participant session required"},"403":{"description":"Untrusted origin or missing access"},"404":{"description":"Feature disabled"},"409":{"description":"Concurrent request"},"413":{"description":"Body limit exceeded"},"429":{"description":"Rate limit exceeded"}}}},"/api/trainer/report":{"get":{"tags":["Account"],"operationId":"getTrainerReport","summary":"Download a private PDF snapshot or read sharing settings","security":[{"sessionCookie":[]}],"description":"Participant may download own records after access expiry. A facilitator can download only a snapshot explicitly shared with that same recipient while consent remains active. No-store PDF bytes include a SHA-256 header. settings=1 reads sharing and delivery readiness.","responses":{"200":{"description":"Private PDF or sharing settings"},"400":{"description":"Invalid period or identifier"},"401":{"description":"Session required"},"403":{"description":"Not the authorized recipient"},"404":{"description":"Disabled feature or missing report"},"429":{"description":"Rate limit exceeded"}}},"post":{"tags":["Account"],"operationId":"shareTrainerReport","summary":"Explicitly share the identical full PDF with participant and facilitator, or revoke sharing","security":[{"sessionCookie":[]}],"description":"Exact Origin, 2 KiB body, rate limits and active access required for sharing. Revocation remains available after expiry. Automatic monthly delivery is opt-in. Queued status is distinct from successful Telegram delivery; demo dispatch remains disabled.","responses":{"200":{"description":"Immutable report queued for both recipients, or consent revoked"},"400":{"description":"Invalid request or missing explicit consent"},"401":{"description":"Participant session required"},"403":{"description":"Untrusted origin or missing access"},"404":{"description":"Feature disabled"},"409":{"description":"Assigned owner unavailable"},"413":{"description":"Body limit exceeded"},"429":{"description":"Rate limit exceeded"}}}},"/api/trainer/subscription":{"get":{"tags":["Account"],"operationId":"getTrainerSubscription","summary":"Read own subscription terms and payment request","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Own current terms and request, private no-store"},"401":{"description":"Participant session required"},"404":{"description":"Trainer disabled"}}},"post":{"tags":["Account"],"operationId":"requestTrainerSubscription","summary":"Accept current offer or report payment for manual review","description":"Exact Origin, session, rate limit and strict bounded JSON required. start: operation, confirmTerms true, version. paid: operation, own requestId. Client amounts rejected. Reporting never grants access.","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Durable own request status"},"400":{"description":"Invalid checkout body"},"401":{"description":"Participant session required"},"403":{"description":"Origin rejected"},"404":{"description":"Disabled or request not found"},"409":{"description":"Stale terms or retry"},"413":{"description":"Body exceeds 2 KiB"},"429":{"description":"Rate limit exceeded"}}}},"/api/trainer/trial":{"get":{"tags":["Account"],"operationId":"getTrainerTrial","summary":"Read own free-trial eligibility and consent readiness","security":[{"sessionCookie":[]}],"description":"Reports whether the self-serve free trial is enabled, its length in days, the eligibility decision for this account, and whether the current offer and profile-data consent are recorded. No access is granted.","responses":{"200":{"description":"Own trial eligibility and consent readiness, private no-store"},"401":{"description":"Participant session required"},"404":{"description":"Trainer disabled"}}},"post":{"tags":["Account"],"operationId":"activateTrainerTrial","summary":"Grant the one-time free trial to the signed-in participant","description":"Exact Origin, session and rate limit required. Grants trainer access once for the configured number of days after signed consent. Re-grant is refused for any current or prior access. Client amounts and identity are never accepted.","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Trial granted; own access expiry returned"},"401":{"description":"Participant session required"},"403":{"description":"Origin rejected or account unavailable"},"404":{"description":"Trainer disabled"},"409":{"description":"Missing signed consent, already active, or trial already used"},"429":{"description":"Rate limit exceeded"}}}},"/api/trainer/subscription/qr":{"get":{"tags":["Account"],"operationId":"getTrainerSubscriptionQr","summary":"Read approved unchanged bank QR immediately after authentication","description":"Requires an authenticated trainer account. No payment request or health consent is needed to view the approved QR. Private no-store PNG.","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Approved QR PNG"},"401":{"description":"Session required"},"404":{"description":"Disabled or request unavailable"}}}},"/api/trainer/state":{"get":{"tags":["Account"],"operationId":"getTrainerState","summary":"Read only the signed-in participant's private trainer state","security":[{"sessionCookie":[]}],"description":"Opt-in tenant feature. User identity is derived from the signed session, never request input. Expired access retains read/export ability. All responses are private, no-store.","responses":{"200":{"description":"Revision, private state and write-access status"},"401":{"description":"Participant session required"},"404":{"description":"Trainer feature disabled"}}},"put":{"tags":["Account"],"operationId":"saveTrainerState","summary":"Save validated private trainer state with revision protection","security":[{"sessionCookie":[]}],"description":"Requires exact configured Origin, active account, participant membership/consent and unexpired trainer access for participants. Active tenant ADMIN has permanent access only to their own workspace. Maximum streamed body is 1 MiB. Concurrent revisions fail closed rather than overwriting another tab. Staff receive counters only through their authenticated workspace.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"New revision saved atomically"},"400":{"description":"Invalid JSON, duplicate keys or invalid state"},"401":{"description":"Participant session required"},"403":{"description":"Untrusted origin, expired access or missing membership/consent"},"404":{"description":"Feature disabled"},"409":{"description":"Concurrent or outdated revision; retain local changes for export"},"413":{"description":"Body exceeds 1 MiB"},"429":{"description":"Write rate exceeded"}}}},"/api/legal/[id]":{"get":{"tags":["Account"],"operationId":"downloadApprovedCourseDocument","summary":"Download an immutable approved tenant legal document","description":"Primary document originals are public. Supplementary participant forms require a participant or staff session. Internal implementation materials require staff. Signed personal originals are never served by this route.","security":[{},{"sessionCookie":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Original PDF (default) or Word template (?format=docx); inline PDF with ?inline=1; private, no-store","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{"schema":{"type":"string","format":"binary"}}}},"404":{"description":"Unknown document or insufficient access"}}}},"/api/demo/legal/[kind]":{"get":{"tags":["Account"],"operationId":"getSyntheticLegalPdf","security":[{"sessionCookie":[]}],"summary":"Read a synthetic legal PDF in the isolated hosted demo","description":"Available only to authenticated synthetic accounts on the explicitly allowed hosted demo origin. These documents are demonstrations and are not approved course legal materials.","parameters":[{"name":"kind","in":"path","required":true,"schema":{"type":"string","enum":["OFFER","PRIVACY","INFORMED_CONSENT"]}}],"responses":{"200":{"description":"Synthetic PDF; private, no-store","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"404":{"description":"Demo disabled, unapproved origin, non-demo account or unknown document kind"}}}},"/api/billing":{"get":{"tags":["Billing"],"operationId":"getTenantBilling","summary":"Read the authenticated tenant's plan and authorized invoices","description":"Tenant scope comes only from the trusted runtime deployment, never a request parameter. Signed-in participants and facilitators receive the plan with an empty invoice array; only ADMIN callers receive tenant invoice details. No payment is submitted and no payment credentials are accepted. Missing platform billing configuration or unapplied billing migrations fail closed with a sanitized 503 response. Every response is private, no-store and noindex.","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"Tenant plan and ADMIN-only invoices; invoices are empty for other roles","headers":{"Cache-Control":{"description":"private, no-store","schema":{"type":"string"}},"X-Robots-Tag":{"description":"noindex, nofollow","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingResponse"}}}},"401":{"description":"UNAUTHENTICATED: no active authenticated account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"404":{"description":"Preview disabled: BILLING_PREVIEW_ENABLED must equal true; no authentication or database reads occur."},"503":{"description":"BILLING_NOT_CONFIGURED or BILLING_UNAVAILABLE: billing cannot be read; SQL and connection details are never returned","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"/api/platform/admin/billing":{"get":{"tags":["Billing"],"operationId":"getPlatformBillingCounts","summary":"Read protected aggregate entitlement counts by plan","description":"Requires the platform operator gate. Returns aggregate counts only: no tenant identifiers, invoices, participant data or payment credentials. Every response is private, no-store and noindex. This endpoint performs no payment operation.","security":[{"platformAdminGate":[]}],"responses":{"200":{"description":"Aggregate platform entitlement counts","headers":{"Cache-Control":{"description":"private, no-store","schema":{"type":"string"}},"X-Robots-Tag":{"description":"noindex, nofollow","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingCountsResponse"}}}},"403":{"description":"FORBIDDEN: the request did not clear the platform operator gate","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"404":{"description":"Preview disabled: BILLING_PREVIEW_ENABLED must equal true; no authentication or database reads occur."},"503":{"description":"BILLING_NOT_CONFIGURED or BILLING_UNAVAILABLE: billing tables or the platform connection are unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"/api/integrations/trainer-archive":{"get":{"tags":["Integrations"],"operationId":"exportTrainerArchive","summary":"Read consented tracker activity or one identical shared PDF for a private Google archive","security":[{"analysisBearer":[]}],"description":"Requires a separate trainer-archive purpose key. Legacy analysis tokens are rejected. The key is scoped to one group and an active creator, expires in 90 days, and can be revoked. Only active members who explicitly opted into Google archive for this exact owner are exported. Tables contain activity counts and case statuses, never diary text; PDFs contain the complete consented snapshot. The report query is checked against the same group, owner and live consent. Responses are private/no-store. Each table is limited to 1000 records; excess rows fail instead of silently truncating. lastExportAt proves server delivery only, not Google synchronization.","responses":{"200":{"description":"Versioned tables and report metadata, or private PDF bytes"},"401":{"description":"Missing, invalid, wrong-purpose, expired or revoked credential"},"403":{"description":"Consent revoked"},"404":{"description":"Feature disabled or report outside scope"},"413":{"description":"Archive exceeds bounded snapshot size"},"429":{"description":"Rate limit exceeded"}}},"post":{"tags":["Integrations"],"operationId":"acknowledgeTrainerArchive","summary":"Record a private Google archive synchronization acknowledgement","security":[{"analysisBearer":[]}],"description":"Trainer-archive purpose key only. A bounded 2KiB strict versioned body contains operational status, generation UUID and Google file identifiers, never participant content. Acknowledgements are audited and rate limited. lastExportAt alone never proves successful Google storage.","responses":{"200":{"description":"Operational acknowledgement recorded"},"400":{"description":"Invalid acknowledgement"},"401":{"description":"Invalid archive key"},"404":{"description":"Feature disabled"},"413":{"description":"Body exceeds2KiB"},"429":{"description":"Rate limit exceeded"}}}},"/api/integrations/analysis":{"get":{"tags":["Integrations"],"operationId":"exportIntegrationAnalysis","summary":"Read a pseudonymous result snapshot for one integration group","description":"GET-only machine endpoint authenticated exclusively by Authorization: Bearer <key>; session cookies do not authorize this request and URL query parameters cannot broaden the immutable group scope. A key is issued once to a group manager, expires after 90 days and is stored only as a SHA-256 hash. Every fetch rechecks expiry, revocation, the issuer's active/unblocked account and current group-manager or admin rights; those checks are repeated before returning the snapshot. The limit is 48 exports per authorized key per hour. Direct account identifiers, credentials, every diary (including shared diaries), staff notes, draft workbooks and draft experiments are excluded. Submitted/reviewed workbook definitions retain their versioned snapshots. Participant-authored text and external result URLs can identify people: this is pseudonymous data, not anonymous data. The group scopes the participant roster and attendance; other participant results are not linked to a program/enrollment in the current schema and must not be attributed to this cohort. A successful fetch updates lastExportAt and lastRowCount in the app; it does not prove Google Sheets or another downstream service synchronized the response. Every handled response has Cache-Control: private, no-store and X-Content-Type-Options: nosniff.","security":[{"analysisBearer":[]}],"responses":{"200":{"description":"Versioned pseudonymous participant result snapshot for the key's single group","headers":{"Cache-Control":{"description":"private, no-store","schema":{"type":"string"}},"X-Content-Type-Options":{"description":"nosniff","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntegrationAnalysisResponse"}}}},"401":{"description":"Generic INVALID_INTEGRATION_KEY: missing, malformed, expired or revoked bearer key, disabled/blocked issuer or issuer no longer permitted to manage this group","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"404":{"description":"GROUP_UNAVAILABLE: the fixed group snapshot cannot be loaded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"429":{"description":"RATE_LIMITED: 48 authorized-key exports per hour exceeded","headers":{"Retry-After":{"description":"Seconds until the rate-limit window ends","schema":{"type":"integer","minimum":1}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"500":{"description":"UNSAFE_EXPORT or EXPORT_UNAVAILABLE: the snapshot failed the privacy guard or could not be generated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"/api/platform/templates":{"get":{"tags":["Platform"],"operationId":"listDemoTemplates","summary":"List available demo templates","security":[],"responses":{"200":{"description":"Static template catalogue","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplatesResponse"}}}}}}},"/api/platform/projects":{"get":{"tags":["Platform"],"operationId":"listDemoProjects","summary":"List example platform projects","security":[],"responses":{"200":{"description":"Static project inventory","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProjectsResponse"}}}}}}},"/api/platform/status":{"get":{"tags":["Platform"],"operationId":"getDemoPlatformStatus","summary":"Get the privacy-safe platform status snapshot","security":[],"responses":{"200":{"description":"Static status snapshot","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatusResponse"}}}}}}},"/api/health":{"get":{"tags":["Operations"],"operationId":"getRuntimeHealth","summary":"Report runtime and database readiness","description":"Used by the container healthcheck, the blue/green switch and the public status page. Never cached, and it reveals no configuration detail beyond the state word.","security":[],"responses":{"200":{"description":"The runtime answers and its database query succeeds","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthOk"}}}},"503":{"description":"Either the production configuration is incomplete or the database query failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthUnavailable"}}}}}}},"/api/version":{"get":{"tags":["Operations"],"operationId":"getRuntimeVersion","summary":"Report the release this container was built from","description":"The release tag is baked into the image at build time. A deployment reads it through the public URL to prove the release it switched traffic to is the release actually answering, and every response also carries it as the X-Feelcouch-Release header.","security":[],"responses":{"200":{"description":"The build identity of the running container","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RuntimeVersion"}}}}}}},"/api/openapi":{"get":{"tags":["Operations"],"operationId":"getOpenApiDocument","summary":"Serve this OpenAPI 3.1 document","security":[],"responses":{"200":{"description":"The machine-readable contract","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/avatar/[userId]":{"get":{"tags":["Account"],"operationId":"getUserAvatar","summary":"Fetch a participant avatar through the server","description":"Proxies the current Telegram profile photo. Visible to the user, administrators and people who share a group with them; anyone else gets 404.","security":[{"sessionCookie":[]}],"parameters":[{"name":"userId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The avatar image","content":{"image/jpeg":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"No session on the request"},"404":{"description":"No avatar, or the caller may not view it"}}}},"/api/reports/final/[participantId]":{"get":{"tags":["Account"],"operationId":"getFinalReport","summary":"Download the final course report as a PDF","description":"A participant may fetch only their own report and only after the facilitator published it. A facilitator may fetch it at any time (preview) for participants of their own groups. Diary entries marked private-to-self are never included.","security":[{"sessionCookie":[]}],"parameters":[{"name":"participantId","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The report as a PDF attachment","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"No session on the request"},"403":{"description":"The caller may not read this participant's report"},"404":{"description":"The report is not published yet"}}}},"/api/downloads/telegram":{"post":{"tags":["Telegram"],"operationId":"deliverPrivateDownload","summary":"Deliver an authorized export to the caller's private bot chat","description":"Requires an active cookie session, a linked Telegram account and the exact configured Origin. The JSON body contains href, limited to personal account export, final report PDF, staff results CSV or staff analysis JSON. Reuses the selected export's owner, role, group and publication guards. The recipient is always the authenticated account's Telegram ID, never a request parameter. No download URL or file bytes are returned. Files are at most 20 MiB; requests are limited to five per user in fifteen minutes in addition to export-specific limits. This explicitly user-requested delivery stores a copy in the user's Telegram chat. The UI asks for confirmation before sending.","security":[{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["href"],"properties":{"href":{"type":"string","maxLength":1500}}}}}},"responses":{"200":{"description":"The file was delivered to the caller's private bot chat"},"400":{"description":"Malformed request or download outside the allowlist"},"401":{"description":"No active session"},"403":{"description":"Foreign request Origin or denied file access"},"404":{"description":"Report not published or group unavailable to the caller"},"409":{"description":"The caller has no linked Telegram account"},"413":{"description":"File exceeds 20 MiB"},"429":{"description":"Per-user download limit reached","headers":{"Retry-After":{"description":"Seconds until another attempt is allowed"}}},"502":{"description":"File could not be generated or delivered"}}}},"/api/account/export":{"get":{"tags":["Account"],"operationId":"exportOwnAccountData","summary":"Download every record held about the signed-in participant","description":"Answers the data portability request with the participant's own records only. The workbook answers carry the wording that was published when they were written, not the wording published today. Each successful export is written to the audit log.","security":[{"sessionCookie":[]}],"responses":{"200":{"description":"A downloadable JSON document scoped to the caller","headers":{"Content-Disposition":{"description":"Attachment filename stamped with the export date","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountExport"}}}},"401":{"description":"No participant session on the request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"/api/auth/email":{"post":{"tags":["Account"],"operationId":"manageEmailAccountAccess","summary":"Sign in or manage browser access without Telegram","description":"JSON mode selects login, register, attach, changeEmail, changePassword, logoutAll, recover, recoveryInfo, issueRecovery, generateRecoveryCodes or recoverCode. Login authenticates an existing email/password. Register creates only a participant account using a valid, single-use active-group invitation and keeps document choices separate from application access; an already authenticated user cannot register a duplicate profile. Attach requires a current active session; changing configured credentials also requires the current password and never merges accounts by a claimed email. ChangeEmail changes only the login address and preserves the existing password. ChangePassword preserves the login email. Both edits and logoutAll require the current password; logoutAll clears this session and revokes all devices without issuing a replacement. RecoveryInfo accepts a valid participant recovery token and returns only whether first-time email attachment is needed, without account identifiers or email addresses. Recovery consumes a manually delivered, single-use 30-minute token for the same participant; an existing email cannot be changed during recovery. IssueRecovery requires an authenticated manager of the participant's active group (or admin), an active participant account and explicit identityVerified=true after checking identity through an established channel; it does not send email or Telegram messages. GenerateRecoveryCodes requires the signed-in account to have email credentials and verifies its current password; it rotates eight 128-bit backup codes, returns them once and stores only SHA-256 hashes. RecoverCode requires the established email, an unused backup code and a strong new password, works for participants and staff without an email provider, preserves identity and consumes exactly one code. Credential changes, logoutAll and every password recovery revoke previous sessions, outstanding manual recovery links and unused backup code batches; generating a new batch revokes only the previous batch. Every mode requires the configured exact Origin and a body of at most 4096 bytes. Process-local limits are 30 requests per IP and 10 per normalized email, authenticated account, recovery token or recovery target in 15 minutes. Every response is private and no-store. Errors are generic and disclose no account existence or credentials.","security":[{},{"sessionCookie":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailAccessRequest"}}}},"responses":{"200":{"description":"Sign-in or access change succeeded; issueRecovery returns a manual-delivery link, recoveryInfo returns needsEmail, generateRecoveryCodes returns eight codes once","headers":{"Set-Cookie":{"description":"HttpOnly signed session cookie for login, registration, attachment, email/password changes and both recovery methods; logoutAll clears the current cookie","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailAccessResponse"}}}},"400":{"description":"Malformed request or generic operation failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"401":{"description":"Generic authentication, account access, password, invitation or recovery rejection","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"403":{"description":"The request Origin is not the configured app origin","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"413":{"description":"The request body exceeds 4096 bytes","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}},"429":{"description":"The per-IP or per-account request limit was exceeded","headers":{"Retry-After":{"description":"Seconds until the current rate-limit window ends","schema":{"type":"integer","minimum":1}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}},"/api/telegram/auth":{"post":{"tags":["Telegram"],"operationId":"authenticateTelegramMiniApp","summary":"Exchange Telegram Mini App init data for a session","description":"Verifies the init data signature, consumes an invite on first sign-in and sets the session cookie. Init data is never logged: only its digest is kept, and only to throttle replays.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelegramAuthRequest"}}}},"responses":{"200":{"description":"Session established; the body names where to continue","headers":{"Set-Cookie":{"description":"HttpOnly session cookie","schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TelegramAuthResponse"}}}},"400":{"description":"Malformed body, init data or invite token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"401":{"description":"Init data failed verification, or the invite is used, revoked or expired","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"403":{"description":"Untrusted request origin, or the account is suspended","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"413":{"description":"The request body exceeds the accepted size","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"429":{"description":"Too many attempts for the same init data","headers":{"Retry-After":{"description":"Seconds to wait before retrying","schema":{"type":"integer","minimum":1}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"500":{"description":"Temporary sign-in failure","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"503":{"description":"The bot is not configured in this environment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}}}}},"/api/telegram/webhook":{"post":{"tags":["Telegram"],"operationId":"receiveTelegramUpdate","summary":"Receive a Telegram Bot API update","description":"Called by Telegram, never by a client. The shared secret header is compared in constant time. An update that cannot be processed is still acknowledged so Telegram does not retry a poison message forever.","security":[{"telegramWebhookSecret":[]}],"requestBody":{"required":true,"description":"A Telegram Bot API Update object","content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"The update was accepted, ignored or deduplicated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}},"400":{"description":"The body is not a JSON object","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}},"401":{"description":"Missing or incorrect secret token header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}},"413":{"description":"The update exceeds the accepted size","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}},"502":{"description":"A reply to Telegram could not be delivered","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}},"503":{"description":"The bot is not configured in this environment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookAck"}}}}}}},"/api/platform/admin/operations":{"get":{"tags":["Operations"],"operationId":"getOperationalEventSummary","summary":"Read grouped counts of redacted operational events","description":"Gated operator read over the retention window. Only event names, reason codes and counters are returned; no token, identifier, name or participant content is ever stored or served.","security":[{"platformAdminGate":[]}],"responses":{"200":{"description":"Grouped operational event counts over the retention window","content":{"application/json":{"schema":{"type":"object","required":["windowDays","rows"],"properties":{"windowDays":{"type":"number"},"rows":{"type":"array","items":{"type":"object","required":["event","reason","count","lastAt"],"properties":{"event":{"type":"string"},"reason":{"type":["string","null"]},"count":{"type":"number"},"lastAt":{"type":"string","format":"date-time"}}}}}}}}},"403":{"description":"The request did not clear the platform admin gate","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorCode"}}}}}}}},"components":{"securitySchemes":{"analysisBearer":{"type":"http","scheme":"bearer","bearerFormat":"43-character base64url opaque key","description":"Authorization: Bearer <key>. Read-only single-group access; 90-day expiry, hash-only storage, revocation and current issuer group-manager/admin rights checked on every export. A session cookie cannot replace this key."},"sessionCookie":{"type":"apiKey","in":"cookie","name":"identichnost_session","description":"HttpOnly signed session cookie issued by Telegram or email/password authentication"},"telegramWebhookSecret":{"type":"apiKey","in":"header","name":"X-Telegram-Bot-Api-Secret-Token","description":"Shared secret registered with the Telegram Bot API when the webhook is set"},"platformAdminGate":{"type":"apiKey","in":"header","name":"x-feelcouch-admin-gate","description":"Operator gate secret, only honoured on the admin host"}},"schemas":{"BillingEntitlement":{"type":"object","required":["plan","status","currentPeriodEnd"],"properties":{"plan":{"type":"string","enum":["core","pro","agency"]},"status":{"type":"string"},"currentPeriodEnd":{"type":["string","null"],"format":"date-time"}}},"BillingInvoice":{"type":"object","description":"Tenant invoice metadata visible only to an ADMIN caller; no payment credentials or processor state","required":["id","amountMinor","currency","state","issuedAt","dueAt","paidAt"],"properties":{"id":{"type":"string"},"amountMinor":{"type":"integer","minimum":0},"currency":{"type":"string"},"state":{"type":"string","enum":["draft","open","paid","void"]},"issuedAt":{"type":"string","format":"date-time"},"dueAt":{"type":["string","null"],"format":"date-time"},"paidAt":{"type":["string","null"],"format":"date-time"}}},"BillingResponse":{"type":"object","required":["entitlement","invoices"],"properties":{"entitlement":{"$ref":"#/components/schemas/BillingEntitlement"},"invoices":{"type":"array","description":"Empty for participants and facilitators; tenant-scoped invoices for ADMIN only","items":{"$ref":"#/components/schemas/BillingInvoice"}}}},"BillingCountsResponse":{"type":"object","required":["counts"],"properties":{"counts":{"type":"array","items":{"type":"object","required":["plan","count"],"properties":{"plan":{"type":"string","enum":["core","pro","agency"]},"count":{"type":"integer","minimum":0}}}}}},"DemoMeta":{"type":"object","required":["mode","notice","asOf","owner"],"properties":{"mode":{"type":"string","const":"static-demo"},"notice":{"type":"string"},"asOf":{"type":"string","format":"date-time"},"owner":{"type":"string"}}},"Template":{"type":"object","required":["id","name","category","summary","accent","modules","readiness"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"category":{"type":"string"},"summary":{"type":"string"},"accent":{"type":"string"},"modules":{"type":"array","items":{"type":"string"}},"readiness":{"type":"string","const":"demo"}}},"Project":{"type":"object","required":["id","name","templateId","domain","state","environment","region","runtimeVersion","channels","updatedAt"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"templateId":{"type":"string"},"domain":{"type":"string","format":"hostname"},"state":{"type":"string","enum":["operational","degraded","maintenance","outage","unknown"]},"environment":{"type":"string","const":"demo"},"region":{"type":"string"},"runtimeVersion":{"type":"string"},"channels":{"type":"array","items":{"type":"string","enum":["web","telegram"]}},"updatedAt":{"type":"string","format":"date-time"}}},"LiveStatusMeta":{"type":"object","required":["mode","asOf","windowDays"],"properties":{"mode":{"type":"string","const":"live"},"asOf":{"type":"string","format":"date-time"},"windowDays":{"type":"integer","const":30}}},"UptimePoint":{"type":"object","required":["date","state"],"properties":{"date":{"type":"string","format":"date"},"state":{"type":"string","enum":["operational","degraded","maintenance","outage","unknown"]}}},"StatusOverall":{"type":"object","required":["state","uptime30d","latencyMs"],"properties":{"state":{"type":"string","enum":["operational","degraded","maintenance","outage","unknown"]},"uptime30d":{"type":["number","null"],"minimum":0,"maximum":100},"latencyMs":{"type":["integer","null"],"minimum":0}}},"StatusGroup":{"type":"object","required":["id","name","description","state","uptime30d","latencyMs","sampleCount","checks"],"properties":{"id":{"type":"string","enum":["platform","mini-apps","telegram","payments","provisioning"]},"name":{"type":"string"},"description":{"type":"string"},"state":{"type":"string","enum":["operational","degraded","maintenance","outage","unknown"]},"uptime30d":{"type":["number","null"],"minimum":0,"maximum":100},"latencyMs":{"type":["integer","null"],"minimum":0},"sampleCount":{"type":"integer","minimum":0},"checks":{"type":"array","minItems":30,"maxItems":30,"items":{"$ref":"#/components/schemas/UptimePoint"}}}},"TemplatesResponse":{"type":"object","required":["meta","data"],"properties":{"meta":{"$ref":"#/components/schemas/DemoMeta"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Template"}}}},"ProjectsResponse":{"type":"object","required":["meta","data"],"properties":{"meta":{"$ref":"#/components/schemas/DemoMeta"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Project"}}}},"RuntimeVersion":{"type":"object","required":["release","version"],"properties":{"release":{"type":"string","description":"Published release tag, prefixed with v"},"version":{"type":"string","description":"SemVer version from package.json"},"revision":{"type":"string","description":"Commit the image was built from, empty outside a release build"}}},"HealthOk":{"type":"object","required":["status"],"properties":{"status":{"type":"string","const":"ok"}}},"HealthUnavailable":{"type":"object","required":["status"],"properties":{"status":{"type":"string","enum":["misconfigured","unavailable"]}}},"ErrorCode":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Stable machine-readable code"}}},"ErrorMessage":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Message safe to show to the person"}}},"WebhookAck":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean"}}},"IntegrationAnalysisResponse":{"type":"object","required":["manifest","program","group","enrollments","participants"],"properties":{"manifest":{"$ref":"#/components/schemas/IntegrationAnalysisManifest"},"program":{"$ref":"#/components/schemas/AnalysisProgram"},"group":{"$ref":"#/components/schemas/AnalysisGroup"},"enrollments":{"type":"array","items":{"$ref":"#/components/schemas/AnalysisEnrollment"}},"participants":{"type":"array","items":{"$ref":"#/components/schemas/AnalysisParticipant"}}}},"IntegrationAnalysisManifest":{"type":"object","required":["schemaVersion","kind","generatedAt","resultScope","scopeNote","identityMode","privacyNote","membershipScope","workbookScope","diaryScope","definitionSnapshotNote"],"properties":{"schemaVersion":{"type":"integer","const":1},"kind":{"type":"string","const":"facilitator-analysis"},"generatedAt":{"type":"string","format":"date-time"},"resultScope":{"type":"string","const":"participant","description":"Results belong to participants, not necessarily to the selected group/program enrollment."},"scopeNote":{"type":"string","description":"Group scopes the roster and attendance; other results lack program/cohort attribution."},"identityMode":{"type":"string","const":"pseudonymous"},"privacyNote":{"type":"string","description":"Participant-authored text and external URLs are not anonymized."},"membershipScope":{"type":"string","const":"all-non-staff-memberships"},"workbookScope":{"type":"string","const":"submitted-or-reviewed"},"diaryScope":{"type":"string","const":"excluded"},"definitionSnapshotNote":{"type":"string","description":"Legacy invalid snapshots have an explicitly versioned fallback."}}},"AnalysisProgram":{"type":"object","required":["id","slug","title","totalWeeks"],"properties":{"id":{"type":"string"},"slug":{"type":"string"},"title":{"type":"string"},"totalWeeks":{"type":"integer"}}},"AnalysisGroup":{"type":"object","required":["id","name","streamLabel","startDate","timezone","currentWeek","status"],"properties":{"id":{"type":"string"},"name":{"type":"string"},"streamLabel":{"type":"string"},"startDate":{"type":"string","format":"date-time"},"timezone":{"type":"string"},"currentWeek":{"type":"integer"},"status":{"type":"string","enum":["ACTIVE","COMPLETED","ARCHIVED"]}}},"AnalysisEnrollment":{"type":"object","required":["participantId","status","joinedAt","exitedAt","blockedAt"],"properties":{"participantId":{"type":"string","pattern":"^[a-f0-9]{24}$","description":"Pseudonym stable within the selected group; the source participant ID is not emitted."},"status":{"type":"string","enum":["ACTIVE","EXITED","BLOCKED"]},"joinedAt":{"type":"string","format":"date-time"},"exitedAt":{"type":["string","null"],"format":"date-time"},"blockedAt":{"type":["string","null"],"format":"date-time"}}},"AnalysisParticipant":{"type":"object","additionalProperties":false,"required":["participantId","label","currentStage","onboardedAt","baselineSubmittedAt","baselineResults","indicatorValues","checkIns","goals","experiments","dailyMoods","workbooks","attendance"],"properties":{"participantId":{"type":"string","pattern":"^[a-f0-9]{24}$"},"label":{"type":"string","description":"Display ordinal, e.g. Participant 001; not the account display name."},"currentStage":{"type":"string","enum":["NOTICING","EXPLORATION","EXPERIMENT","CHOICE_COMMITMENT","INTEGRATION"]},"onboardedAt":{"type":["string","null"],"format":"date-time"},"baselineSubmittedAt":{"type":["string","null"],"format":"date-time"},"baselineResults":{"type":"array","items":{"type":"object"},"description":"External questionnaire result URLs, submittedAt and questionnaire ID/title; URLs may identify a person."},"indicatorValues":{"type":"array","items":{"type":"object"},"description":"Indicator value, updatedAt and indicator ID/label/options; excludes private staff note text."},"checkIns":{"type":"array","items":{"type":"object"},"description":"Weekly ratings and participant-authored check-in text with timestamps."},"goals":{"type":"array","items":{"type":"object"},"description":"Goal text, self-ratings, dated proximity ratings and evidence."},"experiments":{"type":"array","items":{"type":"object"},"description":"Non-draft participant experiment fields and statuses with stable record pseudonyms; not cohort-attributed."},"dailyMoods":{"type":"array","items":{"type":"object"},"description":"Date and self-reported mood score."},"workbooks":{"type":"array","items":{"type":"object"},"description":"Submitted/reviewed workbook answers and versioned definition snapshots; drafts excluded."},"attendance":{"type":"array","items":{"type":"object"},"description":"Attendance status and session week/time/status scoped to the selected group."}}},"EmailAccessRequest":{"description":"The mode-specific request. Attachment and link issuance require a session; all modes require trusted Origin.","oneOf":[{"$ref":"#/components/schemas/EmailLoginRequest"},{"$ref":"#/components/schemas/EmailRegistrationRequest"},{"$ref":"#/components/schemas/EmailAttachmentRequest"},{"$ref":"#/components/schemas/EmailRecoveryRequest"},{"$ref":"#/components/schemas/EmailRecoveryIssueRequest"},{"$ref":"#/components/schemas/EmailChangeRequest"},{"$ref":"#/components/schemas/PasswordChangeRequest"},{"$ref":"#/components/schemas/LogoutAllRequest"},{"$ref":"#/components/schemas/RecoveryInfoRequest"},{"$ref":"#/components/schemas/RecoveryCodesGenerationRequest"},{"$ref":"#/components/schemas/CodeRecoveryRequest"}]},"EmailLoginRequest":{"type":"object","required":["mode","email","password"],"properties":{"mode":{"type":"string","const":"login"},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","format":"password","maxLength":128}}},"EmailRegistrationRequest":{"type":"object","required":["mode","email","password","name","invite"],"properties":{"mode":{"type":"string","const":"register"},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","format":"password","minLength":12,"maxLength":128,"description":"Must include Latin letters and numbers."},"name":{"type":"string","minLength":1,"maxLength":128},"invite":{"type":"string","pattern":"^inv_[A-Za-z0-9_-]{43}$","description":"Unexpired and unrevoked single-use invitation to an active group."}}},"EmailAttachmentRequest":{"type":"object","required":["mode","email","password"],"properties":{"mode":{"type":"string","const":"attach"},"email":{"type":"string","format":"email","maxLength":254},"password":{"type":"string","format":"password","minLength":12,"maxLength":128,"description":"New password; must include Latin letters and numbers."},"currentPassword":{"type":"string","format":"password","maxLength":128,"description":"Required when the signed-in account already has email access configured."}}},"EmailRecoveryRequest":{"type":"object","required":["mode","token","password"],"properties":{"mode":{"type":"string","const":"recover"},"token":{"type":"string","pattern":"^[A-Za-z0-9_-]{43}$","description":"Single-use token from the recovery URL fragment; expires in 30 minutes."},"email":{"type":"string","format":"email","maxLength":254,"description":"Required only for first email attachment to the existing participant account; established emails remain unchanged."},"password":{"type":"string","format":"password","minLength":12,"maxLength":128,"description":"Must include Latin letters and numbers."}}},"EmailRecoveryIssueRequest":{"type":"object","required":["mode","participantId","identityVerified"],"properties":{"mode":{"type":"string","const":"issueRecovery"},"participantId":{"type":"string","maxLength":128,"description":"ParticipantProfile ID belonging to an active membership the caller manages."},"identityVerified":{"type":"boolean","const":true,"description":"Caller confirms identity verification through an established contact channel."}}},"EmailChangeRequest":{"type":"object","required":["mode","email","currentPassword"],"properties":{"mode":{"type":"string","const":"changeEmail"},"email":{"type":"string","format":"email","maxLength":254},"currentPassword":{"type":"string","format":"password","maxLength":128}}},"PasswordChangeRequest":{"type":"object","required":["mode","password","currentPassword"],"properties":{"mode":{"type":"string","const":"changePassword"},"password":{"type":"string","format":"password","minLength":12,"maxLength":128,"description":"Must include Latin letters and numbers."},"currentPassword":{"type":"string","format":"password","maxLength":128}}},"LogoutAllRequest":{"type":"object","required":["mode","currentPassword"],"properties":{"mode":{"type":"string","const":"logoutAll"},"currentPassword":{"type":"string","format":"password","maxLength":128}}},"RecoveryInfoRequest":{"type":"object","required":["mode","token"],"properties":{"mode":{"type":"string","const":"recoveryInfo"},"token":{"type":"string","pattern":"^[A-Za-z0-9_-]{43}$","description":"Valid opaque manual participant recovery token; inspection does not consume it."}}},"RecoveryCodesGenerationRequest":{"type":"object","required":["mode","currentPassword"],"properties":{"mode":{"type":"string","const":"generateRecoveryCodes"},"currentPassword":{"type":"string","format":"password","maxLength":128}}},"CodeRecoveryRequest":{"type":"object","required":["mode","email","code","password"],"properties":{"mode":{"type":"string","const":"recoverCode"},"email":{"type":"string","format":"email","maxLength":254},"code":{"type":"string","maxLength":64,"description":"Unused 128-bit backup code: 32 hex characters; optional hyphens and case are normalized."},"password":{"type":"string","format":"password","minLength":12,"maxLength":128,"description":"Must include Latin letters and numbers."}}},"EmailAccessResponse":{"type":"object","required":["ok"],"properties":{"ok":{"type":"boolean","const":true},"destination":{"type":"string","enum":["/f","/today","/login"],"description":"Returned by login, register, recover and recoverCode; logoutAll returns /login; participant navigation opens directly; content-write prerequisites follow the origin-bound course access policy."},"recoveryUrl":{"type":"string","description":"Returned only by issueRecovery. Sensitive one-time browser URL for manual delivery to the verified participant."},"needsEmail":{"type":"boolean","description":"Returned only by recoveryInfo; no account identity or configured address is revealed."},"codes":{"type":"array","minItems":8,"maxItems":8,"items":{"type":"string","pattern":"^[a-f0-9]{8}(?:-[a-f0-9]{8}){3}$"},"description":"Returned only by generateRecoveryCodes and shown once. Keep offline; the server stores only hashes."}}},"TelegramAuthRequest":{"type":"object","required":["initData"],"properties":{"initData":{"type":"string","maxLength":16384,"description":"Signed init data string handed over by the Telegram Mini App"},"inviteToken":{"type":"string","maxLength":128,"description":"Personal invite, required only for a first sign-in"}}},"TelegramAuthResponse":{"type":"object","required":["ok","destination"],"properties":{"ok":{"type":"boolean","const":true},"destination":{"type":"string","enum":["/today","/onboarding","/f"],"description":"Where the Mini App should continue after sign-in"}}},"AccountExport":{"type":"object","required":["exportedAt","account","participant"],"description":"Every record the platform holds about the caller. Arrays are present but may be empty.","properties":{"exportedAt":{"type":"string","format":"date-time"},"account":{"type":"object","properties":{"telegramUserId":{"type":"string"},"telegramUsername":{"type":["string","null"]},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"}}},"participant":{"type":"object","properties":{"currentStage":{"type":"string"},"focusDomainId":{"type":["string","null"]},"secondaryFocusLabel":{"type":["string","null"]},"focusDomainReason":{"type":["string","null"]},"onboardedAt":{"type":["string","null"],"format":"date-time"},"timezone":{"type":"string"},"notificationPreferences":{"type":"object","properties":{"morning":{"type":"boolean"},"evening":{"type":"boolean"}}}}},"memberships":{"type":"array","items":{"type":"object"}},"goals":{"type":"array","items":{"type":"object"}},"checkIns":{"type":"array","items":{"type":"object"}},"submissions":{"type":"array","description":"Each submission carries the workbook wording published when it was written.","items":{"type":"object"}},"experiments":{"type":"array","items":{"type":"object"}},"conversations":{"type":"array","items":{"type":"object"}},"consents":{"type":"array","items":{"type":"object"}}}},"StatusResponse":{"type":"object","required":["meta","overall","groups"],"properties":{"meta":{"$ref":"#/components/schemas/LiveStatusMeta"},"overall":{"$ref":"#/components/schemas/StatusOverall"},"groups":{"type":"array","items":{"$ref":"#/components/schemas/StatusGroup"}}}}}}}