規則、觸發器與回呼
驗證寫入、自動化資料表事件、檢視階段性工作,並管理各範圍支援的回呼憑證。
/private/module/custom_tables/{scope}/tables/{table_id}/rules回傳資料表已正規化的驗證、核准、通道與不變條件規則。
適合顯示規則編輯器,或在變更資料前檢查實際套用的寫入限制。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/rules - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/rules - 公司
/private/module/custom_tables/company/tables/{table_id}/rules
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableAccessRequired |
| 部門 | 可使用 | CustomTableAccessRequired |
| 公司 | 可使用 | CustomTableAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要取得規則的資料表 UUID。 |
回應結構
TableRulesResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
rules | object[] | 否 | 未指定 |
table_id | string | 是 | 未指定 |
warnings | string[] | 否 | Non-fatal notices about the saved rule set — e.g. a content-masking notice when a require_approval rule is saved on a table with column_acl or grant visible_columns restrictions (approval-gate spec §4). |
範例
取得資料表的唯一值規則
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"rules": [
{
"type": "unique",
"id": "rule_a1b2c3d4",
"name": "訂單編號不可重複",
"columns": [
"訂單編號"
],
"case_insensitive": true,
"when": null
}
],
"warnings": []
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/rules驗證並以原子方式取代後續資料表寫入所套用的完整規則集。
預覽完整的目標規則集後使用;PUT 會在單一交易中取代已儲存的規則清單。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/rules - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/rules - 公司
/private/module/custom_tables/company/tables/{table_id}/rules
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要取代規則的資料表 UUID。 |
請求結構
TableRulesPayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
rules | object[] | 是 | Full rules list (PUT semantics; max 10). Each rule: {"type": "compare" | "unique" | "no_overlap" | "exists" | "not_exists" | "count_limit" | "transition" | "check" | "require" | "require_approval" | "channel" | "invariant" | "immutable_when", "name"?: str, "id"?: "rule_<hex>", "when"?: [predicates], ...type-specific fields}. A "count_limit" rule caps a live-row bucket at {"max": int >= 1}: with "table_id" + "match" it counts the exists-style cross-table bucket; without "table_id" it counts THIS table's rows matching "where" predicates ("$row.<col>" values partition per row, e.g. employee eq $row.employee). A "no_overlap" rule additionally takes "min_gap"?: number — minimum separation between intervals in the same scope partition (numeric bounds: plain number; datetime: minutes; date: days; touching at exactly min_gap is allowed) — and bounds its intervals EITHER with "start_column"+"end_column" OR with "interval_column" (ONE interval-type column whose {start, end} cell carries both bounds; datetime class, min_gap in minutes) — never both. A "channel" rule (SCP v1.3) takes EITHER {"column", "require_present", "read_op"?: "subset" | "overlaps"} or {"policy": <node tree>}, plus "enforcement": "observe" | "enforce" — see ChannelRuleFlat / ChannelRulePolicy. An "invariant" rule takes {"policy": <node tree>, "enforcement"} and is principal-blind: it holds for every writer on every path — see InvariantRule. An "immutable_when" rule takes {"prior_when": [predicates], "columns": [refs]} and takes no "when": prior_when is the lock condition evaluated against the row's PRE-image (the row before the write); while it matches, the listed columns may not change (400 on violation). Locks stored inline columns only (not computed/link). |
回應結構
TableRulesResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
rules | object[] | 否 | 未指定 |
table_id | string | 是 | 未指定 |
warnings | string[] | 否 | Non-fatal notices about the saved rule set — e.g. a content-masking notice when a require_approval rule is saved on a table with column_acl or grant visible_columns restrictions (approval-gate spec §4). |
範例
設定不分大小寫的唯一值規則
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"rules": [
{
"type": "unique",
"name": "訂單編號不可重複",
"columns": [
"訂單編號"
],
"case_insensitive": true
}
]
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"rules": [
{
"type": "unique",
"id": "rule_a1b2c3d4",
"name": "訂單編號不可重複",
"columns": [
"訂單編號"
],
"case_insensitive": true,
"when": null
}
],
"warnings": []
}列一旦 posted 就凍結數量與單價
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"rules": [
{
"type": "immutable_when",
"name": "posted-locks-qty",
"prior_when": [
{
"column": "狀態",
"op": "eq",
"value": "posted"
}
],
"columns": [
"數量",
"單價"
]
}
]
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"rules": [
{
"type": "immutable_when",
"id": "rule_b2c3d4e5",
"name": "posted-locks-qty",
"prior_when": [
{
"column": "狀態",
"op": "eq",
"value": "posted"
}
],
"columns": [
"數量",
"單價"
],
"when": null
}
],
"warnings": []
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 400 | 至少一筆規則的類型、欄位參照、運算式或選項無效。 | |
| 400 | immutable_when 規則缺少 prior_when 或 columns、帶了一般的 when、被鎖欄位超過 20 個,或鎖到計算欄/link 欄。detail 是純字串,有 hint 時會在句點後併入。 | |
| 409 | 仍有未解決的階段性變更依賴 require_approval 規則,因此不能變更該規則。 | |
| 423 | 資料表目前被結構遷移鎖定。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/rules/preview驗證候選規則集,並在有上限的樣本上評估,不儲存規則。
取代正式規則前使用,特別是不變條件與跨資料表限制。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/rules/preview - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/rules/preview - 公司
/private/module/custom_tables/company/tables/{table_id}/rules/preview
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要評估候選規則的資料表 UUID。 |
請求結構
TableRulesPreviewPayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
rules | object[] | 是 | Full rules list (PUT semantics; max 10). Each rule: {"type": "compare" | "unique" | "no_overlap" | "exists" | "not_exists" | "count_limit" | "transition" | "check" | "require" | "require_approval" | "channel" | "invariant" | "immutable_when", "name"?: str, "id"?: "rule_<hex>", "when"?: [predicates], ...type-specific fields}. A "count_limit" rule caps a live-row bucket at {"max": int >= 1}: with "table_id" + "match" it counts the exists-style cross-table bucket; without "table_id" it counts THIS table's rows matching "where" predicates ("$row.<col>" values partition per row, e.g. employee eq $row.employee). A "no_overlap" rule additionally takes "min_gap"?: number — minimum separation between intervals in the same scope partition (numeric bounds: plain number; datetime: minutes; date: days; touching at exactly min_gap is allowed) — and bounds its intervals EITHER with "start_column"+"end_column" OR with "interval_column" (ONE interval-type column whose {start, end} cell carries both bounds; datetime class, min_gap in minutes) — never both. A "channel" rule (SCP v1.3) takes EITHER {"column", "require_present", "read_op"?: "subset" | "overlaps"} or {"policy": <node tree>}, plus "enforcement": "observe" | "enforce" — see ChannelRuleFlat / ChannelRulePolicy. An "invariant" rule takes {"policy": <node tree>, "enforcement"} and is principal-blind: it holds for every writer on every path — see InvariantRule. An "immutable_when" rule takes {"prior_when": [predicates], "columns": [refs]} and takes no "when": prior_when is the lock condition evaluated against the row's PRE-image (the row before the write); while it matches, the listed columns may not change (400 on violation). Locks stored inline columns only (not computed/link). |
回應結構
RulesPreviewResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
invariant_violations | integer | 否 | Sampled rows that already fail the candidate INVARIANT rules. Reported once, not per room: an invariant has no principal. Such rows stay readable but become uneditable until repaired. |
rooms | RulesPreviewRoomImpact[] | 否 | Per acting room, for the CHANNEL rules. Empty when the candidate carries no channel rule or the table has no chatroom grants. |
sample_cap | integer | 是 | The sampling cap applied. |
sampled_rows | integer | 是 | Live rows actually evaluated (the first N by sort_order). EVERY count below is out of this number, not out of total_rows. |
table_id | string | 是 | The table previewed. |
total_rows | integer | 是 | Live rows in the table. Greater than sampled_rows ⇒ the preview was truncated and says so in warnings. |
warnings | string[] | 否 | Truncation notices and lockout alarms, in plain language. |
範例
預覽唯一值規則
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"rules": [
{
"type": "unique",
"name": "訂單編號不可重複",
"columns": [
"訂單編號"
],
"case_insensitive": true
}
]
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"sampled_rows": 1,
"total_rows": 1,
"sample_cap": 200,
"rooms": [],
"invariant_violations": 0,
"warnings": []
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 400 | 候選規則的結構或語意不合法。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/triggers回傳資料表已設定的正規化事件觸發器與動作。
適合顯示自動化設定,或在取代前保留現有觸發器。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/triggers - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/triggers - 公司
/private/module/custom_tables/company/tables/{table_id}/triggers
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableAccessRequired |
| 部門 | 可使用 | CustomTableAccessRequired |
| 公司 | 可使用 | CustomTableAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要取得觸發器的資料表 UUID。 |
回應結構
TableTriggersResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_id | string | 是 | 未指定 |
triggers | object[] | 否 | 未指定 |
範例
取得資料列建立通知觸發器
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"triggers": [
{
"id": "trg_666666666666",
"name": "通知新訂單",
"on": "created",
"created_by": "44444444-4444-4444-8444-444444444444",
"when": null,
"actions": [
{
"id": "act_111111111111",
"type": "notify",
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"message": "已建立訂單:$row.訂單編號"
}
]
}
]
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/triggers驗證並以原子方式取代事件驅動通知、API/資料表動作、通道附件投遞與 Sandbox 工作提交。
要發佈資料表的完整目標觸發器設定時使用。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/triggers - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/triggers - 公司
/private/module/custom_tables/company/tables/{table_id}/triggers
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要取代觸發器的資料表 UUID。 |
請求結構
TableTriggersPayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
triggers | object[] | 是 | Full triggers list (PUT replace semantics; at most 50 triggers). Each trigger authors 1 to 5 actions from the ten supported types: webhook, api_call, create_record, update_record, notify, send_channel_message, invoke_command, delete_record, materialize_slots, and submit_sandbox_job. Saved configs preserve exactly one stable identity per action; server-minted values use act_<12 hex>. GET echoes it as action.id, which clients must round-trip when replacing the list. materialize_slots fails closed before any slot insert when more than 1000 live source rows are scanned; truncating slot inserts at 1000 per tick remains success. |
回應結構
TableTriggersResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_id | string | 是 | 未指定 |
triggers | object[] | 否 | 未指定 |
範例
建立資料列時通知聊天室
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"triggers": [
{
"name": "通知新訂單",
"on": "created",
"actions": [
{
"type": "notify",
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"message": "已建立訂單:$row.訂單編號"
}
]
}
]
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"triggers": [
{
"id": "trg_666666666666",
"name": "通知新訂單",
"on": "created",
"created_by": "44444444-4444-4444-8444-444444444444",
"when": null,
"actions": [
{
"id": "act_111111111111",
"type": "notify",
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"message": "已建立訂單:$row.訂單編號"
}
]
}
]
}傳送附件欄位並提交 pinned Sandbox task version
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"triggers": [
{
"name": "傳送附件並建立 Sandbox 工作",
"on": "created",
"actions": [
{
"type": "send_channel_message",
"recipient": "created_by_client",
"message": "訂單附件:$row.訂單編號",
"attachments": [
{
"column": "col_a1111111_1111_4111_8111_111111111111"
}
]
},
{
"type": "submit_sandbox_job",
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"task_version_id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"timeout_seconds": 900,
"input": {
"order_id": "$row.訂單編號"
}
}
]
}
]
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"triggers": [
{
"id": "trg_777777777777",
"name": "傳送附件並建立 Sandbox 工作",
"on": "created",
"actions": [
{
"type": "send_channel_message",
"recipient": "created_by_client",
"message": "訂單附件:$row.訂單編號",
"attachments": [
{
"column": "col_a1111111_1111_4111_8111_111111111111"
}
],
"id": "act_222222222222"
},
{
"type": "submit_sandbox_job",
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"task_version_id": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"timeout_seconds": 900,
"input": {
"order_id": "$row.訂單編號"
},
"id": "act_333333333333"
}
],
"created_by": "44444444-4444-4444-8444-444444444444",
"when": null
}
]
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 400 | 觸發事件、條件或動作無效,或動作數量超出支援範圍。 | |
| 400 | 資料表帶有通道範圍限制政策,無法與觸發器併用。 | |
| 400 | 某個 trigger 保留原 id 卻更改了 schedule.type;schedule identity 依 kind 區分,請讓舊 id 退役,並用新 id 建立新 kind。 | |
| 409 | Locked-graph 重新驗證或非資料庫的 compile/refresh failure,使伺服器無法安全更新所有先前仍有效的相依 commands。這個結構化錯誤與下方 flat-detail database errors 不同;trigger JSON、schema history 紀錄與所有 command definition 更新會在同一個交易中一起回滾。 | |
| 409 | Trigger-update transaction 中遇到 MySQL 1205 lock-wait timeout 或 1213 deadlock。完整 transaction 已回滾;這個可重試 409 使用 flat string detail,不是 command_dependency_refresh_failed。 | |
| 500 | 發生其他 database operational failure。完整 transaction 已回滾,response 會淨化成 flat detail:Database operation failed.。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/triggers/schedule-preview以 scheduler 自己的 evaluator 唯讀地評估這張表上每一個 schedule trigger,回傳每個 trigger 的機器可讀原因計數與時鐘狀態。
當 scheduler tick 健康卻一直回報零筆 run,而你需要知道資料列是缺日期、仍在未來、被 when 排除、已經消耗,還是真的到期時使用。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/triggers/schedule-preview - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/triggers/schedule-preview - 公司
/private/module/custom_tables/company/tables/{table_id}/triggers/schedule-preview
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要評估其 schedule triggers 的資料表 UUID。 |
回應結構
TableSchedulePreviewResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
evaluated_at | string (date-time) | 是 | 未指定 |
live_records | integer | 是 | 未指定 |
record_limit | integer | 否 | 未指定 |
table_id | string | 是 | 未指定 |
triggers | (InvalidSchedulePreview | DateColumnReachedSchedulePreview | IntervalSchedulePreview | DailySchedulePreview | CronSchedulePreview)[] | 否 | 未指定 |
範例
預覽一張含 date trigger、interval trigger 與一個損毀儲存 trigger 的表
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}{
"table_id": "22222222-2222-4222-8222-222222222222",
"evaluated_at": "2026-08-27T05:02:13",
"live_records": 2,
"record_limit": 1000,
"triggers": [
{
"kind": "date_column_reached",
"trigger_id": "trg_666666666666",
"config_status": "valid",
"already_fired": 1,
"records_scanned": 2,
"missing_schedule_value": 0,
"invalid_schedule_value": 0,
"scheduled_for_future": 1,
"when_filter_mismatch": 0,
"due_now": 0,
"unscanned": 0,
"truncated": false,
"warnings": []
},
{
"kind": "interval",
"trigger_id": "trg_777777777777",
"config_status": "valid",
"last_consumed_window_at": "2026-08-27T05:00:00",
"due_at": null,
"due_now": false,
"active_run": false,
"warnings": [
"when_ignored_for_recordless_schedule"
]
},
{
"kind": "invalid",
"trigger_id": "trg_888888888888",
"stored_schedule_type": "monthly",
"config_status": "invalid",
"error_codes": [
"unsupported_schedule_type"
],
"warnings": []
}
]
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 這個 scope 沒有該資料表,或該表已在垃圾桶。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/trigger-runs回傳資料表非同步觸發動作的分頁執行記錄。
適合監測自動化健康狀態、檢查失敗,或在重試前找到執行記錄。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/trigger-runs - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/trigger-runs - 公司
/private/module/custom_tables/company/tables/{table_id}/trigger-runs
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要列出觸發器執行記錄的資料表 UUID。 |
status | query | enum:pending|running|done|failed|stuck | 否 | 選填的執行狀態:pending、running、done、failed 或 stuck。 |
skip | query | int >= 0 | 否 | 略過前幾筆符合條件的執行記錄,預設為 0。 |
limit | query | int 1..200 | 否 | 最多回傳幾筆執行記錄,可填 1 到 200。 |
回應結構
TriggerRunListResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
runs | TriggerRunResponse[] | 是 | 未指定 |
total | integer | 是 | 未指定 |
範例
列出失敗的觸發器執行記錄
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"query": {
"status": "failed",
"skip": "0",
"limit": "50"
}
}{
"runs": [
{
"id": "55555555-5555-4555-8555-555555555555",
"table_id": "22222222-2222-4222-8222-222222222222",
"trigger_id": "trg_666666666666",
"record_id": "33333333-3333-4333-8333-333333333333",
"record_version": 1,
"event": "created",
"status": "failed",
"attempts": 3,
"error": "Webhook returned HTTP 500",
"chain_id": "77777777-7777-4777-8777-777777777777",
"depth": 0,
"payload": {
"event": "created",
"table_id": "22222222-2222-4222-8222-222222222222",
"record_id": "33333333-3333-4333-8333-333333333333",
"data": {
"訂單編號": "ORD-1001"
}
},
"action_results": [
{
"action_index": 0,
"ok": false,
"error": "HTTP 500"
}
],
"created_at": "2026-07-19T03:00:00",
"updated_at": "2026-07-19T03:05:00"
}
],
"total": 1
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/trigger-runs/{run_id}/retry將符合條件的失敗、待執行或過期執行記錄重新放回觸發器佇列。
排除下游錯誤後,重排 failed、pending 或逾時 running 執行;已完成的 run 不能重試。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/trigger-runs/{run_id}/retry - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/trigger-runs/{run_id}/retry - 公司
/private/module/custom_tables/company/tables/{table_id}/trigger-runs/{run_id}/retry
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 擁有觸發器執行記錄的資料表 UUID。 |
run_id | path | uuid | 是 | 要重試的觸發器執行 UUID。 |
回應結構
TriggerRunResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
action_results | object[] | null | 否 | Per-action results written by the worker |
attempts | integer | 是 | 未指定 |
chain_id | string | 是 | 未指定 |
created_at | string (date-time) | 是 | 未指定 |
depth | integer | 是 | 未指定 |
error | string | null | 是 | 未指定 |
event | string | 是 | 未指定 |
id | string | 是 | 未指定 |
payload | object | null | 否 | Trigger-time row snapshot + change metadata (the webhook payload) |
record_id | string | null | 是 | 未指定 |
record_version | integer | 是 | 未指定 |
status | string | 是 | pending | running | done | failed |
table_id | string | 是 | 未指定 |
trigger_id | string | 是 | 未指定 |
updated_at | string (date-time) | 是 | 未指定 |
範例
將失敗的觸發器執行重新排入佇列
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222",
"run_id": "55555555-5555-4555-8555-555555555555"
}
}{
"id": "55555555-5555-4555-8555-555555555555",
"table_id": "22222222-2222-4222-8222-222222222222",
"trigger_id": "trg_666666666666",
"record_id": "33333333-3333-4333-8333-333333333333",
"record_version": 1,
"event": "created",
"status": "pending",
"attempts": 3,
"error": null,
"chain_id": "77777777-7777-4777-8777-777777777777",
"depth": 0,
"payload": {
"event": "created",
"table_id": "22222222-2222-4222-8222-222222222222",
"record_id": "33333333-3333-4333-8333-333333333333",
"data": {
"訂單編號": "ORD-1001"
}
},
"action_results": [
{
"action_index": 0,
"ok": false,
"error": "HTTP 500"
}
],
"created_at": "2026-07-19T03:00:00",
"updated_at": "2026-07-19T03:05:00"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 這張資料表沒有指定觸發器執行記錄。 | |
| 409 | 執行已完成,或處於其他不可重試的狀態。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/staged-changes列出被 require_approval 規則暫緩的寫入,以及審核與套用狀態。
適合監測需核准的寫入,或調查為何資料列被待審狀態擋住。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/staged-changes - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/staged-changes - 公司
/private/module/custom_tables/company/tables/{table_id}/staged-changes
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableAccessRequired |
| 部門 | 可使用 | CustomTableAccessRequired |
| 公司 | 可使用 | CustomTableAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要列出階段性變更的資料表 UUID。 |
status | query | enum:pending|applying|applied|apply_failed|discarded | 否 | 選填的進程狀態:pending、applying、applied、apply_failed 或 discarded。 |
change_type | query | enum:create|update|delete|restore|revert|batch_actions | 否 | 選填的暫緩操作類型,例如 create、update、delete、restore、revert 或 batch_actions。 |
skip | query | int >= 0 | 否 | 略過前幾筆符合條件的階段性變更,預設為 0。 |
limit | query | int 1..200 | 否 | 最多回傳幾筆階段性變更,可填 1 到 200。 |
回應結構
StagedChangeListResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
staged_changes | StagedChangeResponse[] | 是 | Visible staged changes, newest first |
total | integer | 是 | Total visible staged changes matching the filters (before pagination) |
範例
列出待審階段性變更
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"query": {
"status": "pending",
"skip": "0",
"limit": "50"
}
}{
"staged_changes": [],
"total": 0
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/staged-changes/discard嘗試將指定的未解決核准寫入標記為已捨棄。
被暫緩的寫入應直接作廢,而不是核准並套用時使用。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/staged-changes/discard - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/staged-changes/discard - 公司
/private/module/custom_tables/company/tables/{table_id}/staged-changes/discard
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 擁有階段性變更的資料表 UUID。 |
請求結構
StagedChangeDiscardRequest| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
staged_change_ids | string[] | 是 | Staged change ids to discard (1..50); each is looked up anchored to the path table_id |
回應結構
StagedChangeDiscardResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
discarded | integer | 是 | How many ids were discarded this call |
results | StagedChangeDiscardResult[] | 是 | One result per requested id, in request order |
範例
捨棄一個階段性變更 ID
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"staged_change_ids": [
"88888888-8888-4888-8888-888888888888"
]
}
}{
"results": [
{
"staged_change_id": "88888888-8888-4888-8888-888888888888",
"ok": false,
"outcome": "not_found",
"status": null
}
],
"discarded": 0
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/callback-tokens建立綁定資料表的 token,供已驗證的公開回呼寫入,並只回傳一次密鑰。
要為外部回呼程式配置新增,或新增與更新能力時使用。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/callback-tokens - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/callback-tokens - 公司
/private/module/custom_tables/company/tables/{table_id}/callback-tokens
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要綁定回呼 token 的資料表 UUID。 |
請求結構
CallbackTokenMintPayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
allowed_ops | "create" | "create,update" | 否 | Operations the token may perform |
name | string | null | 否 | Label shown in listings |
valid_until | string (date-time) | null | 否 | Expiry (UTC); null = no expiry. Expired tokens answer the uniform 404. |
回應結構
CallbackTokenMintResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
allowed_ops | string | 是 | 未指定 |
secret | string | 是 | Bearer secret — shown ONCE, never retrievable again |
table_id | string | 是 | 未指定 |
token_id | string | 是 | The URL path segment: POST /public/module/custom_tables/callback/{token_id} |
valid_until | string (date-time) | null | 是 | 未指定 |
範例
簽發可新增與更新的回呼 token
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
},
"body": {
"name": "訂單系統回呼",
"allowed_ops": "create,update",
"valid_until": null
}
}{
"token_id": "99999999-9999-4999-8999-999999999999",
"secret": "cbsec_catalog_example_only_0000000000000000",
"table_id": "22222222-2222-4222-8222-222222222222",
"allowed_ops": "create,update",
"valid_until": null
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
| 422 | token 名稱、允許的操作集合或到期時間不合法。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/callback-tokens回傳資料表回呼 token 的基本資訊、能力、到期時間與撤銷狀態。
適合稽核整合,或在撤銷前找到 token ID。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/callback-tokens - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/callback-tokens - 公司
/private/module/custom_tables/company/tables/{table_id}/callback-tokens
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 要列出回呼 token 的資料表 UUID。 |
回應結構
CallbackTokenListResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
tokens | CallbackTokenInfo[] | 是 | 未指定 |
範例
列出回呼 token 基本資訊
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}{
"tokens": [
{
"id": "99999999-9999-4999-8999-999999999999",
"name": "訂單系統回呼",
"table_id": "22222222-2222-4222-8222-222222222222",
"allowed_ops": "create,update",
"valid_until": null,
"revoked": false,
"created_by": "44444444-4444-4444-8444-444444444444",
"created_at": "2026-07-19T03:00:00"
}
]
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 資料表不存在,或不屬於指定範圍。 | |
/private/module/custom_tables/{scope}/tables/{table_id}/callback-tokens/{token_id}永久停用一組資料表專屬憑證,使後續 public callback 寫入回傳與無效驗證相同的隱蔽 404。
輪替憑證、停用整合,或懷疑憑證外洩時使用。
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/tables/{table_id}/callback-tokens/{token_id} - 部門
/private/module/custom_tables/department/{department_id}/tables/{table_id}/callback-tokens/{token_id} - 公司
/private/module/custom_tables/company/tables/{table_id}/callback-tokens/{token_id}
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | CustomTableModeratorRequired |
| 部門 | 可使用 | CustomTableModeratorRequired |
| 公司 | 可使用 | CustomTableModeratorRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
table_id | path | uuid | 是 | 擁有回呼 token 的資料表 UUID。 |
token_id | path | uuid | 是 | 要撤銷的回呼 token UUID。 |
回應結構
SuccessResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
message | string | 否 | 未指定 |
範例
撤銷一組回呼 token
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"table_id": "22222222-2222-4222-8222-222222222222",
"token_id": "99999999-9999-4999-8999-999999999999"
}
}{
"message": "Callback token revoked"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 這張資料表沒有該 token,或指定範圍無法看到它。 | |
| 409 | 撤銷在鎖競爭中落敗,「沒有」發生——token 仍然存活、仍接受 callback 寫入。重試直到拿到 200;只有 200 才確認撤銷完成。 | |