ViewChat

API Documentation

Using an AI coding agent? Read our llms.txt or install the View Chat skill to give your agent full access to this API.

Base URL: https://api.view-chat.com

All requests are POST with JSON body: { endpoint, token, payload }

Integration Guides

Copy a 10-line snippet for your stack. No SDK package required.

Log both the user prompt and assistant reply without blocking your response stream.
const logViewChat = (conversation: string, from: string, text: string) =>
  fetch("https://api.view-chat.com", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      endpoint: "log",
      token: process.env.VIEW_CHAT_TOKEN,
      payload: {
        event: { from, text, time: Date.now() },
        conversation,
        groups: ["openai-support"],
      },
    }),
  }).catch(() => {});

// Inside your chat handler:
void logViewChat(threadId, userId, userMessage);
const completion = await openai.chat.completions.create({
  model: "gpt-4.1-mini",
  messages,
});
const reply = completion.choices[0]?.message?.content ?? "";
void logViewChat(threadId, "assistant", reply);

log

Auth Required

Request Payload

eventobject
The message event to log
fromstring
Who sent the message
fromAvatarstringoptional
Optional HTTP(S) URL of the sender's avatar image
textstring
Message content
timenumber
Unix timestamp in milliseconds
foreignIdstringoptional
Client-provided unique message ID for deduplication
conversationstringoptional
Conversation name. Created automatically if it doesn't exist. Mutually exclusive with conversationId.
conversationIdstringoptional
Existing conversation ID. Must already exist; returns an error if not. Mutually exclusive with conversation.
groupsstring[]optional
Group names to assign. Groups are created automatically if they don't exist. Mutually exclusive with groupIds.
groupIdsstring[]optional
Group IDs to assign. Groups must already exist. Mutually exclusive with groups.
recipientsstring[]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

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "log",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "event": {
              "from": "...",
              "text": "...",
              "time": 0
          },
          "conversation": "...",
          "conversationId": "...",
          "groups": [
              "..."
          ],
          "groupIds": [
              "..."
          ],
          "recipients": [
              "..."
          ]
      }
  }),
});

createGroup

Auth Required

Request Payload

namestring
Name for the new group

Response

oktrue
groupIdstring
ID of the created group

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createGroup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "name": "..."
      }
  }),
});

renameGroup

Auth Required

Request Payload

groupIdstring
ID of the group to rename
namestring
New name for the group

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "renameGroup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "groupId": "...",
          "name": "..."
      }
  }),
});

addViewer

Auth Required

Request Payload

emailstring
Email address of the viewer to add
groupIdstring
ID of the group to add the viewer to

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "addViewer",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "email": "...",
          "groupId": "..."
      }
  }),
});

removeViewer

Auth Required

Request Payload

emailstring
Email address of the viewer to remove
groupIdstring
ID of the group to remove the viewer from

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "removeViewer",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "email": "...",
          "groupId": "..."
      }
  }),
});

createAccount

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user

Response

oktrue
accountIdstring
ID of the created account

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createAccount",
      "payload": {
          "sessionToken": "..."
      }
  }),
});

addAccountAdmin

Auth Required

Request Payload

emailstring
Email address of the admin to add

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "addAccountAdmin",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "email": "..."
      }
  }),
});

removeAccountAdmin

Auth Required

Request Payload

emailstring
Email address of the admin to remove

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "removeAccountAdmin",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "email": "..."
      }
  }),
});

listPendingAccountInvites

Auth Required

Request Payload

No parameters required

Response

oktrue
emailsstring[]

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "listPendingAccountInvites",
      "token": "YOUR_API_TOKEN",
      "payload": {}
  }),
});

listPendingAdminInvites

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user

Response

oktrue
invitesobject[]
accountIdstring

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "listPendingAdminInvites",
      "payload": {
          "sessionToken": "..."
      }
  }),
});

acceptAccountAdminInvite

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
accountIdstring
Account ID of the invitation to accept

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "acceptAccountAdminInvite",
      "payload": {
          "sessionToken": "...",
          "accountId": "..."
      }
  }),
});

declineAccountAdminInvite

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
accountIdstring
Account ID of the invitation to decline

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "declineAccountAdminInvite",
      "payload": {
          "sessionToken": "...",
          "accountId": "..."
      }
  }),
});

getMessages

Auth Required

Request Payload

conversationIdstring
Conversation ID
groupIdstringoptional
Optional group ID that the conversation must belong to
sincenumberoptional
Only return messages with time >= this Unix timestamp in milliseconds
untilnumberoptional
Only return messages with time <= this Unix timestamp in milliseconds
limitnumberoptional
Maximum number of messages to return (default: 100, max: 200)
offsetnumberoptional
Number of messages to skip for pagination (default: 0)

Response

oktrue
messagesobject[]
Messages in this conversation, ordered by time ascending
idstring
Message ID
fromstring
Message sender
fromAvatarstringoptional
Sender avatar image URL, if logged
textstring
Message text
timenumber
Unix timestamp in milliseconds
timeIsostring
ISO 8601 timestamp string (UTC), equivalent to `time`

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getMessages",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "conversationId": "...",
          "groupId": "...",
          "since": 0,
          "until": 0,
          "limit": 0,
          "offset": 0
      }
  }),
});

getConversations

Auth Required

Request Payload

groupIdstringoptional
Filter by group ID
limitnumberoptional
Maximum number of conversations to return (default: 25, max: 100)
offsetnumberoptional
Number of conversations to skip for pagination (default: 0)
sincenumberoptional
Only return conversations with lastMessageTime >= this Unix timestamp in milliseconds
untilnumberoptional
Only return conversations with lastMessageTime <= this Unix timestamp in milliseconds
participantstringoptional
Filter conversations that have messages from this participant (case-insensitive substring match)

Response

oktrue
conversationsobject[]
List of conversations for this account
idstring
Conversation ID
namestring
Conversation name
lastMessageTimenumberoptional
Timestamp of the last message (Unix ms)
lastMessageTimeIsostringoptional
ISO 8601 timestamp string (UTC) of the last message, equivalent to `lastMessageTime`
participantsstring[]optional
Participants who have sent messages in this conversation
participantAvatarsobjectoptional
Map of participant name to avatar image URL
recipientsstring[]optional
Known recipients who have not yet sent a message in this conversation
groupsobject[]
Groups this conversation belongs to
idstring
Group ID
namestring
Group name

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getConversations",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "groupId": "...",
          "limit": 0,
          "offset": 0,
          "since": 0,
          "until": 0,
          "participant": "..."
      }
  }),
});

getAnalytics

Auth Required

Request Payload

groupIdstringoptional
Filter by group ID
sincenumber
Only return analytics at or after this Unix timestamp in milliseconds
untilnumberoptional
Only return analytics at or before this Unix timestamp in milliseconds

Response

oktrue
chatsPerDayobject[]
datestring
UTC day in YYYY-MM-DD format
valuenumber
Conversation count for the day
participantsPerDayobject[]
datestring
UTC day in YYYY-MM-DD format
valuenumber
Unique participant count for the day
messagesPerDayobject[]
datestring
UTC day in YYYY-MM-DD format
valuenumber
Message count for the day
latencyByParticipantobject
Response latency data keyed by participant name, only for the top participants by message count

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getAnalytics",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "groupId": "...",
          "since": 0,
          "until": 0
      }
  }),
});

createToken

Auth Required

Request Payload

namestring
A label for the token (e.g. 'production', 'staging')
groupIdsstring[]optional
Optional group IDs to restrict this token to. If not provided or empty, the token has access to all groups in the account.
totpCodestringoptional
6-digit authenticator app code (required when 2FA is enabled on the account)

Response

oktrue
tokenstring
The full token value to use for API calls
tokenIdstring
The token record ID

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createToken",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "name": "...",
          "groupIds": [
              "..."
          ],
          "totpCode": "..."
      }
  }),
});

listTokens

Auth Required

Request Payload

No parameters required

Response

oktrue
tokensobject[]
All tokens for this account
idstring
Token record ID
namestring
Token label
createdAtnumber
Creation timestamp
revokedAtnumberoptional
Revocation timestamp, if revoked
tokenstring
The full token value
groupsobject[]optional
Groups this token is restricted to, if any
idstring
Group ID
namestring
Group name

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "listTokens",
      "token": "YOUR_API_TOKEN",
      "payload": {}
  }),
});

revokeToken

Auth Required

Request Payload

tokenIdstring
ID of the token to revoke

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "revokeToken",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "tokenId": "..."
      }
  }),
});

createUserToken

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
namestring
A label for the token
totpCodestringoptional
6-digit authenticator app code (required when 2FA is enabled for this user)

Response

oktrue
tokenstring
The full personal access token value. Shown only once — it is not retrievable later.
tokenIdstring
The token record ID

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createUserToken",
      "payload": {
          "sessionToken": "...",
          "name": "...",
          "totpCode": "..."
      }
  }),
});

listUserTokens

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user

Response

oktrue
tokensobject[]
All personal access tokens for this user
idstring
Token record ID
namestring
Token label
createdAtnumber
Creation timestamp
maskedTokenstring
Masked token hint (e.g. vc_pat_…a1b2). The full value is never returned after creation.

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "listUserTokens",
      "payload": {
          "sessionToken": "..."
      }
  }),
});

deleteUserToken

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
tokenIdstring
ID of the token to delete

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "deleteUserToken",
      "payload": {
          "sessionToken": "...",
          "tokenId": "..."
      }
  }),
});

getTotpStatus

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user

Response

oktrue
enabledboolean

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getTotpStatus",
      "payload": {
          "sessionToken": "..."
      }
  }),
});

beginTotpSetup

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user

Response

oktrue
secretstring
otpauthUristring

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "beginTotpSetup",
      "payload": {
          "sessionToken": "..."
      }
  }),
});

confirmTotpSetup

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
totpCodestring
6-digit code from authenticator app

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "confirmTotpSetup",
      "payload": {
          "sessionToken": "...",
          "totpCode": "..."
      }
  }),
});

disableTotp

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
totpCodestring
6-digit code from authenticator app

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "disableTotp",
      "payload": {
          "sessionToken": "...",
          "totpCode": "..."
      }
  }),
});

createCheckup

Auth Required

Request Payload

groupIdstring
ID of the group to monitor
interestsstringoptional
Description of what to look for in conversations
sampleSizeinteger
Number of conversations to sample per run (1-100)
frequencyDaysinteger
How often to run, in days (1-365)
excludeGroupIdsstring[]optional
IDs of groups to exclude from this checkup
onlyStartedInPeriodbooleanoptional
Only scan conversations that started in this period
githubTokenstringoptional
Optional GitHub Personal Access Token to let Vivi create issues in your repository
githubRepostringoptional
Optional GitHub repository in owner/repo format (e.g. 'owner/repo')
recipientEmailsstring[]optional
Optional explicit list of email recipients for this checkup. When provided, summary emails are sent exclusively to these addresses instead of account admins.
billingTokenstringoptional
Optional opaque delegated billing token forwarded when triggering Vivi for this checkup.
lastRunAtnumberoptional
Optional initial lastRunAt timestamp (Unix ms) to schedule the first run after frequencyDays.

Response

oktrue
checkupIdstring
ID of the created checkup

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createCheckup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "groupId": "...",
          "interests": "...",
          "sampleSize": "...",
          "frequencyDays": "...",
          "excludeGroupIds": [
              "..."
          ],
          "onlyStartedInPeriod": true,
          "githubToken": "...",
          "githubRepo": "...",
          "recipientEmails": [
              "..."
          ],
          "billingToken": "...",
          "lastRunAt": 0
      }
  }),
});

getCheckup

Auth Required

Request Payload

checkupIdstring
ID of the checkup to retrieve

Response

oktrue
checkupobject
idstring
groupIdstring
interestsstring
sampleSizenumber
frequencyDaysnumber
lastRunAtnumberoptional
onlyStartedInPeriodbooleanoptional
githubRepostringoptional
hasGithubTokenboolean
recipientEmailsstring[]optional
excludeGroupIdsstring[]

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getCheckup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "checkupId": "..."
      }
  }),
});

updateCheckup

Auth Required

Request Payload

checkupIdstring
ID of the checkup to update
groupIdstringoptional
Updated group ID
interestsstringoptional
Updated description of what to look for
sampleSizeintegeroptional
Updated sample size (1-100)
frequencyDaysintegeroptional
Updated frequency in days (1-365)
excludeGroupIdsstring[]optional
Updated list of group IDs to exclude
onlyStartedInPeriodbooleanoptional
Only scan conversations that started in this period
githubTokenstringoptional
Optional GitHub Personal Access Token to let Vivi create issues in your repository
githubRepostringoptional
Optional GitHub repository in owner/repo format (e.g. 'owner/repo')
recipientEmailsstring[]optional
Updated list of explicit email recipients for this checkup.
billingTokenstringoptional
Updated opaque delegated billing token for this checkup.

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "updateCheckup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "checkupId": "...",
          "groupId": "...",
          "interests": "...",
          "sampleSize": "...",
          "frequencyDays": "...",
          "excludeGroupIds": [
              "..."
          ],
          "onlyStartedInPeriod": true,
          "githubToken": "...",
          "githubRepo": "...",
          "recipientEmails": [
              "..."
          ],
          "billingToken": "..."
      }
  }),
});

deleteCheckup

Auth Required

Request Payload

checkupIdstring
ID of the checkup to delete

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "deleteCheckup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "checkupId": "..."
      }
  }),
});

deleteGroup

Auth Required

Request Payload

groupIdstring
ID of the group to delete
deleteSharedConversationsbooleanoptional
When true, delete all conversations in this group even if they are also linked to other groups

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "deleteGroup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "groupId": "...",
          "deleteSharedConversations": true
      }
  }),
});

deleteConversation

Auth Required

Request Payload

conversationIdstringoptional
ID of the conversation to delete
conversationNamestringoptional
Canonical name of the conversation to delete (deletes all matching conversations in the account)

Response

oktrue
deletedCountnumber

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "deleteConversation",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "conversationId": "...",
          "conversationName": "..."
      }
  }),
});

runCheckup

Auth Required

Request Payload

checkupIdstring
ID of the checkup to run now

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "runCheckup",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "checkupId": "..."
      }
  }),
});

cronStatus

Auth Required

Request Payload

No parameters required

Response

oktrue
lastRununknownoptional
lastStatusunknownoptional
lastErrorunknownoptional

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "cronStatus",
      "token": "YOUR_API_TOKEN",
      "payload": {}
  }),
});

triggerCron

Auth Required

Request Payload

No parameters required

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "triggerCron",
      "token": "YOUR_API_TOKEN",
      "payload": {}
  }),
});

translate

Auth Required

Request Payload

messagesobject[]
Messages to translate to English
idstring
Message ID
textstring
Message text to translate

Response

oktrue
translationsobject[]
Translations in the same order as input
idstring
Message ID
translatedTextstring
Translated text

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "translate",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "messages": [
              {
                  "id": "...",
                  "text": "..."
              }
          ]
      }
  }),
});

listReports

Auth Required

Request Payload

checkupIdstringoptional
Filter reports by checkup ID
limitnumberoptional
Maximum number of reports to return (default: 20)

Response

oktrue
reportsobject[]
Reports ordered by creation date descending
idstring
Report ID
contentstring
Markdown report content
createdAtnumber
Creation timestamp
conversationIdsstring
JSON array of sampled conversation IDs
checkupunknownoptional
Associated checkup data

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "listReports",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "checkupId": "...",
          "limit": 0
      }
  }),
});

createSnapshot

Request Payload

sessionTokenstring
InstantDB session (refresh) token of the logged-in user
conversationIdstring
ID of the conversation to create a public snapshot from

Response

oktrue
snapshotIdstring
ID of the created snapshot

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createSnapshot",
      "payload": {
          "sessionToken": "...",
          "conversationId": "..."
      }
  }),
});

getSnapshot

Request Payload

snapshotIdstring
UUID of the snapshot to view
sessionTokenstringoptional
Optional InstantDB session token to check delete permission

Response

oktrue
snapshotobject
idstring
createdAtnumber
messagesJsonstring
canDeleteboolean

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getSnapshot",
      "payload": {
          "snapshotId": "...",
          "sessionToken": "..."
      }
  }),
});

deleteSnapshot

Request Payload

sessionTokenstring
InstantDB session (refresh) token of an account admin
snapshotIdstring
UUID of the snapshot to delete

Response

oktrue

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "deleteSnapshot",
      "payload": {
          "sessionToken": "...",
          "snapshotId": "..."
      }
  }),
});

getBillingStatus

Auth Required

Request Payload

No parameters required

Response

oktrue
planstring
statusstring
currentPeriodEndnumberoptional
cancelAtPeriodEndboolean
hasStripeCustomerboolean
grandfatheredboolean
usageobject
monthlyMessagesnumber
monthlyMessageLimitunknown
checkupsCountnumber

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "getBillingStatus",
      "token": "YOUR_API_TOKEN",
      "payload": {}
  }),
});

createCheckoutSession

Auth Required

Request Payload

planstring
Subscription tier to subscribe to
intervalstringoptional
Billing interval ('month' default, or 'year' for 2 months free)
successUrlstringoptional
Optional same-origin URL to redirect to after successful checkout
cancelUrlstringoptional
Optional same-origin URL to redirect to if checkout is cancelled

Response

oktrue
urlstring
Stripe Checkout URL
sessionIdstring
Stripe Checkout Session ID

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createCheckoutSession",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "plan": "...",
          "interval": "...",
          "successUrl": "...",
          "cancelUrl": "..."
      }
  }),
});

createBillingPortalSession

Auth Required

Request Payload

returnUrlstringoptional
Optional same-origin URL to return to after exiting the Stripe Billing Portal

Response

oktrue
urlstring
Stripe Billing Portal URL

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "createBillingPortalSession",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "returnUrl": "..."
      }
  }),
});

syncBillingSession

Auth Required

Request Payload

sessionIdstring
Stripe Checkout Session ID to verify and sync

Response

oktrue
planstring
statusstring
currentPeriodEndnumberoptional
cancelAtPeriodEndboolean
hasStripeCustomerboolean
grandfatheredboolean
usageobject
monthlyMessagesnumber
monthlyMessageLimitunknown
checkupsCountnumber

Example

fetch("https://api.view-chat.com", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
      "endpoint": "syncBillingSession",
      "token": "YOUR_API_TOKEN",
      "payload": {
          "sessionId": "..."
      }
  }),
});

Error Handling

On error, the API returns HTTP 400 with { error: "message" }. Common errors include invalid token, missing required fields, and invalid input format.