# View Chat API Documentation > View Chat is a conversation logging, viewing, analytics, and checkup platform for AI chatbots and human conversations. ## Hosted Remote MCP Server Connect Claude Code, OpenCode, Cursor, or any Streamable HTTP MCP client directly to `https://api.view-chat.com/mcp` with `Authorization: Bearer `. Available MCP tools: `viewchat_log_message`, `viewchat_list_conversations`, `viewchat_get_messages`, `viewchat_get_analytics`, and `viewchat_list_reports`. ## Overview All API requests are made via HTTP POST to: `https://api.view-chat.com` With a JSON body of the form: ```json { "endpoint": "", "token": "", "payload": { ... } } ``` ## Authentication View Chat supports two main types of API tokens: 1. **Account / Org Tokens (and Account Secrets):** - Full API access for ingestion (`log`), querying conversations/messages, analytics, and account management. - Can optionally be limited to specific groups when created via `createToken`. - Created in the Accounts admin dashboard (`/admin`) or via the `createToken` endpoint. 2. **Personal Access Tokens (PATs, `vc_pat_...`):** - Read-only tokens scoped to the viewer and admin groups of the logged-in user. - Created in User Settings (`/settings`) or via `createUserToken`. ## Errors On error, the API returns HTTP 400 with a JSON response: ```json { "error": "Error message description" } ``` ## AI Coding Agent Skill If you are using an AI coding agent (e.g. OpenCode, Claude Code, Cursor, Windsurf), install the [View Chat Skill](https://github.com/uriva/view-chat-skill) to give your agent native access to this API. ## Endpoints ### log **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `event` `object` *(required)* - The message event to log - `from` `string` *(required)* - Who sent the message - `fromAvatar` `string` *(optional)* - Optional HTTP(S) URL of the sender's avatar image - `text` `string` *(required)* - Message content - `time` `number` *(required)* - Unix timestamp in milliseconds - `foreignId` `string` *(optional)* - Client-provided unique message ID for deduplication - `conversation` `string` *(optional)* - Conversation name. Created automatically if it doesn't exist. Mutually exclusive with conversationId. - `conversationId` `string` *(optional)* - Existing conversation ID. Must already exist; returns an error if not. Mutually exclusive with conversation. - `groups` `string[]` *(optional)* - Group names to assign. Groups are created automatically if they don't exist. Mutually exclusive with groupIds. - `groupIds` `string[]` *(optional)* - Group IDs to assign. Groups must already exist. Mutually exclusive with groups. - `recipients` `string[]` *(optional)* - Optional intended recipient names or identifiers for this conversation (e.g. proactive outreach before they reply). Displayed and searchable until they send a message. #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "log", "token": "YOUR_API_TOKEN", "payload": { "event": { "from": "user", "fromAvatar": "sample_value", "text": "Hello world", "time": 1700000000000, "foreignId": "id_12345" }, "conversation": "support-chat-1", "conversationId": "id_12345", "groups": [ "group_id_1" ], "groupIds": [ "group_id_1" ], "recipients": [ "recipient_1" ] } } ``` #### Example Response ```json { "ok": true } ``` --- ### createGroup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `name` `string` *(required)* - Name for the new group #### Response - `ok` `true` *(required)* - `groupId` `string` *(required)* - ID of the created group #### Example Request ```json { "endpoint": "createGroup", "token": "YOUR_API_TOKEN", "payload": { "name": "sample-name" } } ``` #### Example Response ```json { "ok": true, "groupId": "id_12345" } ``` --- ### renameGroup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `groupId` `string` *(required)* - ID of the group to rename - `name` `string` *(required)* - New name for the group #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "renameGroup", "token": "YOUR_API_TOKEN", "payload": { "groupId": "id_12345", "name": "sample-name" } } ``` #### Example Response ```json { "ok": true } ``` --- ### addViewer **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `email` `string` *(required)* - Email address of the viewer to add - `groupId` `string` *(required)* - ID of the group to add the viewer to #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "addViewer", "token": "YOUR_API_TOKEN", "payload": { "email": "user@example.com", "groupId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### removeViewer **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `email` `string` *(required)* - Email address of the viewer to remove - `groupId` `string` *(required)* - ID of the group to remove the viewer from #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "removeViewer", "token": "YOUR_API_TOKEN", "payload": { "email": "user@example.com", "groupId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### createAccount **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user #### Response - `ok` `true` *(required)* - `accountId` `string` *(required)* - ID of the created account #### Example Request ```json { "endpoint": "createAccount", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "accountId": "id_12345" } ``` --- ### addAccountAdmin **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `email` `string` *(required)* - Email address of the admin to add #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "addAccountAdmin", "token": "YOUR_API_TOKEN", "payload": { "email": "user@example.com" } } ``` #### Example Response ```json { "ok": true } ``` --- ### removeAccountAdmin **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `email` `string` *(required)* - Email address of the admin to remove #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "removeAccountAdmin", "token": "YOUR_API_TOKEN", "payload": { "email": "user@example.com" } } ``` #### Example Response ```json { "ok": true } ``` --- ### listPendingAccountInvites **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - *(No payload required)* #### Response - `ok` `true` *(required)* - `emails` `string[]` *(required)* #### Example Request ```json { "endpoint": "listPendingAccountInvites", "token": "YOUR_API_TOKEN", "payload": {} } ``` #### Example Response ```json { "ok": true, "emails": [ "item_1" ] } ``` --- ### listPendingAdminInvites **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user #### Response - `ok` `true` *(required)* - `invites` `object[]` *(required)* - `accountId` `string` *(required)* #### Example Request ```json { "endpoint": "listPendingAdminInvites", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "invites": [ { "accountId": "id_12345" } ] } ``` --- ### acceptAccountAdminInvite **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `accountId` `string` *(required)* - Account ID of the invitation to accept #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "acceptAccountAdminInvite", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "accountId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### declineAccountAdminInvite **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `accountId` `string` *(required)* - Account ID of the invitation to decline #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "declineAccountAdminInvite", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "accountId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### getMessages **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `conversationId` `string` *(required)* - Conversation ID - `groupId` `string` *(optional)* - Optional group ID that the conversation must belong to - `since` `number` *(optional)* - Only return messages with time >= this Unix timestamp in milliseconds - `until` `number` *(optional)* - Only return messages with time <= this Unix timestamp in milliseconds - `limit` `number` *(optional)* - Maximum number of messages to return (default: 100, max: 200) - `offset` `number` *(optional)* - Number of messages to skip for pagination (default: 0) #### Response - `ok` `true` *(required)* - `messages` `object[]` *(required)* - Messages in this conversation, ordered by time ascending - `id` `string` *(required)* - Message ID - `from` `string` *(required)* - Message sender - `fromAvatar` `string` *(optional)* - Sender avatar image URL, if logged - `text` `string` *(required)* - Message text - `time` `number` *(required)* - Unix timestamp in milliseconds - `timeIso` `string` *(required)* - ISO 8601 timestamp string (UTC), equivalent to `time` #### Example Request ```json { "endpoint": "getMessages", "token": "YOUR_API_TOKEN", "payload": { "conversationId": "id_12345", "groupId": "id_12345", "since": 1, "until": 1, "limit": 25, "offset": 0 } } ``` #### Example Response ```json { "ok": true, "messages": [ { "id": "id_12345", "from": "user", "fromAvatar": "sample_value", "text": "Hello world", "time": 1700000000000, "timeIso": "sample_value" } ] } ``` --- ### getConversations **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `groupId` `string` *(optional)* - Filter by group ID - `limit` `number` *(optional)* - Maximum number of conversations to return (default: 25, max: 100) - `offset` `number` *(optional)* - Number of conversations to skip for pagination (default: 0) - `since` `number` *(optional)* - Only return conversations with lastMessageTime >= this Unix timestamp in milliseconds - `until` `number` *(optional)* - Only return conversations with lastMessageTime <= this Unix timestamp in milliseconds - `participant` `string` *(optional)* - Filter conversations that have messages from this participant (case-insensitive substring match) #### Response - `ok` `true` *(required)* - `conversations` `object[]` *(required)* - List of conversations for this account - `id` `string` *(required)* - Conversation ID - `name` `string` *(required)* - Conversation name - `lastMessageTime` `number` *(optional)* - Timestamp of the last message (Unix ms) - `lastMessageTimeIso` `string` *(optional)* - ISO 8601 timestamp string (UTC) of the last message, equivalent to `lastMessageTime` - `participants` `string[]` *(optional)* - Participants who have sent messages in this conversation - `participantAvatars` `object` *(optional)* - Map of participant name to avatar image URL - `recipients` `string[]` *(optional)* - Known recipients who have not yet sent a message in this conversation - `groups` `object[]` *(required)* - Groups this conversation belongs to - `id` `string` *(required)* - Group ID - `name` `string` *(required)* - Group name #### Example Request ```json { "endpoint": "getConversations", "token": "YOUR_API_TOKEN", "payload": { "groupId": "id_12345", "limit": 25, "offset": 0, "since": 1, "until": 1, "participant": "sample_value" } } ``` #### Example Response ```json { "ok": true, "conversations": [ { "id": "id_12345", "name": "sample-name", "lastMessageTime": 1700000000000, "lastMessageTimeIso": "sample_value", "participants": [ "user" ], "participantAvatars": {}, "recipients": [ "recipient_1" ], "groups": [ { "id": "id_12345", "name": "sample-name" } ] } ] } ``` --- ### getAnalytics **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `groupId` `string` *(optional)* - Filter by group ID - `since` `number` *(required)* - Only return analytics at or after this Unix timestamp in milliseconds - `until` `number` *(optional)* - Only return analytics at or before this Unix timestamp in milliseconds #### Response - `ok` `true` *(required)* - `chatsPerDay` `object[]` *(required)* - `date` `string` *(required)* - UTC day in YYYY-MM-DD format - `value` `number` *(required)* - Conversation count for the day - `participantsPerDay` `object[]` *(required)* - `date` `string` *(required)* - UTC day in YYYY-MM-DD format - `value` `number` *(required)* - Unique participant count for the day - `messagesPerDay` `object[]` *(required)* - `date` `string` *(required)* - UTC day in YYYY-MM-DD format - `value` `number` *(required)* - Message count for the day - `latencyByParticipant` `object` *(required)* - Response latency data keyed by participant name, only for the top participants by message count #### Example Request ```json { "endpoint": "getAnalytics", "token": "YOUR_API_TOKEN", "payload": { "groupId": "id_12345", "since": 1, "until": 1 } } ``` #### Example Response ```json { "ok": true, "chatsPerDay": [ { "date": "sample_value", "value": 1 } ], "participantsPerDay": [ { "date": "sample_value", "value": 1 } ], "messagesPerDay": [ { "date": "sample_value", "value": 1 } ], "latencyByParticipant": {} } ``` --- ### createToken **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `name` `string` *(required)* - A label for the token (e.g. 'production', 'staging') - `groupIds` `string[]` *(optional)* - Optional group IDs to restrict this token to. If not provided or empty, the token has access to all groups in the account. - `totpCode` `string` *(optional)* - 6-digit authenticator app code (required when 2FA is enabled on the account) #### Response - `ok` `true` *(required)* - `token` `string` *(required)* - The full token value to use for API calls - `tokenId` `string` *(required)* - The token record ID #### Example Request ```json { "endpoint": "createToken", "token": "YOUR_API_TOKEN", "payload": { "name": "sample-name", "groupIds": [ "group_id_1" ], "totpCode": "sample_value" } } ``` #### Example Response ```json { "ok": true, "token": "sample_value", "tokenId": "id_12345" } ``` --- ### listTokens **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - *(No payload required)* #### Response - `ok` `true` *(required)* - `tokens` `object[]` *(required)* - All tokens for this account - `id` `string` *(required)* - Token record ID - `name` `string` *(required)* - Token label - `createdAt` `number` *(required)* - Creation timestamp - `revokedAt` `number` *(optional)* - Revocation timestamp, if revoked - `token` `string` *(required)* - The full token value - `groups` `object[]` *(optional)* - Groups this token is restricted to, if any - `id` `string` *(required)* - Group ID - `name` `string` *(required)* - Group name #### Example Request ```json { "endpoint": "listTokens", "token": "YOUR_API_TOKEN", "payload": {} } ``` #### Example Response ```json { "ok": true, "tokens": [ { "id": "id_12345", "name": "sample-name", "createdAt": 1, "revokedAt": 1, "token": "sample_value", "groups": [ { "id": "id_12345", "name": "sample-name" } ] } ] } ``` --- ### revokeToken **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `tokenId` `string` *(required)* - ID of the token to revoke #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "revokeToken", "token": "YOUR_API_TOKEN", "payload": { "tokenId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### createUserToken **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `name` `string` *(required)* - A label for the token - `totpCode` `string` *(optional)* - 6-digit authenticator app code (required when 2FA is enabled for this user) #### Response - `ok` `true` *(required)* - `token` `string` *(required)* - The full personal access token value. Shown only once — it is not retrievable later. - `tokenId` `string` *(required)* - The token record ID #### Example Request ```json { "endpoint": "createUserToken", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "name": "sample-name", "totpCode": "sample_value" } } ``` #### Example Response ```json { "ok": true, "token": "sample_value", "tokenId": "id_12345" } ``` --- ### listUserTokens **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user #### Response - `ok` `true` *(required)* - `tokens` `object[]` *(required)* - All personal access tokens for this user - `id` `string` *(required)* - Token record ID - `name` `string` *(required)* - Token label - `createdAt` `number` *(required)* - Creation timestamp - `maskedToken` `string` *(required)* - Masked token hint (e.g. vc_pat_…a1b2). The full value is never returned after creation. #### Example Request ```json { "endpoint": "listUserTokens", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "tokens": [ { "id": "id_12345", "name": "sample-name", "createdAt": 1, "maskedToken": "sample_value" } ] } ``` --- ### deleteUserToken **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `tokenId` `string` *(required)* - ID of the token to delete #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "deleteUserToken", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "tokenId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### getTotpStatus **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user #### Response - `ok` `true` *(required)* - `enabled` `boolean` *(required)* #### Example Request ```json { "endpoint": "getTotpStatus", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "enabled": true } ``` --- ### beginTotpSetup **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user #### Response - `ok` `true` *(required)* - `secret` `string` *(required)* - `otpauthUri` `string` *(required)* #### Example Request ```json { "endpoint": "beginTotpSetup", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "secret": "...", "otpauthUri": "..." } ``` --- ### confirmTotpSetup **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `totpCode` `string` *(required)* - 6-digit code from authenticator app #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "confirmTotpSetup", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "totpCode": "sample_value" } } ``` #### Example Response ```json { "ok": true } ``` --- ### disableTotp **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `totpCode` `string` *(required)* - 6-digit code from authenticator app #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "disableTotp", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "totpCode": "sample_value" } } ``` #### Example Response ```json { "ok": true } ``` --- ### createCheckup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `groupId` `string` *(required)* - ID of the group to monitor - `interests` `string` *(optional)* - Description of what to look for in conversations - `sampleSize` `integer` *(required)* - Number of conversations to sample per run (1-100) - `frequencyDays` `integer` *(required)* - How often to run, in days (1-365) - `excludeGroupIds` `string[]` *(optional)* - IDs of groups to exclude from this checkup - `onlyStartedInPeriod` `boolean` *(optional)* - Only scan conversations that started in this period - `githubToken` `string` *(optional)* - Optional GitHub Personal Access Token to let Vivi create issues in your repository - `githubRepo` `string` *(optional)* - Optional GitHub repository in owner/repo format (e.g. 'owner/repo') - `recipientEmails` `string[]` *(optional)* - Optional explicit list of email recipients for this checkup. When provided, summary emails are sent exclusively to these addresses instead of account admins. - `billingToken` `string` *(optional)* - Optional opaque delegated billing token forwarded when triggering Vivi for this checkup. - `lastRunAt` `number` *(optional)* - Optional initial lastRunAt timestamp (Unix ms) to schedule the first run after frequencyDays. #### Response - `ok` `true` *(required)* - `checkupId` `string` *(required)* - ID of the created checkup #### Example Request ```json { "endpoint": "createCheckup", "token": "YOUR_API_TOKEN", "payload": { "groupId": "id_12345", "interests": "sample_value", "sampleSize": {}, "frequencyDays": {}, "excludeGroupIds": [ "group_id_1" ], "onlyStartedInPeriod": true, "githubToken": "sample_value", "githubRepo": "sample_value", "recipientEmails": [ "item_1" ], "billingToken": "sample_value", "lastRunAt": 1 } } ``` #### Example Response ```json { "ok": true, "checkupId": "id_12345" } ``` --- ### getCheckup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `checkupId` `string` *(required)* - ID of the checkup to retrieve #### Response - `ok` `true` *(required)* - `checkup` `object` *(required)* - `id` `string` *(required)* - `groupId` `string` *(required)* - `interests` `string` *(required)* - `sampleSize` `number` *(required)* - `frequencyDays` `number` *(required)* - `lastRunAt` `number` *(optional)* - `onlyStartedInPeriod` `boolean` *(optional)* - `githubRepo` `string` *(optional)* - `hasGithubToken` `boolean` *(required)* - `recipientEmails` `string[]` *(optional)* - `excludeGroupIds` `string[]` *(required)* #### Example Request ```json { "endpoint": "getCheckup", "token": "YOUR_API_TOKEN", "payload": { "checkupId": "id_12345" } } ``` #### Example Response ```json { "ok": true, "checkup": { "id": "id_12345", "groupId": "id_12345", "interests": "...", "sampleSize": 10, "frequencyDays": 7, "lastRunAt": 1, "onlyStartedInPeriod": true, "githubRepo": "...", "hasGithubToken": true, "recipientEmails": [ "item_1" ], "excludeGroupIds": [ "group_id_1" ] } } ``` --- ### updateCheckup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `checkupId` `string` *(required)* - ID of the checkup to update - `groupId` `string` *(optional)* - Updated group ID - `interests` `string` *(optional)* - Updated description of what to look for - `sampleSize` `integer` *(optional)* - Updated sample size (1-100) - `frequencyDays` `integer` *(optional)* - Updated frequency in days (1-365) - `excludeGroupIds` `string[]` *(optional)* - Updated list of group IDs to exclude - `onlyStartedInPeriod` `boolean` *(optional)* - Only scan conversations that started in this period - `githubToken` `string` *(optional)* - Optional GitHub Personal Access Token to let Vivi create issues in your repository - `githubRepo` `string` *(optional)* - Optional GitHub repository in owner/repo format (e.g. 'owner/repo') - `recipientEmails` `string[]` *(optional)* - Updated list of explicit email recipients for this checkup. - `billingToken` `string` *(optional)* - Updated opaque delegated billing token for this checkup. #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "updateCheckup", "token": "YOUR_API_TOKEN", "payload": { "checkupId": "id_12345", "groupId": "id_12345", "interests": "sample_value", "sampleSize": {}, "frequencyDays": {}, "excludeGroupIds": [ "group_id_1" ], "onlyStartedInPeriod": true, "githubToken": "sample_value", "githubRepo": "sample_value", "recipientEmails": [ "item_1" ], "billingToken": "sample_value" } } ``` #### Example Response ```json { "ok": true } ``` --- ### deleteCheckup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `checkupId` `string` *(required)* - ID of the checkup to delete #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "deleteCheckup", "token": "YOUR_API_TOKEN", "payload": { "checkupId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### deleteGroup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `groupId` `string` *(required)* - ID of the group to delete - `deleteSharedConversations` `boolean` *(optional)* - When true, delete all conversations in this group even if they are also linked to other groups #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "deleteGroup", "token": "YOUR_API_TOKEN", "payload": { "groupId": "id_12345", "deleteSharedConversations": true } } ``` #### Example Response ```json { "ok": true } ``` --- ### deleteConversation **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `conversationId` `string` *(optional)* - ID of the conversation to delete - `conversationName` `string` *(optional)* - Canonical name of the conversation to delete (deletes all matching conversations in the account) #### Response - `ok` `true` *(required)* - `deletedCount` `number` *(required)* #### Example Request ```json { "endpoint": "deleteConversation", "token": "YOUR_API_TOKEN", "payload": { "conversationId": "id_12345", "conversationName": "sample_value" } } ``` #### Example Response ```json { "ok": true, "deletedCount": 1 } ``` --- ### runCheckup **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `checkupId` `string` *(required)* - ID of the checkup to run now #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "runCheckup", "token": "YOUR_API_TOKEN", "payload": { "checkupId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### cronStatus **Authentication:** Required (Cron Admin Secret) #### Request Payload - *(No payload required)* #### Response - `ok` `true` *(required)* - `lastRun` `unknown` *(optional)* - `lastStatus` `unknown` *(optional)* - `lastError` `unknown` *(optional)* #### Example Request ```json { "endpoint": "cronStatus", "token": "YOUR_API_TOKEN", "payload": {} } ``` #### Example Response ```json { "ok": true, "lastRun": {}, "lastStatus": {}, "lastError": {} } ``` --- ### triggerCron **Authentication:** Required (Cron Admin Secret) #### Request Payload - *(No payload required)* #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "triggerCron", "token": "YOUR_API_TOKEN", "payload": {} } ``` #### Example Response ```json { "ok": true } ``` --- ### translate **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `messages` `object[]` *(required)* - Messages to translate to English - `id` `string` *(required)* - Message ID - `text` `string` *(required)* - Message text to translate #### Response - `ok` `true` *(required)* - `translations` `object[]` *(required)* - Translations in the same order as input - `id` `string` *(required)* - Message ID - `translatedText` `string` *(required)* - Translated text #### Example Request ```json { "endpoint": "translate", "token": "YOUR_API_TOKEN", "payload": { "messages": [ { "id": "id_12345", "text": "Hello world" } ] } } ``` #### Example Response ```json { "ok": true, "translations": [ { "id": "id_12345", "translatedText": "sample_value" } ] } ``` --- ### listReports **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `checkupId` `string` *(optional)* - Filter reports by checkup ID - `limit` `number` *(optional)* - Maximum number of reports to return (default: 20) #### Response - `ok` `true` *(required)* - `reports` `object[]` *(required)* - Reports ordered by creation date descending - `id` `string` *(required)* - Report ID - `content` `string` *(required)* - Markdown report content - `createdAt` `number` *(required)* - Creation timestamp - `conversationIds` `string` *(required)* - JSON array of sampled conversation IDs - `checkup` `unknown` *(optional)* - Associated checkup data #### Example Request ```json { "endpoint": "listReports", "token": "YOUR_API_TOKEN", "payload": { "checkupId": "id_12345", "limit": 25 } } ``` #### Example Response ```json { "ok": true, "reports": [ { "id": "id_12345", "content": "sample_value", "createdAt": 1, "conversationIds": "id_12345", "checkup": {} } ] } ``` --- ### createSnapshot **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of the logged-in user - `conversationId` `string` *(required)* - ID of the conversation to create a public snapshot from #### Response - `ok` `true` *(required)* - `snapshotId` `string` *(required)* - ID of the created snapshot #### Example Request ```json { "endpoint": "createSnapshot", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "conversationId": "id_12345" } } ``` #### Example Response ```json { "ok": true, "snapshotId": "id_12345" } ``` --- ### getSnapshot **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `snapshotId` `string` *(required)* - UUID of the snapshot to view - `sessionToken` `string` *(optional)* - Optional InstantDB session token to check delete permission #### Response - `ok` `true` *(required)* - `snapshot` `object` *(required)* - `id` `string` *(required)* - `createdAt` `number` *(required)* - `messagesJson` `string` *(required)* - `canDelete` `boolean` *(required)* #### Example Request ```json { "endpoint": "getSnapshot", "payload": { "snapshotId": "id_12345", "sessionToken": "YOUR_SESSION_REFRESH_TOKEN" } } ``` #### Example Response ```json { "ok": true, "snapshot": { "id": "id_12345", "createdAt": 1, "messagesJson": "..." }, "canDelete": true } ``` --- ### deleteSnapshot **Authentication:** Not required (uses `sessionToken` in payload) #### Request Payload - `sessionToken` `string` *(required)* - InstantDB session (refresh) token of an account admin - `snapshotId` `string` *(required)* - UUID of the snapshot to delete #### Response - `ok` `true` *(required)* #### Example Request ```json { "endpoint": "deleteSnapshot", "payload": { "sessionToken": "YOUR_SESSION_REFRESH_TOKEN", "snapshotId": "id_12345" } } ``` #### Example Response ```json { "ok": true } ``` --- ### getBillingStatus **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - *(No payload required)* #### Response - `ok` `true` *(required)* - `plan` `string` *(required)* - `status` `string` *(required)* - `currentPeriodEnd` `number` *(optional)* - `cancelAtPeriodEnd` `boolean` *(required)* - `hasStripeCustomer` `boolean` *(required)* - `grandfathered` `boolean` *(required)* - `usage` `object` *(required)* - `monthlyMessages` `number` *(required)* - `monthlyMessageLimit` `unknown` *(required)* - `checkupsCount` `number` *(required)* #### Example Request ```json { "endpoint": "getBillingStatus", "token": "YOUR_API_TOKEN", "payload": {} } ``` #### Example Response ```json { "ok": true, "plan": "...", "status": "...", "currentPeriodEnd": 1, "cancelAtPeriodEnd": true, "hasStripeCustomer": true, "grandfathered": true, "usage": { "monthlyMessages": 1, "monthlyMessageLimit": {}, "checkupsCount": 1 } } ``` --- ### createCheckoutSession **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `plan` `string` *(required)* - Subscription tier to subscribe to - `interval` `string` *(optional)* - Billing interval ('month' default, or 'year' for 2 months free) - `successUrl` `string` *(optional)* - Optional same-origin URL to redirect to after successful checkout - `cancelUrl` `string` *(optional)* - Optional same-origin URL to redirect to if checkout is cancelled #### Response - `ok` `true` *(required)* - `url` `string` *(required)* - Stripe Checkout URL - `sessionId` `string` *(required)* - Stripe Checkout Session ID #### Example Request ```json { "endpoint": "createCheckoutSession", "token": "YOUR_API_TOKEN", "payload": { "plan": "sample_value", "interval": "sample_value", "successUrl": "sample_value", "cancelUrl": "sample_value" } } ``` #### Example Response ```json { "ok": true, "url": "sample_value", "sessionId": "id_12345" } ``` --- ### createBillingPortalSession **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `returnUrl` `string` *(optional)* - Optional same-origin URL to return to after exiting the Stripe Billing Portal #### Response - `ok` `true` *(required)* - `url` `string` *(required)* - Stripe Billing Portal URL #### Example Request ```json { "endpoint": "createBillingPortalSession", "token": "YOUR_API_TOKEN", "payload": { "returnUrl": "sample_value" } } ``` #### Example Response ```json { "ok": true, "url": "sample_value" } ``` --- ### syncBillingSession **Authentication:** Required (Account Token, Org Token, or PAT) #### Request Payload - `sessionId` `string` *(required)* - Stripe Checkout Session ID to verify and sync #### Response - `ok` `true` *(required)* - `plan` `string` *(required)* - `status` `string` *(required)* - `currentPeriodEnd` `number` *(optional)* - `cancelAtPeriodEnd` `boolean` *(required)* - `hasStripeCustomer` `boolean` *(required)* - `grandfathered` `boolean` *(required)* - `usage` `object` *(required)* - `monthlyMessages` `number` *(required)* - `monthlyMessageLimit` `unknown` *(required)* - `checkupsCount` `number` *(required)* #### Example Request ```json { "endpoint": "syncBillingSession", "token": "YOUR_API_TOKEN", "payload": { "sessionId": "id_12345" } } ``` #### Example Response ```json { "ok": true, "plan": "...", "status": "...", "currentPeriodEnd": 1, "cancelAtPeriodEnd": true, "hasStripeCustomer": true, "grandfathered": true, "usage": { "monthlyMessages": 1, "monthlyMessageLimit": {}, "checkupsCount": 1 } } ``` ---