FastComments.com

FastComments JavaScript/TypeScript SDK


這是 FastComments 的官方 JavaScript/TypeScript SDK。

可從 Node.js 或瀏覽器管理評論、使用者、SSO(單一登入)和審核。

儲存庫

在 GitHub 上查看


安裝 Internal Link

npm

npm install fastcomments-sdk

API 文件 Internal Link


完整的 API 參考: docs/api/README.md

瀏覽器與伺服器相容性 Internal Link


此 SDK 使用 雙入口點 以確保最佳相容性並避免執行時錯誤:

  • fastcomments-sdk/browser - 瀏覽器安全的版本,使用原生 fetch
  • fastcomments-sdk/server - 完整的 Node.js 版本,支援 SSO
  • fastcomments-sdk (default) - 僅型別,能安全在任何地方匯入

公開 API 與受保護 API Internal Link

此 SDK 提供三個主要的 API 類別:

  • DefaultApi - 需要您的 API 金鑰進行驗證的受保護端點。用於伺服器端操作。
  • PublicApi - 可在無需 API 金鑰的情況下存取的公開端點。可直接從瀏覽器/行動裝置等呼叫。
  • HiddenApi - 供內部/管理用途的端點,適用於進階使用情境。

範例:使用 Public API(瀏覽器安全)

import { PublicApi } from 'fastcomments-sdk/browser';

const publicApi = new PublicApi();

// 取得頁面評論(不需要 API 金鑰)
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id'
});

範例:使用 Default API(僅限伺服器端)

import { DefaultApi, Configuration } from 'fastcomments-sdk/server';

const config = new Configuration({
  apiKey: 'your-api-key' // 請保密!
});
const defaultApi = new DefaultApi(config);

// 以完整管理權限取得評論
const response = await defaultApi.getComments({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id'
});

SSO(單一登入)整合 Internal Link

FastComments 支援 SSO 以整合您現有的使用者認證系統。 SSO 功能僅在伺服器端匯出時可用,因為它需要 Node.js 的 crypto 功能。

Simple SSO (Server-Side Only)

簡易 SSO 應在伺服器端產生並傳送給客戶端:

// 伺服器端程式碼(Node.js/backend)
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

// 使用內建輔助函式建立簡易 SSO  
const userData = {
  username: 'john_doe',
  email: 'john@example.com',
  displayName: 'John Doe',
  avatar: 'https://example.com/avatar.jpg'
};

const sso = FastCommentsSSO.createSimple(userData, {
  loginURL: '/login',
  logoutURL: '/logout'
});

const ssoToken = sso.createToken();

// 將 ssoToken 傳送到你的客戶端程式碼
// 客戶端程式碼之後可以使用此 token 與瀏覽器 SDK

安全 SSO 應在伺服器端實作,並提供較佳的安全性:

// 伺服器端程式碼(Node.js/backend)
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

// 使用內建輔助函式建立安全 SSO
const userData = {
  id: 'user-123',
  email: 'john@example.com',
  username: 'john_doe',
  displayName: 'John Doe',
  avatar: 'https://example.com/avatar.jpg',
  isAdmin: false,
  isModerator: false
};

const sso = FastCommentsSSO.createSecure('your-api-key', userData, {
  loginURL: '/login',
  logoutURL: '/logout'
});

const ssoConfig = sso.prepareToSend();

// 用於伺服器上的 API 呼叫
const publicApi = new PublicApi();
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  sso: JSON.stringify(ssoConfig)
});

// 或將 ssoConfig 傳送給客戶端供瀏覽器使用

Using SSO from Browser (with Server-Generated Token)

// 客戶端程式碼(瀏覽器)
import { PublicApi } from 'fastcomments-sdk/browser';

// 從你的伺服器端點取得 SSO token
const ssoToken = await fetch('/api/sso-token').then(r => r.json());

const publicApi = new PublicApi();
const response = await publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  sso: ssoToken // 使用伺服器產生的 SSO token
});

SSO with Comment Creation

// 伺服器端:建立 SSO 與留言
import { FastCommentsSSO, PublicApi } from 'fastcomments-sdk/server';

const sso = FastCommentsSSO.createSecure('your-api-key', userData);
const ssoConfig = sso.prepareToSend();

const response = await publicApi.createCommentPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
  broadcastId: 'unique-broadcast-id',
  commentData: {
    comment: 'This is my comment',
    date: Date.now(),
    commenterName: 'John Doe',
    url: 'https://example.com/page',
    urlId: 'page-url-id'
  },
  sso: JSON.stringify(ssoConfig)
});

常見使用情境 Internal Link

取得頁面留言

const comments = await sdk.publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'article-123'
});

建立留言

const newComment = await sdk.publicApi.createCommentPublic({
  createCommentParams: {
    tenantId: 'your-tenant-id',
    urlId: 'article-123',
    comment: 'Great article!',
    commenterName: 'John Doe',
    commenterEmail: 'john@example.com'
  }
});

對留言投票

const voteResponse = await sdk.publicApi.voteComment({
  voteBodyParams: {
    commentId: 'comment-id',
    direction: 1 // 1 表示讚,-1 表示踩
  }
});

使用者管理(需要 API 金鑰)

// 搜尋使用者(需要 DefaultApi)
const users = await sdk.defaultApi.searchUsers({
  tenantId: 'your-tenant-id',
  urlId: 'page-id',
  usernameStartsWith: 'john'
});

即時事件(即時更新) Internal Link

訂閱即時事件以獲取有關留言、點讚和其他活動的即時更新。

頁面層級事件

監聽特定頁面的即時事件(留言、點讚等):

import { subscribeToChanges, LiveEvent, LiveEventType } from 'fastcomments-sdk/browser';

const config = {
  tenantId: 'your-tenant-id',
  urlId: 'page-url-id',
};

// 訂閱該頁面的即時事件
const subscription = subscribeToChanges(
  config,
  'your-tenant-id', // tenantIdWS(租戶 ID)
  'page-url-id',    // urlIdWS(頁面 URL ID)  
  'user-session-id', // userIdWS(從 getComments 回應取得)
  (event: LiveEvent) => {
    console.log('Live event received:', event);
    
    switch (event.type) {
      case LiveEventType.new_comment:
        console.log('New comment:', event.comment);
        // 使用新留言更新您的介面
        break;
      case LiveEventType.new_vote:
        console.log('New vote:', event.vote);
        // 在介面中更新票數
        break;
      case LiveEventType.updated_comment:
        console.log('Comment updated:', event.comment);
        break;
      default:
        console.log('Other event type:', event.type);
    }
    
    return true; // 若事件已處理則回傳 true
  },
  (isConnected: boolean) => {
    console.log('Connection status:', isConnected ? 'Connected' : 'Disconnected');
  }
);

// 完成後關閉訂閱
subscription.close();

訂閱使用者事件

監聽與特定使用者相關的事件(通知、提及等):

import { subscribeToUserFeed, LiveEvent, LiveEventType } from 'fastcomments-sdk/browser';

const userConfig = {
  userIdWS: 'user-session-id', // 從 getComments 回應取得
};

// 訂閱使用者的個人資訊流
const userSubscription = subscribeToUserFeed(
  userConfig,
  (event: LiveEvent) => {
    console.log('User event received:', event);
    
    switch (event.type) {
      case LiveEventType.notification:
        console.log('New notification:', event.notification);
        // 在您的介面中顯示通知
        break;
      case LiveEventType.notification_update:
        console.log('Notification updated:', event.notification);
        break;
      default:
        console.log('Other user event:', event.type);
    }
    
    return true;
  },
  (isConnected: boolean) => {
    console.log('User feed connection:', isConnected ? 'Connected' : 'Disconnected');
  }
);

// 完成後關閉
userSubscription.close();

取得 userIdWS

參數 userIdWS 為即時事件所需,可從 API 回應中取得:

const response = await sdk.publicApi.getCommentsPublic({
  tenantId: 'your-tenant-id',
  urlId: 'page-id'
});

// 從回應中擷取 userIdWS
const userIdWS = response.data?.userSessionInfo?.userIdWS;

if (userIdWS) {
  // 現在您可以訂閱即時事件
  const subscription = subscribeToChanges(config, tenantIdWS, urlIdWS, userIdWS, handleEvent);
}

廣播 ID Internal Link

你會看到在某些 API 呼叫中應該傳入 broadcastId。當你接收事件時,你會得到這個 ID 回傳,因此如果你打算在客戶端採取樂觀更新(你很可能會想這麼做,因為它提供最佳體驗),你就會知道要忽略該事件。請在此傳入 UUID。該 ID 應該足夠唯一,以免在瀏覽器會話中出現兩次。

import { v4 as uuidv4 } from 'uuid';

const response = await sdk.publicApi.createCommentPublic({
  createCommentParams: {
    tenantId: 'your-tenant-id',
    urlId: 'page-id',
    comment: 'My comment',
    broadcastId: uuidv4() // 此操作的唯一識別碼
  }
});

錯誤處理 Internal Link

try {
  const comments = await sdk.publicApi.getCommentsPublic({
    tenantId: 'your-tenant-id',
    urlId: 'page-id'
  });
} catch (error) {
  if (error.response?.status === 404) {
    console.log('Page not found');
  } else {
    console.error('API Error:', error.message);
  }
}

彙總 Internal Link

透過分組(若提供 groupBy)並應用多個操作來彙總文件。支援不同的操作(例如 sum、countDistinct、avg 等)。

參數

名稱類型是否必填描述
tenantIdstring
aggregationRequestAggregationRequest
parentTenantIdstring
includeStatsboolean

回應

回傳:Aggregate200Response

範例

aggregate 範例
Copy Copy
1
2const tenantId: string = 'tenant_78a9';
3const parentTenantId: string = 'parent_tenant_01';
4const includeStats: boolean = true;
5const aggregationRequest: AggregationRequest = {
6 operation: { type: 'COUNT' },
7 groupBy: ['pageUrl'],
8 predicate: { field: 'status', operator: 'EQUALS', value: 'approved' },
9 sort: [{ field: 'count', direction: 'DESC' }],
10 limit: 25
11};
12const result: Aggregate200Response = await aggregate(tenantId, aggregationRequest, parentTenantId, includeStats);
13

取得稽核記錄 Internal Link

參數

名稱類型必填描述
tenantIdstring
limitnumber
skipnumber
orderSORTDIR
afternumber
beforenumber

回應

回傳: GetAuditLogs200Response

範例

getAuditLogs 範例
Copy Copy
1
2const tenantId: string = 'tenant_5f8d7c3a';
3const limit: number = 100;
4const skip: number = 0;
5const order: SORTDIR = 'DESC' as SORTDIR;
6const after: number = Date.now() - 7 * 24 * 60 * 60 * 1000; // 一週前
7const before: number = Date.now();
8const result: GetAuditLogs200Response = await getAuditLogs(tenantId, limit, skip, order, after, before);
9

從留言封鎖(公開) Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
publicBlockFromCommentParamsPublicBlockFromCommentParams
ssostring

回應

回傳:BlockFromCommentPublic200Response

範例

blockFromCommentPublic 範例
Copy Copy
1
2const tenantId: string = 'tenant_6b3f9a2d';
3const commentId: string = 'cmt_8f4b12a9';
4const publicBlockFromCommentParams: PublicBlockFromCommentParams = {
5 reason: 'Repeated promotional links',
6 durationMinutes: 60 * 24 * 30, // 30 天
7 escalateToModeration: true
8};
9const sso: string = 'sso_token_3fH7kLw';
10
11const result: BlockFromCommentPublic200Response = await blockFromCommentPublic(tenantId, commentId, publicBlockFromCommentParams, sso);
12

解除封鎖公開留言 Internal Link


參數

名稱類型必填描述
tenantIdstring
commentIdstring
publicBlockFromCommentParamsPublicBlockFromCommentParams
ssostring

回應

回傳:UnBlockCommentPublic200Response

範例

unBlockCommentPublic 範例
Copy Copy
1
2const tenantId: string = "tenant-42-production";
3const commentId: string = "comment_7f3b2a9d";
4const publicBlockFromCommentParams: PublicBlockFromCommentParams = {
5 reason: "flag reviewed and determined not to violate policy",
6 restoredBy: "moderator_jane",
7 restoredAt: new Date().toISOString()
8};
9const sso: string = "sso_token_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
10const result: UnBlockCommentPublic200Response = await unBlockCommentPublic(tenantId, commentId, publicBlockFromCommentParams, sso);
11

檢查被封鎖的留言 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdsstring
ssostring

回應

回傳: CheckedCommentsForBlocked200Response

範例

checkedCommentsForBlocked 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_fa3b2c9e';
4 const commentIds: string = 'cmt_112233,cmt_445566';
5 const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0Njc4IiwidGVuYW50IjoidGVuYW50X2ZhM2IifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
6 const resultWithSSO: CheckedCommentsForBlocked200Response = await checkedCommentsForBlocked(tenantId, commentIds, sso);
7 const resultWithoutSSO: CheckedCommentsForBlocked200Response = await checkedCommentsForBlocked(tenantId, commentIds);
8 console.log(resultWithSSO, resultWithoutSSO);
9})();
10

從留言封鎖使用者 Internal Link

參數

名稱型別必填說明
tenantIdstring
idstring
blockFromCommentParamsBlockFromCommentParams
userIdstring
anonUserIdstring

回應

回傳: BlockFromCommentPublic200Response

範例

blockUserFromComment 範例
Copy Copy
1
2const tenantId: string = "tenant_7f3b4c";
3const id: string = "comment_9a8b7c6d";
4const blockFromCommentParams: BlockFromCommentParams = {
5 reason: "Repeated spam links",
6 durationHours: 168,
7 notifyModerators: true
8};
9const userId: string | undefined = "user_42";
10const anonUserId: string | undefined = undefined;
11const result: BlockFromCommentPublic200Response = await blockUserFromComment(tenantId, id, blockFromCommentParams, userId, anonUserId);
12

建立公開留言 Internal Link

參數

名稱型別必填描述
tenantIdstring
urlIdstring
broadcastIdstring
commentDataCommentData
sessionIdstring
ssostring

回應

回傳: CreateCommentPublic200Response

範例

createCommentPublic 範例
Copy Copy
1
2const tenantId: string = 'tenant_9a1b2c';
3const urlId: string = 'https://www.news-site.com/article/67890';
4const broadcastId: string = 'broadcast_2026-06-15-01';
5const sessionId: string | undefined = 'sess_abc123xyz';
6const sso: string | undefined = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiam9yZGFuIiwiaWF0IjoxNjI0MDAwMDB9.signature';
7const commentData: CommentData = {
8 content: 'Insightful piece — I appreciated the data-backed points and sources cited.',
9 authorDisplayName: 'Jordan Miles'
10} as CommentData;
11const result: CreateCommentPublic200Response = await createCommentPublic(tenantId, urlId, broadcastId, commentData, sessionId, sso);
12

刪除留言 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring
contextUserIdstring
isLiveboolean

回應

回傳:DeleteComment200Response

範例

deleteComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_84a9f2';
3const id: string = 'comment_5f3b21';
4const contextUserId: string | undefined = 'user_1122';
5const isLive: boolean | undefined = true;
6
7async function run(): Promise<void> {
8 const result: DeleteComment200Response = await deleteComment(tenantId, id, contextUserId, isLive);
9 console.log(result);
10}
11
12run();
13

刪除公開留言 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
broadcastIdstring
editKeystring
ssostring

回應

回傳:DeleteCommentPublic200Response

範例

deleteCommentPublic 範例
Copy Copy
1
2const tenantId: string = 'tenant_acme_42';
3const commentId: string = 'c0mment-9f8b7a6';
4const broadcastId: string = 'site_homepage_2026-06-15';
5const editKey: string = 'ek_3b7a1f59-4d2c-11eb-8dcd-0242ac130003';
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fakePayload.signature';
7
8const result: DeleteCommentPublic200Response = await deleteCommentPublic(tenantId, commentId, broadcastId, editKey, sso);
9

刪除留言投票 Internal Link

參數

名稱類型必需說明
tenantIdstring
commentIdstring
voteIdstring
urlIdstring
broadcastIdstring
editKeystring
ssostring

回應

回傳: DeleteCommentVote200Response

範例

deleteCommentVote 範例
Copy Copy
1
2const tenantId: string = 'tenant_8f3a2b7c';
3const commentId: string = 'cmt-5a1f3d92';
4const voteId: string = 'vote-3b9c7e1a';
5const urlId: string = 'articles/2026/06/typescript-best-practices';
6const broadcastId: string = 'broadcast-77f4d2';
7const editKey: string = 'edk-9b2f4c';
8const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload.signature';
9const result: DeleteCommentVote200Response = await deleteCommentVote(tenantId, commentId, voteId, urlId, broadcastId, editKey, sso);
10

檢舉留言 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring
userIdstring
anonUserIdstring

回應

回傳: FlagComment200Response

範例

flagComment 範例
Copy Copy
1
2const tenantId: string = "tenant_4f21c9a";
3const commentId: string = "cmt_7a12b3e9";
4const userId: string = "user_82bd123";
5const result: FlagComment200Response = await flagComment(tenantId, commentId, userId);
6

取得留言 Internal Link

參數

名稱型別必填說明
tenantIdstring
idstring

回應

回傳: GetComment200Response

範例

getComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_6f1a2b';
3const commentId: string = 'cmt_4d9e8f';
4const includeReplies: boolean | undefined = true; // 可選參數範例(未傳遞給 getComment)
5const result: GetComment200Response = await getComment(tenantId, commentId);
6console.log('Fetched comment for tenant:', tenantId, 'comment id:', commentId);
7console.log('API response received:', result);
8

取得留言列表 Internal Link

參數

名稱類型必填描述
tenantIdstring
pagenumber
limitnumber
skipnumber
asTreeboolean
skipChildrennumber
limitChildrennumber
maxTreeDepthnumber
urlIdstring
userIdstring
anonUserIdstring
contextUserIdstring
hashTagstring
parentIdstring
directionSortDirections
fromDatenumber
toDatenumber

回應

回傳:GetComments200Response

範例

getComments 範例
Copy Copy
1
2const tenantId: string = "tenant_9a12b3";
3const response: GetComments200Response = await getComments(tenantId, 1, 20, 0, true, 0, 3, 2, "https://mysite.com/posts/678", undefined, undefined, undefined, undefined, "parent_987", undefined, 1716873600000, 1719552000000);
4

取得公開留言 Internal Link

req tenantId urlId

參數

名稱類型必填說明
tenantIdstring
urlIdstring
pagenumber
directionSortDirections
ssostring
skipnumber
skipChildrennumber
limitnumber
limitChildrennumber
countChildrenboolean
fetchPageForCommentIdstring
includeConfigboolean
countAllboolean
includei10nboolean
localestring
modulesstring
isCrawlerboolean
includeNotificationCountboolean
asTreeboolean
maxTreeDepthnumber
useFullTranslationIdsboolean
parentIdstring
searchTextstring
hashTagsArray
userIdstring
customConfigStrstring
afterCommentIdstring
beforeCommentIdstring

回應

回傳: GetCommentsPublic200Response

範例

getCommentsPublic 範例
Copy Copy
1
2const tenantId: string = 'acme-news';
3const urlId: string = '/articles/2026/fastcomments-update';
4const page: number = 1;
5const skip: number = 0;
6const limit: number = 25;
7const countChildren: boolean = true;
8const includeConfig: boolean = true;
9const result: GetCommentsPublic200Response = await getCommentsPublic(
10 tenantId,
11 urlId,
12 page,
13 undefined,
14 undefined,
15 skip,
16 undefined,
17 limit,
18 undefined,
19 countChildren,
20 undefined,
21 includeConfig
22);
23

取得留言內容 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
editKeystring
ssostring

回應

回傳: GetCommentText200Response

範例

getCommentText 範例
Copy Copy
1
2const tenantId: string = 'tenant_42b7e9';
3const commentId: string = 'cmt_9f3a2b';
4const editKey: string = 'edk_3f1b7c9d';
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
6
7const result: GetCommentText200Response = await getCommentText(tenantId, commentId, editKey, sso);
8

取得留言投票使用者名稱 Internal Link


參數

名稱類型必填說明
tenantIdstring
commentIdstring
dirnumber
ssostring

回應

回傳:GetCommentVoteUserNames200Response

範例

getCommentVoteUserNames 範例
Copy Copy
1
2const tenantId: string = "tenant_67890";
3const commentId: string = "comment_abc123";
4const dir: number = 1;
5const ssoToken: string = "sso-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
6
7const responseWithoutSSO: GetCommentVoteUserNames200Response = await getCommentVoteUserNames(tenantId, commentId, dir);
8const responseWithSSO: GetCommentVoteUserNames200Response = await getCommentVoteUserNames(tenantId, commentId, dir, ssoToken);
9

鎖定留言 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

回應

回傳: LockComment200Response

範例

lockComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_42f6c1';
3const commentId: string = 'cmt-9a8b7c';
4const broadcastId: string = 'brd_2026_06_15';
5const ssoToken: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1Njc4OSIsImlhdCI6MTY1MDAwMDB9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
6
7const lockedWithSso: LockComment200Response = await lockComment(tenantId, commentId, broadcastId, ssoToken);
8const lockedWithoutSso: LockComment200Response = await lockComment(tenantId, commentId, broadcastId);
9

置頂留言 Internal Link

參數

名稱類型必需說明
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

回應

回傳: PinComment200Response

範例

pinComment 範例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-72";
3const commentId: string = "cmt_8f3a2b4c9d";
4const broadcastId: string = "live_2026-06-15_21z";
5const ssoToken: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.fake.payload.signature";
6
7const responseNoSSO: PinComment200Response = await pinComment(tenantId, commentId, broadcastId);
8const responseWithSSO: PinComment200Response = await pinComment(tenantId, commentId, broadcastId, ssoToken);
9

儲存留言 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
createCommentParamsCreateCommentParams
isLiveboolean
doSpamCheckboolean
sendEmailsboolean
populateNotificationsboolean

回應

回傳:SaveComment200Response

範例

saveComment 範例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-42";
3const createCommentParams: CreateCommentParams = {
4 threadId: "article-2026-06-0142",
5 content: "Great write-up — I followed the migration steps and everything worked as described.",
6 userId: "u_9c72b",
7 userName: "Ava R.",
8 userAvatarUrl: "https://cdn.example.com/avatars/u_9c72b.png",
9 metadata: { platform: "web", locale: "en-US" }
10};
11const isLive: boolean = true;
12const doSpamCheck: boolean = true;
13const sendEmails: boolean = false;
14const populateNotifications: boolean = true;
15const result: SaveComment200Response = await saveComment(tenantId, createCommentParams, isLive, doSpamCheck, sendEmails, populateNotifications);
16

批次儲存留言 Internal Link

參數

名稱類型必填說明
tenantIdstring
createCommentParamsArray
isLiveboolean
doSpamCheckboolean
sendEmailsboolean
populateNotificationsboolean

回應

回傳: Array<SaveComment200Response

範例

saveCommentsBulk 範例
Copy Copy
1
2const tenantId: string = "tenant_42a1b7";
3const mentions: CommentUserMentionInfo[] = [{ userId: "user_2b9", displayName: "Alex Chen" }];
4const hashtags: CommentUserHashTagInfo[] = [{ tag: "performance" }];
5const createCommentParams: CreateCommentParams[] = [
6 {
7 content: "Thanks for the detailed article — the alternative approach worked for me.",
8 authorId: "user_8f3c2",
9 authorName: "Maya Patel",
10 authorEmail: "maya.patel@example.com",
11 url: "/articles/optimizing-ts-performance",
12 createdAt: new Date().toISOString(),
13 mentions,
14 hashtags
15 }
16];
17const isLive: boolean = true;
18const doSpamCheck: boolean = false;
19const sendEmails: boolean = true;
20const populateNotifications: boolean = true;
21const result: Array<SaveComment200Response> = await saveCommentsBulk(tenantId, createCommentParams, isLive, doSpamCheck, sendEmails, populateNotifications);
22

設定留言內容 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
broadcastIdstring
commentTextUpdateRequestCommentTextUpdateRequest
editKeystring
ssostring

回應

回傳:SetCommentText200Response

範例

setCommentText 範例
Copy Copy
1
2const tenantId: string = 'tenant_4f9a2b'
3const commentId: string = 'cmt-8421'
4const broadcastId: string = 'brd-2026-06-15'
5const commentTextUpdateRequest: CommentTextUpdateRequest = { text: 'Updated comment text to clarify the schedule.', mentions: [], hashtags: [] }
6const editKey: string = 'editkey_9b12'
7const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso.signature'
8const result: SetCommentText200Response = await setCommentText(tenantId, commentId, broadcastId, commentTextUpdateRequest, editKey, sso)
9

解除從留言封鎖使用者 Internal Link


參數

名稱類型必填描述
tenantIdstringYes
idstringYes
unBlockFromCommentParamsUnBlockFromCommentParamsYes
userIdstringNo
anonUserIdstringNo

回應

回傳: UnBlockCommentPublic200Response

範例

unBlockUserFromComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_7b9c2a';
3const id: string = 'comment_4f8e1d';
4const unBlockFromCommentParams: UnBlockFromCommentParams = {
5 reason: 'User submitted appeal and provided additional context',
6 effectiveAt: new Date().toISOString()
7};
8const userId: string = 'user_92a3f6';
9const result: UnBlockCommentPublic200Response = await unBlockUserFromComment(tenantId, id, unBlockFromCommentParams, userId);
10

解除留言檢舉 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
userIdstring
anonUserIdstring

回應

回傳: FlagComment200Response

範例

unFlagComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_8f3b2a1f';
3const commentId: string = 'cmt_20250614_01';
4const userId: string = 'user_47d2b9';
5const result: FlagComment200Response = await unFlagComment(tenantId, commentId, userId);
6

解除鎖定留言 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

回應

回傳: LockComment200Response

範例

unLockComment 範例
Copy Copy
1
2const tenantId: string = "tenant-8f3b2c4a";
3const commentId: string = "cmt_92a7f3e6";
4const broadcastId: string = "brd_1b4c9d20";
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyMTIzIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
6const result: LockComment200Response = await unLockComment(tenantId, commentId, broadcastId, sso);
7

取消置頂留言 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
commentIdstring
broadcastIdstring
ssostring

回應

回傳: PinComment200Response

範例

unPinComment 範例
Copy Copy
1
2const tenantId: string = "tenant_9f3b2c1a";
3const commentId: string = "comment_4d2e8a7f";
4const broadcastId: string = "broadcast_live_2026_06_15_18";
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.invalid-signature";
6const response: PinComment200Response = await unPinComment(tenantId, commentId, broadcastId, sso);
7console.log(response);
8

更新留言 Internal Link


參數

名稱類型必填描述
tenantIdstring
idstring
updatableCommentParamsUpdatableCommentParams
contextUserIdstring
doSpamCheckboolean
isLiveboolean

回應

回傳: FlagCommentPublic200Response

範例

updateComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f3c1b2a';
3const commentId: string = 'cmt_8d9f2a4b';
4const updatableCommentParams: UpdatableCommentParams = {
5 body: 'Updating this comment to clarify the feature behavior and include a timestamp.',
6 metadata: { category: 'support', editedReason: 'clarify instructions' },
7 visible: true
8};
9const contextUserId: string = 'user_42';
10const doSpamCheck: boolean = true;
11const result: FlagCommentPublic200Response = await updateComment(tenantId, commentId, updatableCommentParams, contextUserId, doSpamCheck);
12

對留言投票 Internal Link


參數

NameType必填Description
tenantIdstring
commentIdstring
urlIdstring
broadcastIdstring
voteBodyParamsVoteBodyParams
sessionIdstring
ssostring

回應

Returns: VoteComment200Response

範例

voteComment 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f9d2e';
3const commentId: string = '5a1d3f9b-2c4e-4a2b-bf7b-1234567890ab';
4const urlId: string = 'articles/2026/06/15/typescript-api-patterns';
5const broadcastId: string = 'broadcast-20260615-01';
6const voteBodyParams: VoteBodyParams = { vote: 'up' };
7const sessionId: string = 'sess_9d2f3b45';
8const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyXzEyMyIsImlhdCI6MTY5NzE2MDAwMH0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
9
10const response: VoteComment200Response = await voteComment(
11 tenantId,
12 commentId,
13 urlId,
14 broadcastId,
15 voteBodyParams,
16 sessionId,
17 sso
18);
19

取得使用者的留言 Internal Link

參數

名稱類型必填說明
userIdstring
directionSortDirections
repliesToUserIdstring
pagenumber
includei10nboolean
localestring
isCrawlerboolean

回應

回傳: GetCommentsForUser200Response

範例

getCommentsForUser 範例
Copy Copy
1
2const userId: string = "550e8400-e29b-41d4-a716-446655440000";
3const page: number = 2;
4const includei10n: boolean = true;
5const locale: string = "en-US";
6const isCrawler: boolean = false;
7
8const comments: GetCommentsForUser200Response = await getCommentsForUser(
9 userId,
10 undefined, // 已省略 direction
11 undefined, // 已省略 repliesToUserId
12 page,
13 includei10n,
14 locale,
15 isCrawler
16);
17
18console.log(comments);
19

新增網域設定 Internal Link


參數

名稱類型必填說明
tenantIdstring
addDomainConfigParamsAddDomainConfigParams

回應

回傳:AddDomainConfig200Response


刪除網域設定 Internal Link

參數

名稱類型必填說明
tenantIdstring
domainstring

回應

回傳: DeleteDomainConfig200Response

取得網域設定 Internal Link


參數

名稱類型必填說明
tenantIdstring
domainstring

回應

回傳: GetDomainConfig200Response


取得網域設定清單 Internal Link


參數

名稱類型必填說明
tenantIdstring

回應

回傳: GetDomainConfigs200Response


部分更新網域設定 Internal Link

參數

名稱類型必填說明
tenantIdstring
domainToUpdatestring
patchDomainConfigParamsPatchDomainConfigParams

回應

回傳: GetDomainConfig200Response


取代/更新網域設定 Internal Link


參數

名稱類型是否必填說明
tenantIdstring
domainToUpdatestring
updateDomainConfigParamsUpdateDomainConfigParams

回應

回傳: GetDomainConfig200Response


建立電子郵件範本 Internal Link

參數

名稱類型必填說明
tenantIdstring
createEmailTemplateBodyCreateEmailTemplateBody

回應

回傳:CreateEmailTemplate200Response

範例

createEmailTemplate 範例
Copy Copy
1
2const tenantId: string = "tenant_4f2b1c9e";
3const createEmailTemplateBody: CreateEmailTemplateBody = {
4 name: "New Comment Notification",
5 subject: "Someone replied to your discussion",
6 fromName: "Community Team",
7 fromAddress: "no-reply@community.example.com",
8 htmlBody: "<p>\{{comment.author}} replied: \{{comment.text}}</p>",
9 plaintextBody: "\{{comment.author}} replied: \{{comment.text}}",
10 previewText: "A new reply on a discussion you follow",
11 isDefault: false // 可選旗標,示範可選參數的用法
12};
13const result: CreateEmailTemplate200Response = await createEmailTemplate(tenantId, createEmailTemplateBody);
14

刪除電子郵件範本 Internal Link

參數

名稱類型是否必填描述
tenantIdstring
idstring

回應

回傳: FlagCommentPublic200Response

範例

deleteEmailTemplate 範例
Copy Copy
1
2const tenantId: string = "tenant_9c4f1b2a";
3const id: string = "emailtmpl_4d2b9a5e";
4const requestorNote: string | undefined = undefined; // 選用的額外資料(函式不需要)
5const result: FlagCommentPublic200Response = await deleteEmailTemplate(tenantId, id);
6

刪除電子郵件範本渲染錯誤 Internal Link

參數

名稱類型必填說明
tenantIdstringYes
idstringYes
errorIdstringYes

回應

回傳: FlagCommentPublic200Response

範例

deleteEmailTemplateRenderError 範例
Copy Copy
1
2const tenantId: string = 'tenant-72f3b4';
3const templateId: string = 'email_template-9c3a1';
4let providedErrorId: string | undefined = undefined; // 可選值,可能在其他地方設定
5const errorId: string = providedErrorId ?? 'render_err-5d2f7';
6const result: FlagCommentPublic200Response = await deleteEmailTemplateRenderError(tenantId, templateId, errorId);
7

取得電子郵件範本 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: GetEmailTemplate200Response

範例

getEmailTemplate 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f3b2c';
3const templateId: string = 'welcome-email-2024';
4const includeDrafts: boolean | undefined = undefined;
5const emailTemplate: GetEmailTemplate200Response = await getEmailTemplate(tenantId, templateId);
6

取得電子郵件範本定義 Internal Link

參數

名稱類型必填說明
tenantIdstring

回應

回傳: GetEmailTemplateDefinitions200Response

範例

getEmailTemplateDefinitions 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_acme_001';
4 const options: { includeDrafts?: boolean } = { includeDrafts: true }; // 示範可選參數
5 const templates: GetEmailTemplateDefinitions200Response = await getEmailTemplateDefinitions(tenantId, options);
6 console.log(templates);
7})();
8

取得電子郵件範本渲染錯誤 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
skipnumber

回應

回傳: GetEmailTemplateRenderErrors200Response

範例

getEmailTemplateRenderErrors 範例
Copy Copy
1
2const tenantId: string = 'acme-tenant-01';
3const id: string = 'tmpl_7f9a2b4c';
4const skip: number = 20;
5
6const errorsWithSkip: GetEmailTemplateRenderErrors200Response = await getEmailTemplateRenderErrors(tenantId, id, skip);
7const errorsFirstPage: GetEmailTemplateRenderErrors200Response = await getEmailTemplateRenderErrors(tenantId, id);
8

取得電子郵件範本清單 Internal Link

參數

名稱類型必填說明
tenantIdstring
skipnumber

回應

回傳: GetEmailTemplates200Response

範例

getEmailTemplates 範例
Copy Copy
1
2async function run(): Promise<void> {
3 const tenantId: string = "acme-marketing-tenant-001";
4 const templatesDefault: GetEmailTemplates200Response = await getEmailTemplates(tenantId);
5 const templatesPaged: GetEmailTemplates200Response = await getEmailTemplates(tenantId, 25);
6 console.log(templatesDefault, templatesPaged);
7}
8run();
9

渲染電子郵件範本 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
renderEmailTemplateBodyRenderEmailTemplateBody
localestring

回應

回傳: RenderEmailTemplate200Response

範例

renderEmailTemplate 範例
Copy Copy
1
2const tenantId: string = '7f7e2b90-3a2b-4d9b-9df1-5f0b6b2e8a1c';
3const renderEmailTemplateBody: RenderEmailTemplateBody = {
4 templateId: 'welcome_email',
5 recipient: { email: 'jordan.smith@acme.co', name: 'Jordan Smith' },
6 variables: { siteName: 'Acme Forum', verificationUrl: 'https://acme.forum/verify?code=abc123' }
7};
8const locale: string = 'en-US';
9const result: RenderEmailTemplate200Response = await renderEmailTemplate(tenantId, renderEmailTemplateBody, locale);
10

更新電子郵件範本 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
updateEmailTemplateBodyUpdateEmailTemplateBody

回應

回傳: FlagCommentPublic200Response

範例

updateEmailTemplate 範例
Copy Copy
1
2const tenantId: string = 'acme-corp-123';
3const id: string = 'template-789';
4const locale: string | undefined = 'en-US';
5const updateEmailTemplateBody: UpdateEmailTemplateBody = {
6 subject: 'Welcome to Acme — Get started',
7 bodyHtml: '<p>Hi \{{firstName}}, welcome to Acme. Start by visiting your dashboard.</p>',
8 fromName: 'Acme Support',
9 fromEmail: 'support@acme.com',
10 enabled: true,
11 ...(locale ? { locale } : {})
12};
13const result: FlagCommentPublic200Response = await updateEmailTemplate(tenantId, id, updateEmailTemplateBody);
14

取得事件記錄 Internal Link

req tenantId urlId userIdWS

參數

NameTypeRequiredDescription
tenantIdstring
urlIdstring
userIdWSstring
startTimenumber
endTimenumber

回傳

回傳: GetEventLog200Response

範例

getEventLog 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3a2b';
3const urlId: string = 'news/2026/06/fastcomments-release';
4const userIdWS: string = 'ws_user_48291';
5const startTime: number = Date.now() - 86_400_000;
6const endTime: number = Date.now();
7const result: GetEventLog200Response = await getEventLog(tenantId, urlId, userIdWS, startTime, endTime);
8

取得全域事件記錄 Internal Link

req tenantId urlId userIdWS

參數

名稱類型必填描述
tenantIdstring
urlIdstring
userIdWSstring
startTimenumber
endTimenumber

回應

回傳:GetEventLog200Response

範例

getGlobalEventLog 範例
Copy Copy
1
2const tenantId: string = "tenant_639b7f12";
3const urlId: string = "https://www.news-site.com/articles/2026/06/15/important-update-987";
4const userIdWS: string = "user_ws_42b7";
5const startTime: number = new Date("2026-06-14T00:00:00Z").getTime();
6const endTime: number = Date.now();
7
8const eventLog: GetEventLog200Response = await getGlobalEventLog(tenantId, urlId, userIdWS, startTime, endTime);
9

建立動態貼文 Internal Link

參數

名稱類型必填描述
tenantIdstring
createFeedPostParamsCreateFeedPostParams
broadcastIdstring
isLiveboolean
doSpamCheckboolean
skipDupCheckboolean

回應

回傳:CreateFeedPost200Response

範例

createFeedPost 範例
Copy Copy
1
2const tenantId: string = 'tenant_4f2b1c';
3const createFeedPostParams: CreateFeedPostParams = {
4 content: 'Launching our summer collection today — check it out!',
5 authorId: 'user_879',
6 media: [
7 {
8 type: 'image',
9 assets: [
10 { url: 'https://cdn.myshop.com/uploads/summer-look.jpg', width: 1200, height: 800 } as FeedPostMediaItemAsset
11 ]
12 } as FeedPostMediaItem
13 ],
14 links: [
15 { url: 'https://myshop.com/new-arrival', title: 'Summer Collection' } as FeedPostLink
16 ],
17 allowComments: true
18};
19const broadcastId: string = 'broadcast-2026-06-15-001';
20const isLive: boolean = false;
21const doSpamCheck: boolean = true;
22const skipDupCheck: boolean = false;
23const response: CreateFeedPost200Response = await createFeedPost(tenantId, createFeedPostParams, broadcastId, isLive, doSpamCheck, skipDupCheck);
24

建立公開動態貼文 Internal Link

參數

名稱類型必填說明
tenantIdstring
createFeedPostParamsCreateFeedPostParams
broadcastIdstring
ssostring

回應

回傳:CreateFeedPostPublic200Response

範例

createFeedPostPublic 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = "tenant_9f8b7c";
4 const media: FeedPostMediaItem[] = [{ type: "image", assets: [{ url: "https://cdn.example.com/roadmap.jpg", mimeType: "image/jpeg" }] }];
5 const links: FeedPostLink[] = [{ url: "https://company.example.com/roadmap", title: "Full roadmap" }];
6 const createFeedPostParams: CreateFeedPostParams = {
7 title: "Weekly Product Roadmap Update",
8 body: "This week we shipped enhancements to search relevance and fixed top customer bugs.",
9 authorId: "user_8321",
10 media,
11 links,
12 visibility: "public"
13 };
14 const broadcastId: string = "broadcast_2026_06_15";
15 const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload";
16 const response: CreateFeedPostPublic200Response = await createFeedPostPublic(tenantId, createFeedPostParams, broadcastId, sso);
17 console.log(response);
18})();
19

刪除公開動態貼文 Internal Link

參數

名稱型別必填說明
tenantIdstring
postIdstring
broadcastIdstring
ssostring

回應

回傳: DeleteFeedPostPublic200Response

範例

deleteFeedPostPublic 範例
Copy Copy
1
2const tenantId: string = 'acme-tenant-42';
3const postId: string = 'post_8f3d2a7c';
4const broadcastId: string = 'broadcast_2026-06-15_01';
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
6const response: DeleteFeedPostPublic200Response = await deleteFeedPostPublic(tenantId, postId, broadcastId, sso);
7

取得動態貼文 Internal Link

req tenantId afterId

參數

名稱類型必填說明
tenantIdstring
afterIdstring
limitnumber
tagsArray

回應

回傳: GetFeedPosts200Response

範例

getFeedPosts 範例
Copy Copy
1
2const tenantId: string = "tenant_74321";
3const afterId: string = "post_20250610_9b2f3";
4const limit: number = 25;
5const tags: Array<string> = ["product-updates", "announcements"];
6
7const response: GetFeedPosts200Response = await getFeedPosts(tenantId, afterId, limit, tags);
8

取得公開動態貼文 Internal Link

req tenantId afterId

參數

名稱類型必填描述
tenantIdstring
afterIdstring
limitnumber
tagsArray
ssostring
isCrawlerboolean
includeUserInfoboolean

回應

回傳: GetFeedPostsPublic200Response

範例

getFeedPostsPublic 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_acme_01';
4 const afterId: string = 'post_20250610_842';
5 const limit: number = 25;
6 const tags: string[] = ['news', 'technology'];
7 const sso: string = 'sso_jwt_eyJhbGciOiJIUzI1Ni';
8 const isCrawler: boolean = false;
9 const includeUserInfo: boolean = true;
10
11 const response: GetFeedPostsPublic200Response = await getFeedPostsPublic(
12 tenantId,
13 afterId,
14 limit,
15 tags,
16 sso,
17 isCrawler,
18 includeUserInfo
19 );
20
21 console.log(response);
22})();
23

取得動態貼文統計 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
postIdsArray
ssostring

回應

回傳: GetFeedPostsStats200Response

範例

getFeedPostsStats 範例
Copy Copy
1
2const tenantId: string = "tenant_98765";
3const postIds: string[] = ["post_a1b2c3", "post_d4e5f6"];
4const ssoToken: string = "sso_jwt_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9";
5
6const statsWithoutSSO: GetFeedPostsStats200Response = await getFeedPostsStats(tenantId, postIds);
7const statsWithSSO: GetFeedPostsStats200Response = await getFeedPostsStats(tenantId, postIds, ssoToken);
8

取得使用者公開反應 Internal Link

參數

名稱類型必要說明
tenantIdstring
postIdsArray
ssostring

回應

回傳:GetUserReactsPublic200Response

範例

getUserReactsPublic 範例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-4f2b9c';
3const postIds: Array<string> = ['post_7a1f9e', 'post_2b3c88'];
4const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1Njc4OSIsImlhdCI6MTYwOTQ0MDAwMH0.signature';
5
6const response: GetUserReactsPublic200Response = await getUserReactsPublic(tenantId, postIds, sso);
7

對公開動態貼文反應 Internal Link

參數

名稱類型必填描述
tenantIdstring
postIdstring
reactBodyParamsReactBodyParams
isUndoboolean
broadcastIdstring
ssostring

回應

回傳: ReactFeedPostPublic200Response

範例

reactFeedPostPublic 範例
Copy Copy
1
2const tenantId: string = 'acme-tenant-001';
3const postId: string = 'feedpost_78901';
4const reactBodyParams: ReactBodyParams = { reaction: 'like', emoji: '👍' };
5const isUndo: boolean = false;
6const broadcastId: string = 'broadcast_2026_06_15_01';
7const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.signature';
8
9const response: ReactFeedPostPublic200Response = await reactFeedPostPublic(
10 tenantId,
11 postId,
12 reactBodyParams,
13 isUndo,
14 broadcastId,
15 sso
16);
17

更新動態貼文 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
feedPostFeedPost

回應

回傳: FlagCommentPublic200Response

範例

updateFeedPost 範例
Copy Copy
1
2const tenantId: string = "tenant_72f3b4c9";
3const id: string = "post_ba4f6e18-2d3c-4b7a-91f2-8c0e3a6b5d4f";
4
5const feedPost: FeedPost = {
6 title: "June feature rollout",
7 body: "Announcing performance improvements and moderation updates available to all sites.",
8 authorName: "Platform Team",
9 mediaItems: [
10 {
11 type: "image",
12 caption: "Release banner",
13 asset: { url: "https://cdn.fastcomments.com/assets/june-banner.jpg", mimeType: "image/jpeg", width: 1200, height: 600 }
14 }
15 ],
16 links: [{ title: "Release notes", url: "https://docs.fastcomments.com/releases/june-2026" }]
17} as FeedPost;
18
19const result: FlagCommentPublic200Response = await updateFeedPost(tenantId, id, feedPost);
20

更新公開動態貼文 Internal Link

參數

名稱類型必填說明
tenantIdstring
postIdstring
updateFeedPostParamsUpdateFeedPostParams
broadcastIdstring
ssostring

回應

回傳: CreateFeedPostPublic200Response

範例

updateFeedPostPublic 範例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const postId: string = 'post_20260615_001';
4const updateFeedPostParams: UpdateFeedPostParams = {
5 title: 'Weekly Update: Product Launch',
6 content: 'We shipped the 2.0 release today — highlights and links below.',
7 media: [{ url: 'https://cdn.acme.com/releases/launch.jpg', type: 'image' }],
8 tags: ['release', 'product'],
9 isPublic: true
10};
11const broadcastId: string = 'broadcast_live_42';
12const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9';
13const result: CreateFeedPostPublic200Response = await updateFeedPostPublic(tenantId, postId, updateFeedPostParams, broadcastId, sso);
14

檢舉公開留言 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
isFlaggedboolean
ssostring

回應

回傳: FlagCommentPublic200Response

範例

flagCommentPublic 範例
Copy Copy
1
2const tenantId: string = "tenant_4f1b2a9c";
3const commentId: string = "comment_8d3e6f12";
4const isFlagged: boolean = true;
5const sso: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
6const result: FlagCommentPublic200Response = await flagCommentPublic(tenantId, commentId, isFlagged, sso);
7

取得大型 GIF Internal Link

參數

名稱類型必填說明
tenantIdstring
largeInternalURLSanitizedstring

回應

回傳: GetGifLarge200Response

範例

getGifLarge 範例
Copy Copy
1
2const tenantId: string = "tenant_9f8b7c";
3const largeInternalURLSanitized: string = "https://cdn.fastcomments.com/gifs/07d3f6_large.gif";
4const preferWebP: boolean | undefined = true; // 可選的偏好
5const urlToUse: string = preferWebP ? largeInternalURLSanitized.replace(".gif", ".webp") : largeInternalURLSanitized;
6const response: GetGifLarge200Response = await getGifLarge(tenantId, urlToUse);
7

搜尋 GIF Internal Link

參數

名稱類型必填說明
tenantIdstring
searchstring
localestring
ratingstring
pagenumber

回應

回傳: GetGifsSearch200Response

範例

getGifsSearch 範例
Copy Copy
1
2const tenantId: string = "tenant_acme_9876";
3const search: string = "cat playing piano";
4const locale: string = "en-US";
5const rating: string = "pg";
6const page: number = 1;
7const result: GetGifsSearch200Response = await getGifsSearch(tenantId, search, locale, rating, page);
8

取得熱門 GIF Internal Link

參數

名稱類型必填描述
tenantIdstring
localestring
ratingstring
pagenumber

回應

回傳: GetGifsTrending200Response

範例

getGifsTrending 範例
Copy Copy
1
2async function main(): Promise<void> {
3 const tenantId: string = 'tenant_8b3f2c';
4 const locale: string = 'en-US';
5 const rating: string = 'pg';
6 const page: number = 1;
7 const result: GetGifsTrending200Response = await getGifsTrending(tenantId, locale, rating, page);
8 console.log(result);
9}
10main();
11

新增標籤 Internal Link

參數

名稱型別必填描述
tenantIdstring
createHashTagBodyCreateHashTagBody

回應

回傳: AddHashTag200Response

範例

addHashTag 範例
Copy Copy
1
2const tenantId: string | undefined = "tenant_3c9f7b";
3const createHashTagBody: CreateHashTagBody = {
4 name: "support",
5 title: "Support",
6 description: "Questions about product usage, bugs, and account issues",
7 color: "#0066CC",
8 isActive: true,
9 aliases: ["help", "customer-service"]
10};
11const result: AddHashTag200Response = await addHashTag(tenantId, createHashTagBody);
12

批次新增標籤 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
bulkCreateHashTagsBodyBulkCreateHashTagsBody

回應

回傳: AddHashTagsBulk200Response

範例

addHashTagsBulk 範例
Copy Copy
1
2const tenantId: string = "tenant_acme_corp_987";
3const bulkCreateHashTagsBody: BulkCreateHashTagsBody = {
4 tags: [
5 { name: "product-update", description: "Announcements about new product releases", visible: true },
6 { name: "customer-support", description: "Customer support related discussions", visible: false }
7 ],
8 createdBy: "moderator_jane"
9};
10const resultWithTenant: AddHashTagsBulk200Response = await addHashTagsBulk(tenantId, bulkCreateHashTagsBody);
11const resultWithoutTenant: AddHashTagsBulk200Response = await addHashTagsBulk(undefined, bulkCreateHashTagsBody);
12

刪除標籤 Internal Link


參數

名稱類型必填說明
tagstring
tenantIdstring
deleteHashTagRequestDeleteHashTagRequest

回應

回傳:FlagCommentPublic200Response

範例

deleteHashTag 範例
Copy Copy
1
2const tag: string = "breaking-news";
3const tenantId: string = "tenant_72a1";
4const deleteHashTagRequest: DeleteHashTagRequest = {
5 reason: "consolidate-duplicates",
6 requestedBy: "moderator@dailypress.com",
7 forceDelete: true
8};
9const result: FlagCommentPublic200Response = await deleteHashTag(tag, tenantId, deleteHashTagRequest);
10

取得標籤 Internal Link

參數

名稱類型必填描述
tenantIdstring
pagenumber

回應

回傳: GetHashTags200Response

範例

getHashTags 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f4b2c3a';
3const tagsFirstPage: GetHashTags200Response = await getHashTags(tenantId);
4const tagsSecondPage: GetHashTags200Response = await getHashTags(tenantId, 2);
5console.log(tagsFirstPage, tagsSecondPage);
6

部分更新標籤 Internal Link

參數

NameTypeRequiredDescription
tagstring
tenantIdstring
updateHashTagBodyUpdateHashTagBody

回應

回傳: PatchHashTag200Response

範例

patchHashTag 範例
Copy Copy
1
2const tag: string = "feature-request";
3const tenantId: string = "tenant_8f7a3b2c";
4const updateHashTagBody: UpdateHashTagBody = {
5 displayName: "Feature Request",
6 description: "Use this tag for requests to add new features to the product",
7 enabled: true
8};
9const result: PatchHashTag200Response = await patchHashTag(tag, tenantId, updateHashTagBody);
10

建立管理員 Internal Link


參數

名稱類型必填說明
tenantIdstring
createModeratorBodyCreateModeratorBody

回應

回傳:CreateModerator200Response

範例

createModerator 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b21';
3const createModeratorBody: CreateModeratorBody = {
4 moderator: {
5 name: 'Alex Rivera',
6 email: 'alex.rivera@fastcomments.io',
7 role: 'global_moderator',
8 enabled: true,
9 },
10 // 示範可選參數:
11 notifyUser: true,
12 permissions: ['delete_comment', 'edit_comment', 'ban_user'],
13 customConfig: { dashboardTheme: 'dark' } as unknown as CustomConfigParameters
14};
15const result: CreateModerator200Response = await createModerator(tenantId, createModeratorBody);
16

刪除管理員 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
sendEmailstring

回應

回傳: FlagCommentPublic200Response

範例

deleteModerator 範例
Copy Copy
1
2const tenantId: string = 'tenant_4f3b2c9a';
3const id: string = 'mod_9c2d1f7b';
4const sendEmail: string = 'true';
5const response: FlagCommentPublic200Response = await deleteModerator(tenantId, id, sendEmail);
6console.log(response);
7

取得管理員 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: GetModerator200Response

範例

getModerator 範例
Copy Copy
1
2const tenantId: string = 'acme-media-58';
3const id: string = 'mod-82f3b9c1';
4const moderatorResponse: GetModerator200Response = await getModerator(tenantId, id);
5

取得管理員清單 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
skipnumber

回應

回傳: GetModerators200Response

範例

getModerators 範例
Copy Copy
1
2const tenantId: string = 'tenant_0a1b2c3d';
3const moderators: GetModerators200Response = await getModerators(tenantId);
4const skip: number = 20;
5const moderatorsPage2: GetModerators200Response = await getModerators(tenantId, skip);
6

發送邀請 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
fromNamestring

回應

回傳: FlagCommentPublic200Response

範例

sendInvite 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = "tenant_acme_42";
4 const id: string = "cmt_8f3b21";
5 const fromName: string = "Ava Thompson";
6 const inviteResult: FlagCommentPublic200Response = await sendInvite(tenantId, id, fromName);
7 console.log(inviteResult);
8})();
9

更新管理員 Internal Link

參數

NameTypeRequiredDescription
tenantIdstringYes
idstringYes
updateModeratorBodyUpdateModeratorBodyYes

回應

回傳:FlagCommentPublic200Response

範例

updateModerator 範例
Copy Copy
1
2const tenantId: string = 'acme-tenant-81';
3const id: string = 'mod_7f3a2b';
4const updateModeratorBody: UpdateModeratorBody = {
5 email: 'j.reyes@acme-corp.com',
6 displayName: 'Jordan Reyes',
7 roles: ['moderator', 'content_reviewer'],
8 active: true,
9 notes: 'Promoted to senior moderator; monitor flagged content weekly'
10};
11const result: FlagCommentPublic200Response = await updateModerator(tenantId, id, updateModeratorBody);
12

刪除通知計數 Internal Link

參數

名稱型別是否必填說明
tenantIdstring
idstring

回應

回傳:FlagCommentPublic200Response

範例

deleteNotificationCount 範例
Copy Copy
1
2const tenantId: string = 'tenant_5f3d2e1b';
3const id: string = 'notification_9a4b1c2';
4const result: FlagCommentPublic200Response = await deleteNotificationCount(tenantId, id);
5

取得快取的通知計數 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring

回應

回傳:GetCachedNotificationCount200Response

範例

getCachedNotificationCount 範例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-23';
3const id: string = 'user_987654';
4const cachedCount: GetCachedNotificationCount200Response = await getCachedNotificationCount(tenantId, id);
5
6const maybeId: string | undefined = Math.random() > 0.5 ? 'user_123456' : undefined;
7if (maybeId) {
8 const optionalCachedCount: GetCachedNotificationCount200Response = await getCachedNotificationCount(tenantId, maybeId);
9}
10

取得通知計數 Internal Link

參數

名稱型別必填描述
tenantIdstring
userIdstring
urlIdstring
fromCommentIdstring
viewedboolean
typestring

回應

回傳: GetNotificationCount200Response

範例

getNotificationCount 範例
Copy Copy
1
2const tenantId: string = 'tenant_82a3b9f';
3const userId: string = 'user_43721';
4const urlId: string = 'https://news.example.com/articles/2026/06/15/coverage-123';
5const fromCommentId: string = 'comment_98765';
6const viewed: boolean = false;
7const notificationType: string = 'mention';
8
9const result: GetNotificationCount200Response = await getNotificationCount(tenantId, userId, urlId, fromCommentId, viewed, notificationType);
10

取得通知 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
userIdstring
urlIdstring
fromCommentIdstring
viewedboolean
typestring
skipnumber

回應

回傳: GetNotifications200Response

範例

getNotifications 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f8b7c6a';
3const userId: string = 'user_5a4b3c2d';
4const urlId: string = 'post_84f2a1b9';
5const fromCommentId: string = 'cmt_0a1b2c3d';
6const viewed: boolean = false;
7const type: string = 'reply';
8const skip: number = 0;
9
10const notifications: GetNotifications200Response = await getNotifications(
11 tenantId,
12 userId,
13 urlId,
14 fromCommentId,
15 viewed,
16 type,
17 skip
18);
19

更新通知 Internal Link

參數

NameType是否必填說明
tenantIdstring
idstring
updateNotificationBodyUpdateNotificationBody
userIdstring

回應

回傳: FlagCommentPublic200Response

範例

updateNotification 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2c';
3const id: string = 'notification_4a1d2e';
4const updateNotificationBody: UpdateNotificationBody = {
5 enabled: true,
6 channels: ['email', 'push'],
7 frequency: 'immediate',
8 templateId: 'tmpl_77aa'
9} as UpdateNotificationBody;
10const userId: string = 'user_2468';
11const result: FlagCommentPublic200Response = await updateNotification(tenantId, id, updateNotificationBody, userId);
12

建立 V1 頁面回應 Internal Link

參數

NameType必填說明
tenantIdstring
urlIdstring
titlestring

回應

回傳:CreateV1PageReact200Response

範例

createV1PageReact 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'b12f3c4d-5678-90ab-cdef-1234567890ab';
4 const urlId: string = 'https://www.news-site.com/world/2026/election-results';
5 const title: string = 'Election results: key takeaways and analysis';
6 const responseWithTitle: CreateV1PageReact200Response = await createV1PageReact(tenantId, urlId, title);
7 const responseWithoutTitle: CreateV1PageReact200Response = await createV1PageReact(tenantId, urlId);
8 console.log(responseWithTitle, responseWithoutTitle);
9})();
10

建立 V2 頁面回應 Internal Link

參數

名稱類型必要描述
tenantIdstring
urlIdstring
idstring
titlestring

回應

回傳: CreateV2PageReact200Response

範例

createV2PageReact 範例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-72";
3const urlId: string = "articles/2026/06/15/product-update";
4const id: string = "page-8f3b2a";
5const title: string = "Product Update: June 15, 2026";
6
7(async function run(): Promise<void> {
8 const response: CreateV2PageReact200Response = await createV2PageReact(tenantId, urlId, id, title);
9 console.log(response);
10})();
11

刪除 V1 頁面回應 Internal Link

參數

名稱類型必填說明
tenantIdstring
urlIdstring

回應

回傳: DeleteV1PageReact200Response

範例

deleteV1PageReact 範例
Copy Copy
1
2const tenantId: string = process.env.TENANT_ID ?? 'd3b07384-9f6a-4c2b-8c3e-0a1b2c3d4e5f';
3const urlId: string = 'https://acme.com/articles/2026/06/fastcomments-integration';
4const result: DeleteV1PageReact200Response = await deleteV1PageReact(tenantId, urlId);
5

刪除 V2 頁面回應 Internal Link

參數

名稱型別必填說明
tenantIdstring
urlIdstring
idstring

回應

回傳:DeleteV2PageReact200Response

範例

deleteV2PageReact 範例
Copy Copy
1
2const tenantId: string = "tenant_79021";
3const urlId: string = "blog/my-first-post";
4const id: string = "reaction_9f8b7c";
5let includeHistory: boolean | undefined = undefined; // 可選旗標,在某些呼叫中使用
6
7const result: DeleteV2PageReact200Response = await deleteV2PageReact(tenantId, urlId, id);
8console.log(result);
9

取得 V1 頁面按讚 Internal Link

參數

名稱類型必填說明
tenantIdstring
urlIdstring

回傳

回傳:GetV1PageLikes200Response

範例

getV1PageLikes 範例
Copy Copy
1
2const tenantId: string = 'fastcomments-742';
3const urlId: string = 'sports/2026/06/15/world-cup-preview';
4const pageLikes: GetV1PageLikes200Response = await getV1PageLikes(tenantId, urlId);
5

取得 V2 頁面回應 Internal Link

參數

名稱類型必填說明
tenantIdstring
urlIdstring

回應

回傳: GetV2PageReacts200Response

範例

getV2PageReacts 範例
Copy Copy
1
2const tenantId: string = "tenant_82f4b3a9";
3const urlId: string = "https://news.site.com/articles/2026/06/15/product-launch";
4const response: GetV2PageReacts200Response = await getV2PageReacts(tenantId, urlId);
5console.log(response);
6

取得 V2 頁面回應使用者 Internal Link

參數

NameTypeRequiredDescription
tenantIdstringYes
urlIdstringYes
idstringYes

回應

回傳: GetV2PageReactUsers200Response

範例

getV2PageReactUsers 範例
Copy Copy
1
2const tenantId: string = "7421";
3const urlId: string = "sports/london-marathon";
4const id: string = "reactUser-3fa85f64-5717-4562-b3fc-2c963f66afa6";
5const includeDeleted: boolean | undefined = undefined; // 可選旗標(示範)
6
7const result: GetV2PageReactUsers200Response = await getV2PageReactUsers(tenantId, urlId, id);
8

新增頁面 Internal Link

參數

名稱類型必填說明
tenantIdstring
createAPIPageDataCreateAPIPageData

回應

回傳: AddPageAPIResponse


刪除頁面 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring

Response

回傳: DeletePageAPIResponse

取得離線使用者 Internal Link

在該頁面先前的留言者,但目前不在線上。依 displayName 排序。 在用盡 /users/online 後,使用此來呈現一個 "成員" 區段。 Cursor pagination on commenterName: server walks the partial {tenantId, urlId, commenterName} index from afterName forward via $gt, no $skip cost.

參數

NameTypeRequiredDescription
tenantIdstringYes
urlIdstringYes
afterNamestringNo
afterUserIdstringNo

回應

回傳: GetOfflineUsers200Response

範例

getOfflineUsers 範例
Copy Copy
1
2const tenantId: string = 'tenant_prod_001';
3const urlId: string = 'article-2026-06-15-how-ai-impacts';
4const afterName: string = 'michael.smith';
5const afterUserId: string = 'user_72b9';
6
7const response: GetOfflineUsers200Response = await getOfflineUsers(tenantId, urlId, afterName, afterUserId);
8

取得線上使用者 Internal Link

某頁面當前線上的觀眾:目前 websocket 會話已訂閱該頁面的使用者。 回傳 anonCount + totalCount (整個房間的訂閱者,包括我們不列舉的匿名觀眾).

參數

名稱型別必填說明
tenantIdstring
urlIdstring
afterNamestring
afterUserIdstring

回應

回傳: GetOnlineUsers200Response

範例

getOnlineUsers 範例
Copy Copy
1
2const tenantId: string = 'tenant_14f9c3';
3const urlId: string = 'article_20250615';
4const afterName: string = 'marie.curie';
5const afterUserId: string = 'u_92b7';
6const result: GetOnlineUsers200Response = await getOnlineUsers(tenantId, urlId, afterName, afterUserId);
7

依 URLId 取得頁面 Internal Link


參數

名稱類型必填描述
tenantIdstring
urlIdstring

回應

回傳:GetPageByURLIdAPIResponse


取得頁面清單 Internal Link


參數

名稱類型必填描述
tenantIdstring

回應

回傳: GetPagesAPIResponse


取得公開頁面 Internal Link


列出租戶的頁面。供 FChat 桌面客戶端用來填充其房間列表。 要求每個頁面的解析後自訂設定中 enableFChat 必須為 true。 需要 SSO 的頁面會根據請求使用者的群組權限進行篩選。

參數

NameTypeRequiredDescription
tenantIdstring
cursorstring
limitnumber
qstring
sortByPagesSortBy
hasCommentsboolean

回應

回傳: GetPagesPublic200Response

範例

getPagesPublic 範例
Copy Copy
1
2const tenantId: string = 'tenant_8f3b2c';
3const cursor: string = 'eyJwYWdlIjoiMTIwIn0';
4const limit: number = 25;
5const q: string = 'homepage hero';
6const hasComments: boolean = true;
7
8const response: GetPagesPublic200Response = await getPagesPublic(
9 tenantId,
10 cursor,
11 limit,
12 q,
13 undefined,
14 hasComments
15);
16

取得使用者資訊 Internal Link

租戶的批量用戶資訊。給定 userIds,從 User / SSOUser 返回顯示資訊。 由評論 widget 使用,用於豐富剛透過 presence 事件出現的使用者。 無頁面上下文:隱私統一強制執行(私人檔案會被遮蔽)。

參數

名稱類型必填描述
tenantIdstring
idsstring

回應

回傳: GetUsersInfo200Response

範例

getUsersInfo 範例
Copy Copy
1
2const tenantId: string = 'acme-tenant-007';
3const userIdsList: string[] = ['user_12a', 'user_34b', 'user_56c'];
4const separator: string | undefined = undefined; // 可選;若為 undefined 則預設為逗號
5const ids: string = userIdsList.join(separator ?? ',');
6const usersInfo: GetUsersInfo200Response = await getUsersInfo(tenantId, ids);
7

部分更新頁面 Internal Link


參數

NameTypeRequiredDescription
tenantIdstring
idstring
updateAPIPageDataUpdateAPIPageData

回應

回傳: PatchPageAPIResponse


刪除待處理的 Webhook 事件 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: FlagCommentPublic200Response

範例

deletePendingWebhookEvent 範例
Copy Copy
1
2const tenantId: string = "tenant_5f8d7a34";
3const id: string = "webhook_evt_987654321";
4const requestNote: string | undefined = undefined;
5const response: FlagCommentPublic200Response = await deletePendingWebhookEvent(tenantId, id);
6

取得待處理 Webhook 事件計數 Internal Link

參數

名稱型別必填描述
tenantIdstring
commentIdstring
externalIdstring
eventTypestring
typestring
domainstring
attemptCountGTnumber

回應

回傳: GetPendingWebhookEventCount200Response

範例

getPendingWebhookEventCount 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f8b3b';
3const commentId: string = 'cmt_1a2b3c';
4const eventType: string = 'comment.created';
5const domain: string = 'news-site.com';
6const attemptCountGT: number = 2;
7
8const result: GetPendingWebhookEventCount200Response = await getPendingWebhookEventCount(
9 tenantId,
10 commentId,
11 undefined, // 已省略 externalId
12 eventType,
13 undefined, // 已省略 type
14 domain,
15 attemptCountGT
16);
17

取得待處理的 Webhook 事件 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
commentIdstring
externalIdstring
eventTypestring
typestring
domainstring
attemptCountGTnumber
skipnumber

回傳

回傳: GetPendingWebhookEvents200Response

範例

getPendingWebhookEvents 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a';
3const commentId: string = 'cmt_8a7d1';
4const eventType: string = 'comment.created';
5const domain: string = 'reviews.myshop.com';
6const attemptCountGT: number = 1;
7const skip: number = 0;
8
9const result: GetPendingWebhookEvents200Response = await getPendingWebhookEvents(
10 tenantId,
11 commentId,
12 undefined,
13 eventType,
14 undefined,
15 domain,
16 attemptCountGT,
17 skip
18);
19

建立問卷設定 Internal Link


參數

名稱類型是否必填描述
tenantIdstring
createQuestionConfigBodyCreateQuestionConfigBody

回應

回傳: CreateQuestionConfig200Response

範例

createQuestionConfig 範例
Copy Copy
1
2const tenantId: string = "tenant_9f3b1c2a";
3
4const createQuestionConfigBody: CreateQuestionConfigBody = {
5 name: "Product feedback",
6 key: "product_quality",
7 description: "Short survey question shown after posting a comment",
8 required: true,
9 renderingType: "singleChoice",
10 customOptions: [
11 { label: "Excellent", value: "5" },
12 { label: "Good", value: "4" },
13 { label: "Fair", value: "3" }
14 ] as QuestionConfigCustomOptionsInner[],
15 notifyModerators: false // 示範可選參數
16};
17
18const result: CreateQuestionConfig200Response = await createQuestionConfig(tenantId, createQuestionConfigBody);
19

刪除問卷設定 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: FlagCommentPublic200Response

範例

deleteQuestionConfig 範例
Copy Copy
1
2const tenantId: string = 'acme-corp-47a9';
3const id: string = 'qcfg_20260615_001';
4const result: FlagCommentPublic200Response = await deleteQuestionConfig(tenantId, id);
5

取得問卷設定 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetQuestionConfig200Response

範例

getQuestionConfig 範例
Copy Copy
1
2const tenantId: string = "acme-corp-47";
3const questionId: string = "q-4f2b9a";
4const includeDrafts: boolean | undefined = undefined; // 可選參數佔位符
5const result: GetQuestionConfig200Response = await getQuestionConfig(tenantId, questionId);
6console.log(result);
7

取得問卷設定清單 Internal Link

參數

名稱類型必填描述
tenantIdstring
skipnumber

回應

回傳: GetQuestionConfigs200Response

範例

getQuestionConfigs 範例
Copy Copy
1
2const tenantId: string = "tenant_4c9f2b";
3const responseWithoutSkip: GetQuestionConfigs200Response = await getQuestionConfigs(tenantId);
4const skip: number = 50;
5const responseWithSkip: GetQuestionConfigs200Response = await getQuestionConfigs(tenantId, skip);
6

更新問卷設定 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring
updateQuestionConfigBodyUpdateQuestionConfigBody

回應

回傳:FlagCommentPublic200Response

範例

updateQuestionConfig 範例
Copy Copy
1
2const tenantId: string = "tenant_9f3b8a2e-4c6d-4b4f-a1b2-9e8f7d6c5b3a";
3const id: string = "q_7c2e1b4a-5d6f-4a8b-9c3d-2e1f0b9a4c5d";
4const options: QuestionConfigCustomOptionsInner[] = [
5 { value: "1", label: "Very dissatisfied" },
6 { value: "2", label: "Dissatisfied" },
7 { value: "3", label: "Neutral" },
8 { value: "4", label: "Satisfied" },
9 { value: "5", label: "Very satisfied" }
10];
11const updateQuestionConfigBody: UpdateQuestionConfigBody = {
12 label: "How satisfied are you with the article?",
13 enabled: true,
14 required: false, // 示範可選參數
15 options
16};
17const result: FlagCommentPublic200Response = await updateQuestionConfig(tenantId, id, updateQuestionConfigBody);
18

建立問卷結果 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
createQuestionResultBodyCreateQuestionResultBody

回應

回傳: CreateQuestionResult200Response

範例

createQuestionResult 範例
Copy Copy
1
2const tenantId: string = 'fc-tenant-512';
3const meta: MetaItem[] = [{ key: 'source', value: 'article' }];
4const body: CreateQuestionResultBody = {
5 questionId: 'q-94',
6 userId: 'user_332',
7 answers: [{ optionId: 'opt_a', score: 1 }],
8 meta, // 提供的選用元資料
9} as CreateQuestionResultBody;
10const result: CreateQuestionResult200Response = await createQuestionResult(tenantId, body);
11

刪除問卷結果 Internal Link

參數

名稱類型是否必填說明
tenantIdstring
idstring

回應

回傳: FlagCommentPublic200Response

範例

deleteQuestionResult 範例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-01";
3const id: string = "qres_9f8b7c3a";
4const response: FlagCommentPublic200Response = await deleteQuestionResult(tenantId, id);
5const optionalResponse: FlagCommentPublic200Response | undefined = response;
6

取得問卷結果 Internal Link

參數

名稱類型是否必填描述
tenantIdstring
idstring

回應

回傳:GetQuestionResult200Response

範例

getQuestionResult 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a7c9';
3const questionId: string = 'q_8d4f1b2c3a';
4const options: { includeMeta?: boolean } = { includeMeta: true }; // 可選參數示範
5const result: GetQuestionResult200Response = await getQuestionResult(tenantId, questionId);
6const apiStatus: APIStatus | undefined = (result as unknown as { apiStatus?: APIStatus }).apiStatus;
7const question: QuestionResult | undefined = (result as unknown as { question?: QuestionResult }).question;
8

取得問卷結果清單 Internal Link

參數

名稱類型必填描述
tenantIdstring
urlIdstring
userIdstring
startDatestring
questionIdstring
questionIdsstring
skipnumber

回應

回傳: GetQuestionResults200Response

範例

getQuestionResults 範例
Copy Copy
1
2const tenantId: string = 'fc-tenant-7a9c';
3const urlId: string = 'news/article-2026-06-15';
4const userId: string = 'user-8421';
5const startDate: string = '2026-05-01T00:00:00Z';
6const questionId: string = 'q-13';
7const questionIds: string = 'q-13,q-14';
8const skip: number = 20;
9const result: GetQuestionResults200Response = await getQuestionResults(tenantId, urlId, userId, startDate, questionId, questionIds, skip);
10

更新問卷結果 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
updateQuestionResultBodyUpdateQuestionResultBody

回應

回傳: FlagCommentPublic200Response

範例

updateQuestionResult 範例
Copy Copy
1
2const tenantId: string = "tenant_prod_84b2";
3const id: string = "question_9f3a";
4const updateQuestionResultBody: UpdateQuestionResultBody = {
5 outcome: "accepted",
6 confidence: 0.88,
7 moderatorId: "moderator_17",
8 notes: "Validated by automated review" // 包含可選欄位
9};
10const result: FlagCommentPublic200Response = await updateQuestionResult(tenantId, id, updateQuestionResultBody);
11

彙總問卷結果 Internal Link

參數

名稱型別必填描述
tenantIdstring
questionIdstring
questionIdsArray
urlIdstring
timeBucketAggregateTimeBucket
startDateDate
forceRecalculateboolean

回應

回傳:AggregateQuestionResults200Response

範例

aggregateQuestionResults 範例
Copy Copy
1
2const tenantId: string = 'tenant_6f2b3c';
3const questionIds: Array<string> = ['q-7a1b2c', 'q-8d3e4f'];
4const urlId: string = 'url_9f8e7d';
5const startDate: Date = new Date('2025-01-01T00:00:00Z');
6const result: AggregateQuestionResults200Response = await aggregateQuestionResults(tenantId, undefined, questionIds, urlId, undefined, startDate, true);
7

批次彙總問卷結果 Internal Link

參數

名稱類型必填說明
tenantIdstring
bulkAggregateQuestionResultsRequestBulkAggregateQuestionResultsRequest
forceRecalculateboolean

回應

回傳: BulkAggregateQuestionResults200Response

範例

bulkAggregateQuestionResults 範例
Copy Copy
1
2const tenantId: string = "tenant_0012";
3const bulkAggregateQuestionResultsRequest: BulkAggregateQuestionResultsRequest = {
4 items: [
5 {
6 questionId: "quality_score",
7 startTime: "2026-06-01T00:00:00Z",
8 endTime: "2026-06-14T00:00:00Z",
9 timeBucket: "day",
10 dimensions: ["threadId"]
11 }
12 ],
13 includeTotals: true
14};
15const forceRecalculate: boolean = false;
16const result: BulkAggregateQuestionResults200Response = await bulkAggregateQuestionResults(tenantId, bulkAggregateQuestionResultsRequest, forceRecalculate);
17

將留言與問卷結果結合 Internal Link

參數

名稱類型必填說明
tenantIdstring
questionIdstring
questionIdsArray
urlIdstring
startDateDate
forceRecalculateboolean
minValuenumber
maxValuenumber
limitnumber

回應

回傳: CombineCommentsWithQuestionResults200Response

範例

combineCommentsWithQuestionResults 範例
Copy Copy
1
2const tenantId: string = 'tenant_12345';
3const questionId: string = 'q_98765';
4const questionIds: string[] = ['q_98765', 'q_12345'];
5const urlId: string = 'url_abc123';
6const startDate: Date = new Date('2026-01-01T00:00:00Z');
7const forceRecalculate: boolean = true;
8const minValue: number = 0;
9const maxValue: number = 5;
10const limit: number = 50;
11const result: CombineCommentsWithQuestionResults200Response = await combineCommentsWithQuestionResults(
12 tenantId,
13 questionId,
14 questionIds,
15 urlId,
16 startDate,
17 forceRecalculate,
18 minValue,
19 maxValue,
20 limit
21);
22

新增 SSO 使用者 Internal Link


參數

名稱類型必填描述
tenantIdstring
createAPISSOUserDataCreateAPISSOUserData

回應

回傳:AddSSOUserAPIResponse


刪除 SSO 使用者 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
deleteCommentsboolean
commentDeleteModestring

回應

回傳: DeleteSSOUserAPIResponse


以電子郵件取得 SSO 使用者 Internal Link


參數

名稱類型必填說明
tenantIdstring
emailstring

回應

回傳: GetSSOUserByEmailAPIResponse


以 ID 取得 SSO 使用者 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetSSOUserByIdAPIResponse

取得 SSO 使用者清單 Internal Link


參數

名稱類型必填描述
tenantIdstring
skipnumber

回應

回傳: GetSSOUsers200Response


部分更新 SSO 使用者 Internal Link


參數

NameTypeRequiredDescription
tenantIdstring
idstring
updateAPISSOUserDataUpdateAPISSOUserData
updateCommentsboolean

回應

回傳: PatchSSOUserAPIResponse


取代/更新 SSO 使用者 Internal Link

參數

名稱型別必要說明
tenantIdstring
idstring
updateAPISSOUserDataUpdateAPISSOUserData
updateCommentsboolean

回應

回傳: PutSSOUserAPIResponse

範例

putSSOUser 範例
Copy Copy
1
2const tenantId: string = 'acme-enterprises-42';
3const id: string = 'usr-73a1b2';
4const updateAPISSOUserData: UpdateAPISSOUserData = {
5 email: 'marcus.ingram@acme.com',
6 givenName: 'Marcus',
7 familyName: 'Ingram',
8 roles: ['editor', 'project_owner'],
9 enabled: true
10};
11const result: PutSSOUserAPIResponse = await putSSOUser(tenantId, id, updateAPISSOUserData, true);
12

建立訂閱 Internal Link

參數

名稱類型必填說明
tenantIdstring
createAPIUserSubscriptionDataCreateAPIUserSubscriptionData

回應

回傳:CreateSubscriptionAPIResponse

範例

createSubscription 範例
Copy Copy
1
2const tenantId: string = "acme-corp-tenant-123";
3const createAPIUserSubscriptionData: CreateAPIUserSubscriptionData = {
4 userId: "user_98765",
5 planId: "pro_monthly",
6 paymentMethod: { type: "card", cardId: "card_abc123" },
7 autoRenew: true,
8 trialDays: 14, // 示範可選參數
9 metadata: { campaign: "spring_launch" } // 示範可選參數
10};
11const result: CreateSubscriptionAPIResponse = await createSubscription(tenantId, createAPIUserSubscriptionData);
12

刪除訂閱 Internal Link


參數

名稱類型必填說明
tenantIdstring
idstring
userIdstring

回應

回傳: DeleteSubscriptionAPIResponse


取得訂閱 Internal Link

參數

NameType必填描述
tenantIdstring
userIdstring

回傳

回傳: GetSubscriptionsAPIResponse

範例

getSubscriptions 範例
Copy Copy
1
2const tenantId: string = "contoso-9a1b2c";
3const userId: string = "u-482f6";
4const subscriptions: GetSubscriptionsAPIResponse = await getSubscriptions(tenantId);
5const userSubscriptions: GetSubscriptionsAPIResponse = await getSubscriptions(tenantId, userId);
6

更新訂閱 Internal Link


參數

名稱類型必填描述
tenantIdstring
idstring
updateAPIUserSubscriptionDataUpdateAPIUserSubscriptionData
userIdstring

回應

回傳: UpdateSubscriptionAPIResponse

範例

updateSubscription 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2c';
3const subscriptionId: string = 'sub_7641a2b3';
4const updateData: UpdateAPIUserSubscriptionData = {
5 status: 'active',
6 planId: 'pro_annual',
7 autoRenew: true,
8 renewalDate: '2026-04-15T00:00:00Z',
9 metadata: { upgradedBy: 'billing-team' }
10};
11const userId: string = 'user_215';
12const result: UpdateSubscriptionAPIResponse = await updateSubscription(tenantId, subscriptionId, updateData, userId);
13

取得租戶每日使用量 Internal Link

參數

名稱類型必填描述
tenantIdstring
yearNumbernumber
monthNumbernumber
dayNumbernumber
skipnumber

回應

回傳: GetTenantDailyUsages200Response

範例

getTenantDailyUsages 範例
Copy Copy
1
2const tenantId: string = 'tenant_7a3c2e';
3const dailyUsages: GetTenantDailyUsages200Response = await getTenantDailyUsages(tenantId, 2026, 6, undefined, 0);
4

建立租戶方案 Internal Link

參數

名稱類型是否必填說明
tenantIdstring
createTenantPackageBodyCreateTenantPackageBody

回應

回傳: CreateTenantPackage200Response

範例

createTenantPackage 範例
Copy Copy
1
2const tenantId: string = "tenant_7890";
3const createTenantPackageBody: CreateTenantPackageBody = {
4 packageName: "Growth Plan",
5 maxSeats: 2500,
6 features: {
7 moderation: true,
8 analytics: true,
9 sso: { enabled: true, provider: "saml" }
10 },
11 billing: { interval: "monthly", priceCents: 19900 },
12 // 示範可選參數:notes 非必填但已提供
13 notes: "Onboarding bundle with priority support"
14};
15const result: CreateTenantPackage200Response = await createTenantPackage(tenantId, createTenantPackageBody);
16

刪除租戶方案 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring

回應

回傳: FlagCommentPublic200Response

範例

deleteTenantPackage 範例
Copy Copy
1
2const tenantId: string = 'acme-corp-tenant-01';
3const packageId: string = 'pkg-2026-06-15-001';
4const dryRun: boolean | undefined = undefined; // 可選的旗標範例(函式不需此參數)
5const result: FlagCommentPublic200Response = await deleteTenantPackage(tenantId, packageId);
6

取得租戶方案 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetTenantPackage200Response

範例

getTenantPackage 範例
Copy Copy
1
2const tenantId: string = 'tenant_4b8c2a9f';
3const packageId: string = 'pkg_7d3e1b5c';
4const includeMetadata: boolean | undefined = true;
5const packageResponse: GetTenantPackage200Response = await getTenantPackage(tenantId, packageId);
6

取得租戶方案清單 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
skipnumber

回應

回傳: GetTenantPackages200Response

範例

getTenantPackages 範例
Copy Copy
1
2const tenantId: string = 'tenant_8421';
3const packagesWithSkip: GetTenantPackages200Response = await getTenantPackages(tenantId, 25);
4const packagesWithoutSkip: GetTenantPackages200Response = await getTenantPackages(tenantId);
5

取代租戶方案 Internal Link

參數

名稱類型是否必填說明
tenantIdstring
idstring
replaceTenantPackageBodyReplaceTenantPackageBody

回應

回傳: FlagCommentPublic200Response

範例

replaceTenantPackage 範例
Copy Copy
1
2const tenantId: string = "fastcomments-tenant-114";
3const id: string = "pkg-enterprise-2026-06";
4const replaceTenantPackageBody: ReplaceTenantPackageBody = {
5 name: "EnterpriseModeration",
6 version: "2.4.7",
7 enabled: true,
8 apiStatus: { state: "active", lastUpdated: "2026-06-10T12:00:00Z" },
9 customConfigParameters: { maxCommentLength: 1200, allowImages: true }, // 包含可選設定
10 voteStyle: { style: "updown" }
11};
12const result: FlagCommentPublic200Response = await replaceTenantPackage(tenantId, id, replaceTenantPackageBody);
13

更新租戶方案 Internal Link

參數

NameTypeRequiredDescription
tenantIdstringYes
idstringYes
updateTenantPackageBodyUpdateTenantPackageBodyYes

回應

回傳: FlagCommentPublic200Response

範例

updateTenantPackage 範例
Copy Copy
1
2const tenantId: string = 'tenant_9f3b2a';
3const id: string = 'pkg_pro_2026';
4const updateTenantPackageBody: UpdateTenantPackageBody = {
5 name: 'Pro Plan',
6 monthlyPriceUsd: 49,
7 isActive: true,
8 features: ['moderation', 'analytics', 'sso'],
9 trialDays: 14 // 示範可選參數
10};
11const result: FlagCommentPublic200Response = await updateTenantPackage(tenantId, id, updateTenantPackageBody);
12

建立租戶使用者 Internal Link

參數

名稱類型是否必填描述
tenantIdstring
createTenantUserBodyCreateTenantUserBody

回應

回傳:CreateTenantUser200Response

範例

createTenantUser 範例
Copy Copy
1
2const tenantId: string = "tenant_7f4a2b";
3const createTenantUserBody: CreateTenantUserBody = {
4 email: "jane.doe@example.com",
5 firstName: "Jane",
6 lastName: "Doe",
7 role: "commenter",
8 approved: true,
9 displayName: "Jane D." // 可選:提供友好顯示名稱
10};
11const result: CreateTenantUser200Response = await createTenantUser(tenantId, createTenantUserBody);
12console.log(result);
13

刪除租戶使用者 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
deleteCommentsstring
commentDeleteModestring

回應

回傳: FlagCommentPublic200Response

範例

deleteTenantUser 範例
Copy Copy
1
2const tenantId: string = "tenant_8f3a2b1c4d";
3const id: string = "user_62a4f9e0b7";
4const deleteComments: string = "true";
5const commentDeleteMode: string = "permanent";
6const result: FlagCommentPublic200Response = await deleteTenantUser(tenantId, id, deleteComments, commentDeleteMode);
7

取得租戶使用者 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: GetTenantUser200Response

範例

getTenantUser 範例
Copy Copy
1
2const tenantId: string = 'tenant_ab12c3';
3const id: string = 'user_9f8e7d';
4const response: GetTenantUser200Response = await getTenantUser(tenantId, id);
5console.log(response);
6

取得租戶使用者清單 Internal Link

參數

名稱類型是否必填說明
tenantIdstring
skipnumber

回應

回傳: GetTenantUsers200Response

範例

getTenantUsers 範例
Copy Copy
1
2const tenantId: string = 'tenant_7b8f3a2c-9e4d-4f1a';
3const skip: number = 50;
4const usersResponseDefault: GetTenantUsers200Response = await getTenantUsers(tenantId);
5const usersResponsePaged: GetTenantUsers200Response = await getTenantUsers(tenantId, skip);
6

取代租戶使用者 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
replaceTenantUserBodyReplaceTenantUserBody
updateCommentsstring

回應

回傳: FlagCommentPublic200Response

範例

replaceTenantUser 範例
Copy Copy
1
2const tenantId: string = "f3b9a2d1-8b4e-4c6a-9f2b-1d5c4e6a7b8c";
3const id: string = "user_92f7c3b1";
4const replaceTenantUserBody: ReplaceTenantUserBody = {
5 externalId: "auth0|1234567890",
6 email: "jane.doe@company.com",
7 displayName: "Jane Doe",
8 roles: ["moderator"],
9 metadata: { department: "support" }
10};
11const updateComments: string = "reassign-comments-to-new-user";
12const response: FlagCommentPublic200Response = await replaceTenantUser(tenantId, id, replaceTenantUserBody, updateComments);
13

參數

名稱類型必填說明
tenantIdstring
idstring
redirectURLstring

回應

回傳: FlagCommentPublic200Response

範例

sendLoginLink 範例
Copy Copy
1
2const tenantId: string = "tenant_0a1b2c3d";
3const id: string = "user_984321";
4const redirectURL: string = "https://app.acme-corp.com/welcome";
5const responseWithRedirect: FlagCommentPublic200Response = await sendLoginLink(tenantId, id, redirectURL);
6const responseWithoutRedirect: FlagCommentPublic200Response = await sendLoginLink(tenantId, id);
7

更新租戶使用者 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
updateTenantUserBodyUpdateTenantUserBody
updateCommentsstring

回應

回傳:FlagCommentPublic200Response

範例

updateTenantUser 範例
Copy Copy
1
2const tenantId: string = 'acme-corp';
3const userId: string = 'u_72b9f4';
4const updateTenantUserBody: UpdateTenantUserBody = {
5 email: 'jane.doe@acme.com',
6 displayName: 'Jane Doe',
7 roles: ['moderator'],
8 suspended: false
9};
10const updateComments: string = 'Promoted to moderator after review of activity and community feedback';
11const result: FlagCommentPublic200Response = await updateTenantUser(tenantId, userId, updateTenantUserBody, updateComments);
12

建立租戶 Internal Link

參數

名稱類型必填說明
tenantIdstring
createTenantBodyCreateTenantBody

回應

回傳: CreateTenant200Response

範例

createTenant 範例
Copy Copy
1
2const tenantId: string = 'acme-news-01';
3const createTenantBody: CreateTenantBody = {
4 name: 'Acme News',
5 domainConfiguration: { primaryDomain: 'news.acme.com', redirectHttps: true } as APIDomainConfiguration,
6 importedSites: [{ siteId: 'site-92', url: 'https://news.acme.com' }] as ImportedSiteType[],
7 billingInfo: { planId: 'business_monthly', contactEmail: 'billing@acme.com' } as BillingInfo
8};
9const result: CreateTenant200Response = await createTenant(tenantId, createTenantBody);
10

刪除租戶 Internal Link

參數

名稱型別必填說明
tenantIdstring
idstring
surestring

回應

回傳: FlagCommentPublic200Response

範例

deleteTenant 範例
Copy Copy
1
2const tenantId: string = 'tenant_742b9c';
3const flagId: string = 'flag_1a2b3c';
4const resultWithoutSure: FlagCommentPublic200Response = await deleteTenant(tenantId, flagId);
5const sureConfirmation: string = 'confirmed';
6const resultWithSure: FlagCommentPublic200Response = await deleteTenant(tenantId, flagId, sureConfirmation);
7

取得租戶 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetTenant200Response

範例

getTenant 範例
Copy Copy
1
2const tenantId: string = 'fc_tenant_6b3e2a';
3const id: string = 'site_42f1';
4const tenantResponse: GetTenant200Response = await getTenant(tenantId, id);
5const tenant: APITenant | undefined = tenantResponse.tenant;
6const primaryDomain: APIDomainConfiguration | undefined = tenant?.domainConfiguration?.[0];
7

取得租戶清單 Internal Link


參數

名稱類型必填說明
tenantIdstring
metastring
skipnumber

回應

回傳: GetTenants200Response

範例

getTenants 範例
Copy Copy
1
2const tenantId: string = "fcom-tenant-8b4f2a1c";
3const meta: string = "include=domains,billing&status=active";
4const skip: number = 20;
5const response: GetTenants200Response = await getTenants(tenantId, meta, skip);
6console.log(response);
7

更新租戶 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring
updateTenantBodyUpdateTenantBody

回應

回傳: FlagCommentPublic200Response

範例

updateTenant 範例
Copy Copy
1
2const tenantId: string = 'tenant_84f12';
3const id: string = 'flag_192b';
4const updateTenantBody: UpdateTenantBody = {
5 name: 'Acme Media',
6 billingInfo: { plan: 'enterprise', seats: 25, nextBillingDate: '2026-07-01' },
7 apiDomainConfiguration: { primaryDomain: 'comments.acme.com', additionalDomains: ['acme.com'] },
8 importedSites: [{ siteUrl: 'https://blog.acme.com', archived: false }], // 可選
9 commentSettings: { htmlRenderingMode: 'sanitized', deletionMode: 'soft' } // 可選
10} as UpdateTenantBody;
11const result: FlagCommentPublic200Response = await updateTenant(tenantId, id, updateTenantBody);
12

變更工單狀態 Internal Link

參數

名稱類型必填說明
tenantIdstring
userIdstring
idstring
changeTicketStateBodyChangeTicketStateBody

回應

回傳:ChangeTicketState200Response

範例

changeTicketState 範例
Copy Copy
1
2const tenantId: string = 'tenant_8a7d3f4b';
3const userId: string = 'user_5d1a9b2c';
4const id: string = 'ticket_1024';
5const changeTicketStateBody: ChangeTicketStateBody = {
6 state: 'closed',
7 notifyParticipants: true, // 示範可選參數
8 comment: 'Resolved by support — follow-up not required.'
9};
10const result: ChangeTicketState200Response = await changeTicketState(tenantId, userId, id, changeTicketStateBody);
11

建立工單 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
userIdstring
createTicketBodyCreateTicketBody

回應

回傳: CreateTicket200Response

範例

createTicket 範例
Copy Copy
1
2const tenantId: string = 'tenant_acme_corp';
3const userId: string = 'moderator_jane';
4const createTicketBody: CreateTicketBody = {
5 subject: 'Mass spam reports on article 789',
6 description: 'Multiple identical spam comments posted under article 789. Needs moderation and bulk removal.',
7 priority: 'high',
8 contactEmail: 'jane@acme-corp.com',
9 metadata: { articleId: '789', reportedCount: 12 } // 示範可選的 metadata
10};
11const ticket: CreateTicket200Response = await createTicket(tenantId, userId, createTicketBody);
12

取得工單 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
userIdstring

回應

回傳: GetTicket200Response

範例

getTicket 範例
Copy Copy
1
2const tenantId: string = 'acme-corp';
3const ticketId: string = 'TCKT-20250615-42';
4const userId: string = 'user_84b2';
5
6const ticketWithUser: GetTicket200Response = await getTicket(tenantId, ticketId, userId);
7const ticketWithoutUser: GetTicket200Response = await getTicket(tenantId, ticketId);
8
9console.log(ticketWithUser.id, ticketWithoutUser.id);
10

取得工單清單 Internal Link

參數

名稱類型必填說明
tenantIdstring
userIdstring
statenumber
skipnumber
limitnumber

回應

回傳: GetTickets200Response

範例

getTickets 範例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const userId: string = 'user_87b3';
4const state: number = 2;
5const skip: number = 0;
6const limit: number = 50;
7
8const tickets: GetTickets200Response = await getTickets(tenantId, userId, state, skip, limit);
9

取得翻譯 Internal Link

參數

名稱類型必填描述
namespacestring
componentstring
localestring
useFullTranslationIdsboolean

回應

回傳: GetTranslations200Response

範例

getTranslations 範例
Copy Copy
1
2const namespaceName: string = 'site-ui';
3const componentName: string = 'comment-widget';
4const locale: string = 'fr-FR';
5const useFullTranslationIds: boolean = true;
6const translationsWithLocale: GetTranslations200Response = await getTranslations(namespaceName, componentName, locale, useFullTranslationIds);
7const translationsDefault: GetTranslations200Response = await getTranslations(namespaceName, componentName);
8

上傳圖片 Internal Link

上傳並調整圖片大小

參數

名稱類型必填說明
tenantIdstring
fileBlob
sizePresetSizePreset
urlIdstring

回應

回傳: UploadImageResponse


以 ID 取得使用者徽章進度 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetUserBadgeProgressById200Response

範例

getUserBadgeProgressById 範例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-241';
3const badgeId: string = 'user-78b3d-badge-3';
4const response: GetUserBadgeProgressById200Response = await getUserBadgeProgressById(tenantId, badgeId);
5const progress: UserBadgeProgress | undefined = (response as unknown as { progress?: UserBadgeProgress }).progress;
6const percentComplete: number | undefined = progress?.percentage;
7console.log('Badge progress percent complete:', percentComplete);
8

以使用者 ID 取得使用者徽章進度 Internal Link

參數

名稱類型必填說明
tenantIdstring
userIdstring

回應

回傳: GetUserBadgeProgressById200Response

範例

getUserBadgeProgressByUserId 範例
Copy Copy
1
2const tenantId: string = 'acme-inc-tenant-01';
3const userId: string = 'user_73c9b2';
4const progress: GetUserBadgeProgressById200Response = await getUserBadgeProgressByUserId(tenantId, userId);
5
6async function maybeFetchProgress(tenant: string, user?: string): Promise<GetUserBadgeProgressById200Response | null> {
7 if (!user) return null;
8 return await getUserBadgeProgressByUserId(tenant, user);
9}
10
11const optionalResult: GetUserBadgeProgressById200Response | null = await maybeFetchProgress(tenantId, userId);
12

取得使用者徽章進度清單 Internal Link


參數

名稱類型必填描述
tenantIdstring
userIdstring
limitnumber
skipnumber

回應

回傳: GetUserBadgeProgressList200Response

範例

getUserBadgeProgressList 範例
Copy Copy
1
2const tenantId: string = 'tenant_4f3a2b9c';
3const userId: string = 'user_7721d';
4const limit: number = 20;
5const skip: number = 0;
6const result: GetUserBadgeProgressList200Response = await getUserBadgeProgressList(tenantId, userId, limit, skip);
7

建立使用者徽章 Internal Link

參數

名稱類型必填說明
tenantIdstring
createUserBadgeParamsCreateUserBadgeParams

回應

回傳: CreateUserBadge200Response

範例

createUserBadge 範例
Copy Copy
1
2const tenantId: string = "tenant_7f4b2a";
3const createUserBadgeParams: CreateUserBadgeParams = {
4 code: "top_contributor",
5 title: "Top Contributor",
6 description: "Awarded for 100 high-quality comments",
7 iconUrl: "https://cdn.fastcomments.com/badges/top_contributor.svg",
8 isActive: true,
9 criteria: { commentsRequired: 100 },
10 customConfig: { displayOnProfile: true } // 示範可選參數
11};
12const result: CreateUserBadge200Response = await createUserBadge(tenantId, createUserBadgeParams);
13

刪除使用者徽章 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring

回應

回傳: UpdateUserBadge200Response

範例

deleteUserBadge 範例
Copy Copy
1
2const tenantId: string = "tenant_8b3f2c7a";
3const badgeIdOptional: string | undefined = Math.random() > 0.5 ? "badge_4f9a21" : undefined;
4const id: string = badgeIdOptional ?? "badge_backup_01";
5const result: UpdateUserBadge200Response = await deleteUserBadge(tenantId, id);
6

取得使用者徽章 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring

回應

回傳: GetUserBadge200Response

範例

getUserBadge 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_6b8f2a1c';
4 const id: string = 'badge_9f3d4b2a';
5 const response: GetUserBadge200Response = await getUserBadge(tenantId, id);
6 const badge: UserBadge | undefined = response.userBadge;
7 const badgeName: string | undefined = badge?.name;
8 console.log('Retrieved badge name:', badgeName);
9})();
10

取得使用者徽章清單 Internal Link

參數

Name類型必填描述
tenantIdstring
userIdstring
badgeIdstring
typenumber
displayedOnCommentsboolean
limitnumber
skipnumber

回應

回傳:GetUserBadges200Response

範例

getUserBadges 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f9a12';
3const userId: string = 'user_42b7';
4const badgeId: string = 'badge_top_contributor';
5const type: number = 2;
6const displayedOnComments: boolean = true;
7const limit: number = 25;
8const skip: number = 0;
9const badges: GetUserBadges200Response = await getUserBadges(tenantId, userId, badgeId, type, displayedOnComments, limit, skip);
10

更新使用者徽章 Internal Link

參數

名稱類型必填描述
tenantIdstring
idstring
updateUserBadgeParamsUpdateUserBadgeParams

回應

回傳: UpdateUserBadge200Response

範例

updateUserBadge 範例
Copy Copy
1
2const tenantId: string = "tenant_9a8b7c";
3const id: string = "badge_a1b2c3";
4const updateUserBadgeParams: UpdateUserBadgeParams = {
5 title: "Community Helper",
6 description: "Awarded for providing 50 helpful answers",
7 iconUrl: "https://cdn.fastcomments.com/badges/community-helper.png",
8 isActive: true,
9 expiryDate: undefined
10};
11const result: UpdateUserBadge200Response = await updateUserBadge(tenantId, id, updateUserBadgeParams);
12

取得使用者通知計數 Internal Link

參數

名稱類型必填說明
tenantIdstring
ssostring

回應

回傳: GetUserNotificationCount200Response

範例

getUserNotificationCount 範例
Copy Copy
1
2const tenantId: string = 'tenant_acme_01';
3const ssoToken: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.sso_payload.signature';
4const notificationCountNoSSO: GetUserNotificationCount200Response = await getUserNotificationCount(tenantId);
5const notificationCountWithSSO: GetUserNotificationCount200Response = await getUserNotificationCount(tenantId, ssoToken);
6

取得使用者通知 Internal Link


參數

NameTypeRequiredDescription
tenantIdstring
urlIdstring
pageSizenumber
afterIdstring
includeContextboolean
afterCreatedAtnumber
unreadOnlyboolean
dmOnlyboolean
noDmboolean
includeTranslationsboolean
includeTenantNotificationsboolean
ssostring

回應

回傳:GetUserNotifications200Response

範例

getUserNotifications 範例
Copy Copy
1
2const tenantId: string = "tenant_8271";
3const urlId: string = "https://www.news-site.com/articles/2026/06/15/ai-updates";
4const pageSize: number = 25;
5const afterId: string = "notif_abc123";
6const includeContext: boolean = true;
7const afterCreatedAt: number = Date.now() - 86_400_000;
8const unreadOnly: boolean = true;
9const dmOnly: boolean = false;
10const noDm: boolean = false;
11const includeTranslations: boolean = true;
12const includeTenantNotifications: boolean = true;
13const sso: string = "sso_token_xyz_987";
14
15const notifications: GetUserNotifications200Response = await getUserNotifications(
16 tenantId,
17 urlId,
18 pageSize,
19 afterId,
20 includeContext,
21 afterCreatedAt,
22 unreadOnly,
23 dmOnly,
24 noDm,
25 includeTranslations,
26 includeTenantNotifications,
27 sso
28);
29

重置使用者通知計數 Internal Link

參數

名稱類型必填說明
tenantIdstring
ssostring

回應

回傳: ResetUserNotifications200Response

範例

resetUserNotificationCount 範例
Copy Copy
1
2const tenantId: string = "tenant_8a3f2b6c";
3const ssoToken: string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyX2QxMjM0IiwiaWF0IjoxNjI1MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c";
4const resetResponseWithSso: ResetUserNotifications200Response = await resetUserNotificationCount(tenantId, ssoToken);
5const resetResponseWithoutSso: ResetUserNotifications200Response = await resetUserNotificationCount(tenantId);
6

重置使用者通知 Internal Link


參數

名稱類型必填說明
tenantIdstring
afterIdstring
afterCreatedAtnumber
unreadOnlyboolean
dmOnlyboolean
noDmboolean
ssostring

回應

回傳: ResetUserNotifications200Response

範例

resetUserNotifications 範例
Copy Copy
1
2const tenantId: string = "tenant_9b1f2";
3const afterId: string = "notification_0001";
4const afterCreatedAt: number = Date.now() - 60 * 60 * 1000; // 一小時前
5const unreadOnly: boolean = true;
6const dmOnly: boolean = false;
7const noDm: boolean = false;
8const sso: string = "sso_session_7f2d";
9const result: ResetUserNotifications200Response = await resetUserNotifications(
10 tenantId,
11 afterId,
12 afterCreatedAt,
13 unreadOnly,
14 dmOnly,
15 noDm,
16 sso
17);
18

更新使用者留言通知訂閱狀態 Internal Link

啟用或停用針對特定評論的通知。

參數

名稱類型必填說明
tenantIdstring
notificationIdstring
optedInOrOutUpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum
commentIdstring
ssostring

回應

回傳:UpdateUserNotificationStatus200Response

範例

updateUserNotificationCommentSubscriptionStatus 範例
Copy Copy
1
2const tenantId: string = 'f3a9c8b0-4d2e-4f8a-9c3b-1234567890ab';
3const notificationId: string = '62a1f4d2-8c7b-4e1a-aaa1-abcdef123456';
4const commentId: string = '7e4a2b1c-1234-5678-90ab-cdef12345678';
5const optedInOrOut: UpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum = UpdateUserNotificationCommentSubscriptionStatusOptedInOrOutEnum.OptedIn;
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.ssoPayload.signature';
7const response: UpdateUserNotificationStatus200Response = await updateUserNotificationCommentSubscriptionStatus(tenantId, notificationId, optedInOrOut, commentId, sso);
8

更新使用者頁面通知訂閱狀態 Internal Link

啟用或停用頁面的通知。當使用者訂閱頁面時,會為新的根評論建立通知,並且

參數

名稱類型必填描述
tenantIdstring
urlIdstring
urlstring
pageTitlestring
subscribedOrUnsubscribedUpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnum
ssostring

回應

回傳: UpdateUserNotificationStatus200Response

範例

updateUserNotificationPageSubscriptionStatus 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f3b2';
3const urlId: string = 'article_987';
4const url: string = 'https://www.news-site.com/articles/2026/pasta-guide';
5const pageTitle: string = 'The Definitive Guide to Cooking Pasta';
6const subscribedOrUnsubscribed: UpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnum = UpdateUserNotificationPageSubscriptionStatusSubscribedOrUnsubscribedEnum.Subscribed;
7const sso: string = 'sso-token-62b9f1';
8const result: UpdateUserNotificationStatus200Response = await updateUserNotificationPageSubscriptionStatus(tenantId, urlId, url, pageTitle, subscribedOrUnsubscribed, sso);
9

更新使用者通知狀態 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
notificationIdstring
newStatusUpdateUserNotificationStatusNewStatusEnum
ssostring

回應

回傳:UpdateUserNotificationStatus200Response

範例

updateUserNotificationStatus 範例
Copy Copy
1
2const tenantId: string = 'tenant_5f2a8b9c';
3const notificationId: string = 'notif_987654321';
4const newStatus: UpdateUserNotificationStatusNewStatusEnum = UpdateUserNotificationStatusNewStatusEnum.Read;
5const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.payload.signature';
6const result: UpdateUserNotificationStatus200Response = await updateUserNotificationStatus(tenantId, notificationId, newStatus, sso);
7

取得使用者在線狀態 Internal Link


參數

名稱類型必填說明
tenantIdstring
urlIdWSstring
userIdsstring

回應

回傳:GetUserPresenceStatuses200Response

範例

getUserPresenceStatuses 範例
Copy Copy
1
2const tenantId: string = 'tenant_42';
3const urlIdWS: string = 'wss://comments.fastsite.com/ws/tenant_42';
4const userIds: string = 'user_9012,user_3478';
5const includePresenceMetadata: boolean | undefined = true; // 可選參數範例
6const presenceStatuses: GetUserPresenceStatuses200Response = await getUserPresenceStatuses(tenantId, urlIdWS, userIds);
7

搜尋使用者 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
urlIdstring
usernameStartsWithstring
mentionGroupIdsArray
ssostring
searchSectionSearchUsersSearchSectionEnum

回應

回傳: SearchUsers200Response

範例

searchUsers 範例
Copy Copy
1
2const tenantId: string = 'tenant_7890';
3const urlId: string = 'news/2026-06-15-world-cup-final';
4const usernameStartsWith: string = 'mar';
5const mentionGroupIds: string[] = ['staff', 'trusted-commenters'];
6const sso: string = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI0NTY3OCJ9.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c';
7const searchSection: SearchUsersSearchSectionEnum = SearchUsersSearchSectionEnum.Commenters;
8const response: SearchUsers200Response = await searchUsers(tenantId, urlId, usernameStartsWith, mentionGroupIds, sso, searchSection);
9

取得使用者 Internal Link

參數

NameTypeRequiredDescription
tenantIdstring
idstring

回應

傳回: GetUser200Response

範例

getUser 範例
Copy Copy
1
2const tenantId: string = 'fastcomments_corp';
3const id: string = 'user_9f8b7c6d-5e4a-3b2c-1f0e-123456789abc';
4const response: GetUser200Response = await getUser(tenantId, id);
5const userEmail: string | undefined = response.user?.email;
6const displayName: string | undefined = response.user?.displayName
7

建立投票 Internal Link

參數

名稱類型必填說明
tenantIdstring
commentIdstring
directionCreateVoteDirectionEnum
userIdstring
anonUserIdstring

回應

回傳: VoteComment200Response

範例

createVote 範例
Copy Copy
1
2const tenantId: string = 'fastcomments-tenant-001';
3const commentId: string = 'cmt_8f3b2a9d';
4const direction: CreateVoteDirectionEnum = CreateVoteDirectionEnum.Up;
5const userId: string = 'user_5021';
6const anonUserId: string = 'anon_7a9c';
7
8const voteResponse: VoteComment200Response = await createVote(tenantId, commentId, direction, userId, anonUserId);
9

刪除投票 Internal Link

參數

名稱類型必填說明
tenantIdstring
idstring
editKeystring

回應

回傳: DeleteCommentVote200Response

範例

deleteVote 範例
Copy Copy
1
2(async () => {
3 const tenantId: string = 'tenant_8421';
4 const id: string = 'vote_3f9b7c2a';
5 const editKey: string = 'edit_7Xk9LpQ';
6 const responseWithoutEdit: DeleteCommentVote200Response = await deleteVote(tenantId, id);
7 const responseWithEdit: DeleteCommentVote200Response = await deleteVote(tenantId, id, editKey);
8 console.log(responseWithoutEdit, responseWithEdit);
9})();
10

取得投票 Internal Link


參數

名稱類型必填描述
tenantIdstring
urlIdstring

回應

回傳: GetVotes200Response

範例

getVotes 範例
Copy Copy
1
2const tenantId: string = 'tenant_7f8e91c2';
3const urlId: string = 'https://www.sportsdaily.com/news/2026/06/15/championship-game-recap';
4const votes: GetVotes200Response = await getVotes(tenantId, urlId);
5console.log(votes);
6

取得使用者的投票 Internal Link

參數

名稱類型必填描述
tenantIdstring
urlIdstring
userIdstring
anonUserIdstring

回應

回傳: GetVotesForUser200Response

範例

getVotesForUser 範例
Copy Copy
1
2const tenantId: string = 'tenant_9b8f7c6d';
3const urlId: string = 'articles/product-update-2026';
4const userId: string = 'user_c12345';
5const anonUserId: string = 'anon_7f4e2a';
6const votes: GetVotesForUser200Response = await getVotesForUser(tenantId, urlId, userId, anonUserId);
7

需要幫助嗎?

如果您在使用 JavaScript/TypeScript SDK 時遇到任何問題或有任何疑問,請:

貢獻

歡迎貢獻!請造訪 GitHub 儲存庫 以取得貢獻指南。