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 RequiredRequest Payload
eventobjectThe message event to log
fromstringWho sent the message
fromAvatarstringoptionalOptional HTTP(S) URL of the sender's avatar image
textstringMessage content
timenumberUnix timestamp in milliseconds
foreignIdstringoptionalClient-provided unique message ID for deduplication
conversationstringoptionalConversation name. Created automatically if it doesn't exist. Mutually exclusive with conversationId.
conversationIdstringoptionalExisting conversation ID. Must already exist; returns an error if not. Mutually exclusive with conversation.
groupsstring[]optionalGroup names to assign. Groups are created automatically if they don't exist. Mutually exclusive with groupIds.
groupIdsstring[]optionalGroup IDs to assign. Groups must already exist. Mutually exclusive with groups.
recipientsstring[]optionalOptional intended recipient names or identifiers for this conversation (e.g. proactive outreach before they reply). Displayed and searchable until they send a message.
Response
oktrueExample
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 RequiredRequest Payload
namestringName for the new group
Response
oktruegroupIdstringID 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 RequiredRequest Payload
groupIdstringID of the group to rename
namestringNew name for the group
Response
oktrueExample
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 RequiredRequest Payload
emailstringEmail address of the viewer to add
groupIdstringID of the group to add the viewer to
Response
oktrueExample
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 RequiredRequest Payload
emailstringEmail address of the viewer to remove
groupIdstringID of the group to remove the viewer from
Response
oktrueExample
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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
Response
oktrueaccountIdstringID 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 RequiredRequest Payload
emailstringEmail address of the admin to add
Response
oktrueExample
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 RequiredRequest Payload
emailstringEmail address of the admin to remove
Response
oktrueExample
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 RequiredRequest Payload
No parameters required
Response
oktrueemailsstring[]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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
Response
oktrueinvitesobject[]accountIdstringExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "listPendingAdminInvites",
"payload": {
"sessionToken": "..."
}
}),
});acceptAccountAdminInvite
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
accountIdstringAccount ID of the invitation to accept
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "acceptAccountAdminInvite",
"payload": {
"sessionToken": "...",
"accountId": "..."
}
}),
});declineAccountAdminInvite
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
accountIdstringAccount ID of the invitation to decline
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "declineAccountAdminInvite",
"payload": {
"sessionToken": "...",
"accountId": "..."
}
}),
});getMessages
Auth RequiredRequest Payload
conversationIdstringConversation ID
groupIdstringoptionalOptional group ID that the conversation must belong to
sincenumberoptionalOnly return messages with time >= this Unix timestamp in milliseconds
untilnumberoptionalOnly return messages with time <= this Unix timestamp in milliseconds
limitnumberoptionalMaximum number of messages to return (default: 100, max: 200)
offsetnumberoptionalNumber of messages to skip for pagination (default: 0)
Response
oktruemessagesobject[]Messages in this conversation, ordered by time ascending
idstringMessage ID
fromstringMessage sender
fromAvatarstringoptionalSender avatar image URL, if logged
textstringMessage text
timenumberUnix timestamp in milliseconds
timeIsostringISO 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 RequiredRequest Payload
groupIdstringoptionalFilter by group ID
limitnumberoptionalMaximum number of conversations to return (default: 25, max: 100)
offsetnumberoptionalNumber of conversations to skip for pagination (default: 0)
sincenumberoptionalOnly return conversations with lastMessageTime >= this Unix timestamp in milliseconds
untilnumberoptionalOnly return conversations with lastMessageTime <= this Unix timestamp in milliseconds
participantstringoptionalFilter conversations that have messages from this participant (case-insensitive substring match)
Response
oktrueconversationsobject[]List of conversations for this account
idstringConversation ID
namestringConversation name
lastMessageTimenumberoptionalTimestamp of the last message (Unix ms)
lastMessageTimeIsostringoptionalISO 8601 timestamp string (UTC) of the last message, equivalent to `lastMessageTime`
participantsstring[]optionalParticipants who have sent messages in this conversation
participantAvatarsobjectoptionalMap of participant name to avatar image URL
recipientsstring[]optionalKnown recipients who have not yet sent a message in this conversation
groupsobject[]Groups this conversation belongs to
idstringGroup ID
namestringGroup 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 RequiredRequest Payload
groupIdstringoptionalFilter by group ID
sincenumberOnly return analytics at or after this Unix timestamp in milliseconds
untilnumberoptionalOnly return analytics at or before this Unix timestamp in milliseconds
Response
oktruechatsPerDayobject[]datestringUTC day in YYYY-MM-DD format
valuenumberConversation count for the day
participantsPerDayobject[]datestringUTC day in YYYY-MM-DD format
valuenumberUnique participant count for the day
messagesPerDayobject[]datestringUTC day in YYYY-MM-DD format
valuenumberMessage count for the day
latencyByParticipantobjectResponse 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 RequiredRequest Payload
namestringA label for the token (e.g. 'production', 'staging')
groupIdsstring[]optionalOptional group IDs to restrict this token to. If not provided or empty, the token has access to all groups in the account.
totpCodestringoptional6-digit authenticator app code (required when 2FA is enabled on the account)
Response
oktruetokenstringThe full token value to use for API calls
tokenIdstringThe 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 RequiredRequest Payload
No parameters required
Response
oktruetokensobject[]All tokens for this account
idstringToken record ID
namestringToken label
createdAtnumberCreation timestamp
revokedAtnumberoptionalRevocation timestamp, if revoked
tokenstringThe full token value
groupsobject[]optionalGroups this token is restricted to, if any
idstringGroup ID
namestringGroup 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 RequiredRequest Payload
tokenIdstringID of the token to revoke
Response
oktrueExample
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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
namestringA label for the token
totpCodestringoptional6-digit authenticator app code (required when 2FA is enabled for this user)
Response
oktruetokenstringThe full personal access token value. Shown only once — it is not retrievable later.
tokenIdstringThe 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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
Response
oktruetokensobject[]All personal access tokens for this user
idstringToken record ID
namestringToken label
createdAtnumberCreation timestamp
maskedTokenstringMasked 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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
tokenIdstringID of the token to delete
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "deleteUserToken",
"payload": {
"sessionToken": "...",
"tokenId": "..."
}
}),
});getTotpStatus
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
Response
oktrueenabledbooleanExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "getTotpStatus",
"payload": {
"sessionToken": "..."
}
}),
});beginTotpSetup
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
Response
oktruesecretstringotpauthUristringExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "beginTotpSetup",
"payload": {
"sessionToken": "..."
}
}),
});confirmTotpSetup
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
totpCodestring6-digit code from authenticator app
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "confirmTotpSetup",
"payload": {
"sessionToken": "...",
"totpCode": "..."
}
}),
});disableTotp
Request Payload
sessionTokenstringInstantDB session (refresh) token of the logged-in user
totpCodestring6-digit code from authenticator app
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "disableTotp",
"payload": {
"sessionToken": "...",
"totpCode": "..."
}
}),
});createCheckup
Auth RequiredRequest Payload
groupIdstringID of the group to monitor
interestsstringoptionalDescription of what to look for in conversations
sampleSizeintegerNumber of conversations to sample per run (1-100)
frequencyDaysintegerHow often to run, in days (1-365)
excludeGroupIdsstring[]optionalIDs of groups to exclude from this checkup
onlyStartedInPeriodbooleanoptionalOnly scan conversations that started in this period
githubTokenstringoptionalOptional GitHub Personal Access Token to let Vivi create issues in your repository
githubRepostringoptionalOptional GitHub repository in owner/repo format (e.g. 'owner/repo')
recipientEmailsstring[]optionalOptional explicit list of email recipients for this checkup. When provided, summary emails are sent exclusively to these addresses instead of account admins.
billingTokenstringoptionalOptional opaque delegated billing token forwarded when triggering Vivi for this checkup.
lastRunAtnumberoptionalOptional initial lastRunAt timestamp (Unix ms) to schedule the first run after frequencyDays.
Response
oktruecheckupIdstringID 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 RequiredRequest Payload
checkupIdstringID of the checkup to retrieve
Response
oktruecheckupobjectidstringgroupIdstringinterestsstringsampleSizenumberfrequencyDaysnumberlastRunAtnumberoptionalonlyStartedInPeriodbooleanoptionalgithubRepostringoptionalhasGithubTokenbooleanrecipientEmailsstring[]optionalexcludeGroupIdsstring[]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 RequiredRequest Payload
checkupIdstringID of the checkup to update
groupIdstringoptionalUpdated group ID
interestsstringoptionalUpdated description of what to look for
sampleSizeintegeroptionalUpdated sample size (1-100)
frequencyDaysintegeroptionalUpdated frequency in days (1-365)
excludeGroupIdsstring[]optionalUpdated list of group IDs to exclude
onlyStartedInPeriodbooleanoptionalOnly scan conversations that started in this period
githubTokenstringoptionalOptional GitHub Personal Access Token to let Vivi create issues in your repository
githubRepostringoptionalOptional GitHub repository in owner/repo format (e.g. 'owner/repo')
recipientEmailsstring[]optionalUpdated list of explicit email recipients for this checkup.
billingTokenstringoptionalUpdated opaque delegated billing token for this checkup.
Response
oktrueExample
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 RequiredRequest Payload
checkupIdstringID of the checkup to delete
Response
oktrueExample
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 RequiredRequest Payload
groupIdstringID of the group to delete
deleteSharedConversationsbooleanoptionalWhen true, delete all conversations in this group even if they are also linked to other groups
Response
oktrueExample
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 RequiredRequest Payload
conversationIdstringoptionalID of the conversation to delete
conversationNamestringoptionalCanonical name of the conversation to delete (deletes all matching conversations in the account)
Response
oktruedeletedCountnumberExample
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 RequiredRequest Payload
checkupIdstringID of the checkup to run now
Response
oktrueExample
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 RequiredRequest Payload
No parameters required
Response
oktruelastRununknownoptionallastStatusunknownoptionallastErrorunknownoptionalExample
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 RequiredRequest Payload
No parameters required
Response
oktrueExample
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 RequiredRequest Payload
messagesobject[]Messages to translate to English
idstringMessage ID
textstringMessage text to translate
Response
oktruetranslationsobject[]Translations in the same order as input
idstringMessage ID
translatedTextstringTranslated 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 RequiredRequest Payload
checkupIdstringoptionalFilter reports by checkup ID
limitnumberoptionalMaximum number of reports to return (default: 20)
Response
oktruereportsobject[]Reports ordered by creation date descending
idstringReport ID
contentstringMarkdown report content
createdAtnumberCreation timestamp
conversationIdsstringJSON array of sampled conversation IDs
checkupunknownoptionalAssociated 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
sessionTokenstringInstantDB session (refresh) token of the logged-in user
conversationIdstringID of the conversation to create a public snapshot from
Response
oktruesnapshotIdstringID 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
snapshotIdstringUUID of the snapshot to view
sessionTokenstringoptionalOptional InstantDB session token to check delete permission
Response
oktruesnapshotobjectidstringcreatedAtnumbermessagesJsonstringcanDeletebooleanExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "getSnapshot",
"payload": {
"snapshotId": "...",
"sessionToken": "..."
}
}),
});deleteSnapshot
Request Payload
sessionTokenstringInstantDB session (refresh) token of an account admin
snapshotIdstringUUID of the snapshot to delete
Response
oktrueExample
fetch("https://api.view-chat.com", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"endpoint": "deleteSnapshot",
"payload": {
"sessionToken": "...",
"snapshotId": "..."
}
}),
});getBillingStatus
Auth RequiredRequest Payload
No parameters required
Response
oktrueplanstringstatusstringcurrentPeriodEndnumberoptionalcancelAtPeriodEndbooleanhasStripeCustomerbooleangrandfatheredbooleanusageobjectmonthlyMessagesnumbermonthlyMessageLimitunknowncheckupsCountnumberExample
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 RequiredRequest Payload
planstringSubscription tier to subscribe to
intervalstringoptionalBilling interval ('month' default, or 'year' for 2 months free)
successUrlstringoptionalOptional same-origin URL to redirect to after successful checkout
cancelUrlstringoptionalOptional same-origin URL to redirect to if checkout is cancelled
Response
oktrueurlstringStripe Checkout URL
sessionIdstringStripe 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 RequiredRequest Payload
returnUrlstringoptionalOptional same-origin URL to return to after exiting the Stripe Billing Portal
Response
oktrueurlstringStripe 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 RequiredRequest Payload
sessionIdstringStripe Checkout Session ID to verify and sync
Response
oktrueplanstringstatusstringcurrentPeriodEndnumberoptionalcancelAtPeriodEndbooleanhasStripeCustomerbooleangrandfatheredbooleanusageobjectmonthlyMessagesnumbermonthlyMessageLimitunknowncheckupsCountnumberExample
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.