Knowledge review

Updated at:

This topic describes RDS ContextDB knowledge review APIs for review records, manual decisions, rewrite templates, and review policies.

Common information

Endpoint

https://context-database.aliyuncs.com

Authentication

All Data API operations are authenticated by a workspace-level API key. Use one of the following methods:

Method

Header format

X-API-Key

X-API-Key: <YOUR_API_KEY>

Token

Authorization: Token <YOUR_API_KEY>

Bearer

Authorization: Bearer <YOUR_API_KEY>

Response envelope

All operations return a unified envelope, with business data in data.

Name

Type

Description

Example

errorCode

integer

The error code. 0 indicates success.

0

errorMessage

string

The error message, or null on success.

null

requestId

string

The request trace ID.

req-xxx

data

object/array/null

The business data, defined in each operation's response parameters.

See the operation examples.

Common error behavior

HTTP status code

errorCode

Trigger

400

1001

Missing or invalid parameters, missing resources, invalid operation states, or insufficient permissions (errorMessage starts with forbidden: ).

401

4001

No API key provided.

500

1000

Internal server error.

Note

Knowledge review permission failures do not return HTTP 403. They return HTTP 400 with errorCode=1001 and an errorMessage such as forbidden: kb_write, knowledge base permission denied: kb-001.

Data API overview

The following table lists the operations covered in this topic.

API

Description

ListReviews

Lists ingestion review records with pagination and decision/review_status filters.

GetReviewDetail

Retrieves review details, including quality scores, contradictions, conflicts, and rewritten content, in a unified envelope.

ReviewAction

Performs a manual review action and returns a unified envelope.

DeleteReview

Deletes one review record whose stored status is reviewed or rejected.

ResolveConflicts

Records decisions for individual conflicts in a unified envelope.

BatchReviewAction

Runs confirm or reject for up to 50 reviews.

BatchDeleteReviews

Permanently deletes up to 50 reviews with stored status reviewed or rejected.

ListKnowledgeReviewTemplates

Lists all active review rewrite templates in a knowledge base, sorted by name ascending.

CreateKnowledgeReviewTemplate

Creates a review rewrite template.

GetKnowledgeReviewTemplate

Retrieves template details.

UpdateKnowledgeReviewTemplate

Updates a template by template_id.

DeleteKnowledgeReviewTemplate

Soft-deletes the template: sets status=deleted, clears content, and renames it to avoid uniqueness conflicts.

SetDefaultKnowledgeReviewTemplate

Sets the KB's default rewrite template and clears other defaults in the same transaction.

ClearDefaultKnowledgeReviewTemplate

Clears all template is_default flags in the KB, restoring no-template runtime behavior.

GetReviewSettings

Retrieves workspace review settings in a unified envelope.

UpdateReviewSettings

Partially updates workspace review settings in a unified envelope.

Knowledge Review API

ListReviews

Description

Lists ingestion review records with pagination and decision/review_status filters. Query parameters sort_by and sort_order control sorting. Only confidence_score is supported; sort_order accepts asc/desc and defaults to desc when sort_by is specified. Null scores always sort last. Ties use created_at descending, then review ID ascending. Invalid values or sort_order without sort_by return HTTP 400. Without sort_by, records sort by created_at descending.

Request syntax

GET /v1/knowledge/reviews

Request parameters

Name

Type

Required

Description

Example

decision

string

No

The filter by decision type. Valid values: auto_accept, pending_review, and reject

pending_review

review_status

string

No

The filter by status. Valid values: pending, reviewed, and rejected

pending

page

integer

No

The page number. Default value: 1

1

page_size

integer

No

The number of entries per page. Default value: 20. Maximum value: 100

20

sort_by

string

No

The sort field. Currently only confidence_score is supported.

confidence_score

sort_order

string

No

Sort direction: asc or desc. Valid only with sort_by. Default: desc.

desc

Response parameters (in the data field)

Name

Type

Description

Example

reviews

array

The list of review records. For the fields of each element, see the following table

See the example

total

integer

The total number of entries

42

page

integer

The effective page number after clamping.

1

page_size

integer

The effective page size after clamping.

20

Elements of the reviews array:

Name

Type

Description

Example

review_id

string

The review record ID

rev-001

document_id

string

The document ID

doc-001

document_name

string

The document name. If absent in the review record, retrieved from the document record; null if the document was deleted.

troubleshooting-guide.md

knowledge_base_id

string

The knowledge base ID

kb-001

confidence_score

float

The overall confidence score, or null if unscored.

0.85

decision

string

The system decision. Valid values: auto_accept, pending_review, and reject

pending_review

review_status

string

The derived review status: pending, reviewed, or rejected. See the following rules.

pending

has_conflicts

boolean

Indicates whether knowledge conflicts exist

false

has_contradictions

boolean

Whether unresolvable internal contradictions exist.

false

rewrite_needed

boolean

Indicates whether a rewrite is required

true

human_action

string

The manual action type. If no action has been taken, the value is null

null

created_at

string

The creation time

2026-06-01T10:00:00Z

Deriving review_status

review_status is derived for each response rather than stored as a database column. Rules apply in this order:

Priority

Condition

Derived result

1

human_action is nonempty: a manual action has occurred.

Use the stored status: reviewed or rejected.

2

decision = auto_accept

reviewed

3

Other cases, including decision = pending_review.

pending

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "reviews": [
      {
        "review_id": "rev-001",
        "document_id": "doc-001",
        "document_name": "troubleshooting-guide.md",
        "knowledge_base_id": "kb-001",
        "confidence_score": 0.85,
        "decision": "pending_review",
        "review_status": "pending",
        "has_conflicts": false,
        "has_contradictions": false,
        "rewrite_needed": true,
        "human_action": null,
        "created_at": "2026-06-01T10:00:00Z"
      }
    ],
    "total": 42,
    "page": 1,
    "page_size": 20
  }
}

GetReviewDetail

Description

Retrieves review details, including quality scores, contradictions, conflicts, and rewritten content, in a unified envelope. Original content is paginated into 3,000-character pages selected by content_page.

Request syntax

GET /v1/knowledge/reviews/detail

Request parameters

Name

Type

Required

Description

Example

review_id

string

Yes

The review record ID

rev-001

content_page

integer

No

The original-content page number. Default: 1. Each page contains 3,000 characters.

1

Validation and out-of-range behavior

Parameter

Invalid or out-of-range input

Behavior

review_id

Missing

Returns 400 for a missing required parameter.

review_id

Does not exist in the current workspace.

Returns 400 with errorMessage set to review not found: xxx.

content_page

< 1

Silently clamped to 1 without an error.

content_page

Exceeds the actual page count.

No error. original_content.text is empty, and page echoes the supplied value.

Response parameters (in the data field)

Name

Type

Description

Example

review_id

string

The review record ID

rev-001

document_id

string

The document ID

doc-001

document_name

string

The document name, retrieved from the document record if absent in the review record.

troubleshooting-guide.md

knowledge_base_id

string

The knowledge base ID

kb-001

member_id

string

The member ID that triggered ingestion.

member-001

logic_score

float

The logical coherence score; higher is better. Null if unscored.

0.82

noise_score

float

The noise ratio score; lower is better.

0.12

contradiction_score

float

The internal contradiction score; lower is better.

0.05

confidence_score

float

The overall confidence

0.85

source_type

string

The source type: upload, memory_promotion, process, or platform.

upload

decision

string

The system decision. Valid values: auto_accept, pending_review, and reject

pending_review

decision_reason

string

The explanation of the decision.

Overall confidence 0.55 is below the automatic ingestion threshold 0.60

review_status

string

The derived review status: pending, reviewed, or rejected.

pending

has_contradictions

boolean

Whether unresolvable internal contradictions exist.

false

contradictions

string

Contradiction details as a JSON string, not an object. See the structure below.

[{"snippet1":"...","snippet2":"..."}]

conflicts

string

Conflicts with the knowledge base as a JSON string. See the structure below.

[{"id":"c1","conflict_type":"fact"}]

quality_details

string

Quality details as a JSON string, such as {"logic_issues":[...],"noise_segments":[...]}.

{"logic_issues":[...]}

original_content

object

The paginated original content. See the subfields below. Null if the original content is empty.

See the following table

original_logic_score

float

The logical coherence score before rewriting.

0.61

original_noise_score

float

The noise score before rewriting.

0.30

original_contradiction_score

float

The contradiction score before rewriting.

0.10

original_contradictions

string

Contradiction details before rewriting, as a JSON string.

Empty array

rewrite_needed

boolean

Indicates whether a rewrite is required

true

rewrite_reason

string

The reason rewriting was triggered.

Confidence 0.55 is below the automatic ingestion threshold 0.6; noise is the weakest dimension, so denoising takes priority

rewrite_strategy

string

The rewrite strategy. See the values below.

denoise

rewritten_content

string

The full AI-rewritten content, without pagination.

Rewritten document content...

rewrite_info_check

string

The rewrite information-preservation check as a JSON string, such as {"missing_facts":[...],"preserved_facts_count":12}.

{"missing_facts":[...]}

human_action

string

The manual action type, or null before an action.

null

human_edited_content

string

The manually edited content, or null if not edited.

null

human_conflict_resolutions

string

Manual conflict resolutions as a JSON string.

[{"conflict_id":"c1","resolution":"use_new"}]

human_action_by

string

The member ID that performed the manual action.

member-001

human_action_at

string

The manual action time.

2026-06-01T11:00:00Z

loop_iterations

integer

The number of completed review/rewrite iterations.

1

max_iterations

integer

The maximum iteration count.

3

created_at

string

The creation time

2026-06-01T10:00:00Z

updated_at

string

The update time

2026-06-01T10:05:00Z

original_content object:

Name

Type

Description

Example

text

string

The current page's original text, with 3,000 characters per page. Empty when the page is out of range.

# Troubleshooting guide...

page

integer

The current page number, echoing content_page after clamping.

1

total_pages

integer

The page count, calculated as ceil(total characters / 3000).

4

total_chars

integer

The original content's total character count.

10240

rewrite_strategy values:

Value

Description

denoise

Denoising, selected when noise is the weakest dimension.

restructure

Restructuring, selected when logical coherence is the weakest dimension.

fix_contradiction

Contradiction repair, selected for resolvable internal contradictions.

hybrid

Hybrid strategy; defined as a code constant.

remove_hallucination

Hallucination removal; defined as a code constant.

conflicts elements, after parsing the JSON string:

Name

Type

Description

id

string

The conflict ID used as conflict_id in ResolveConflicts or ReviewAction.

kb_document_id

string

The knowledge base document ID containing the conflicting fact.

kb_document_name

string

The knowledge base document name containing the conflicting fact.

kb_fact

string

The existing fact in the knowledge base.

new_fact

string

The new fact in the content being ingested.

conflict_type

string

The conflict type.

severity_score

float

The conflict severity score.

ai_recommendation

string

The AI-recommended resolution.

human_resolution

string

The manual resolution.

contradictions elements, after parsing the JSON string:

Name

Type

Description

snippet1

string

The first contradictory excerpt.

snippet2

string

The second contradictory excerpt.

type

string

The contradiction type.

resolvable

boolean

Whether automatic resolution is possible. Unresolvable items set has_contradictions=true and force pending_review.

confidence

float

The confidence in the contradiction assessment.

Note

contradictions, conflicts, quality_details, original_contradictions, rewrite_info_check, and human_conflict_resolutions are JSON strings in the envelope. Parse them separately on the client. The table describes their decoded structure; actual fields follow the JSON saved during ingestion.

ReviewAction

Description

Performs a manual review action and returns a unified envelope. A record can be actioned only once: calls after human_action is written return HTTP 400. The workspace must be active.

Request syntax

POST /v1/knowledge/reviews/action

Request parameters

Name

Type

Required

Description

Example

review_id

string

Yes

The review record ID

rev-001

action

string

Yes

The action type. Valid values: confirm, force_accept, accept_rewrite, reject, and reject_reupload

accept_rewrite

edited_content

string

No

The manually edited content. It is used only for accept_rewrite

Modified document content...

conflict_resolutions

array

No

The list of conflict resolutions

[{"conflict_id":"c1","resolution":"use_new"}]

Elements of the conflict_resolutions array:

Name

Type

Required

Description

Example

conflict_id

string

Yes

The conflict ID from id in conflicts.

c1

resolution

string

Yes

The resolution. Valid values: use_new, keep_old, merge, and annotate_divergence

use_new

Note

conflict_resolutions is serialized only into the human_conflict_resolutions audit field. The server does not validate whether conflict_id belongs to this review's conflicts or whether resolution is a defined value.

Action behavior

action

Meaning

Document processing

Stored review status

confirm

Confirm and ingest the original content.

Dispatches KNOWLEDGE_REVIEW_APPROVE with chunk and graph extraction enabled; sets the document review_status to reviewed.

reviewed

force_accept

Force ingestion of the original content despite contradictions.

Same as confirm.

reviewed

accept_rewrite

Accept the rewritten content.

Reingests edited_content, defaulting to rewritten_content; sets document review_status to reviewed.

reviewed

reject

Reject ingestion.

Sets the document to deleting, dispatches KNOWLEDGE_DOC_DELETE to clean up ES chunks, OSS objects, and snapshots, and sets review_status to rejected.

rejected

reject_reupload

Reject and request reupload.

The same cleanup process as reject.

rejected

Validation and error behavior

Condition

HTTP

errorMessage

review_id is missing or blank.

400

review_id is required

action is missing or blank.

400

action is required

action is not one of the five valid values.

400

invalid action: xxx

The workspace does not exist.

400

workspace not found: xxx

The workspace is not active, such as during downtime.

400

workspace is not active: xxx

review_id does not exist in the current workspace.

400

review not found: xxx

The review already has a manual action.

400

Review already actioned: xxx

action=accept_rewrite and both edited_content and rewritten_content are empty.

400

edited_content or rewritten_content is required for accept_rewrite

Response parameters (in the data field)

Returns the updated review details with the same fields as GetReviewDetail. original_content always contains page 1:

Name

Type

Description

Example

review_id

string

The review record ID

rev-001

document_id

string

The document ID

doc-001

document_name

string

The document name

troubleshooting-guide.md

knowledge_base_id

string

The knowledge base ID

kb-001

member_id

string

The member ID that triggered ingestion.

member-001

logic_score

float

The logical coherence score.

0.82

noise_score

float

The noise ratio score.

0.12

contradiction_score

float

The internal contradiction score.

0.05

confidence_score

float

The overall confidence

0.85

source_type

string

The source type

upload

decision

string

The system decision.

pending_review

decision_reason

string

The explanation of the decision.

Overall confidence 0.55 is below the automatic ingestion threshold 0.60

review_status

string

The resulting review status: reviewed or rejected.

reviewed

has_contradictions

boolean

Whether unresolvable internal contradictions exist.

false

contradictions

string

Contradiction details as a JSON string.

Empty array

conflicts

string

Conflict details as a JSON string.

Empty array

quality_details

string

Quality details as a JSON string.

{"logic_issues":[...]}

original_content

object

Page 1 of the original content, with the same subfields as GetReviewDetail.

See GetReviewDetail.

original_logic_score

float

The logical coherence score before rewriting.

0.61

original_noise_score

float

The noise score before rewriting.

0.30

original_contradiction_score

float

The contradiction score before rewriting.

0.10

original_contradictions

string

Contradiction details before rewriting, as a JSON string.

Empty array

rewrite_needed

boolean

Indicates whether a rewrite is required

true

rewrite_reason

string

The reason rewriting was triggered.

Noise is the weakest dimension; prioritize denoising

rewrite_strategy

string

The rewrite strategy

denoise

rewritten_content

string

The full AI-rewritten content.

Rewritten document content...

rewrite_info_check

string

The rewrite information-preservation check as a JSON string.

{"missing_facts":[...]}

human_action

string

The manual action type saved by this call.

accept_rewrite

human_edited_content

string

The manually edited content saved by this call.

Modified document content...

human_conflict_resolutions

string

The conflict resolutions saved by this call, as a JSON string.

[{"conflict_id":"c1","resolution":"use_new"}]

human_action_by

string

The acting member ID, supplied by the server.

member-001

human_action_at

string

The manual action time.

2026-06-01T11:00:00Z

loop_iterations

integer

The number of completed review/rewrite iterations.

1

max_iterations

integer

The maximum iteration count.

3

created_at

string

The creation time

2026-06-01T10:00:00Z

updated_at

string

The update time

2026-06-01T11:00:00Z

Examples

Request body:

{
  "review_id": "rev-001",
  "action": "accept_rewrite",
  "edited_content": "Modified document content..."
}

DeleteReview

Description

Deletes one review record whose stored status is reviewed or rejected. Deletion is permanent and cannot be undone. Only the review record is removed; ingested documents are unaffected.

Request syntax

DELETE /v1/knowledge/reviews

Request parameters

Name

Type

Required

Description

Example

review_id

string

Yes

The review record ID

rev-001

Deletion eligibility

Eligibility uses the stored status, not the derived response field review_status:

Stored status

When assigned

Deletable

reviewed

After confirm, force_accept, or accept_rewrite.

Yes

rejected

After reject or reject_reupload.

Yes

active

The initial value for records without a manual action, including pending_review and auto_accept records.

No; returns HTTP 400.

Note

For decision=auto_accept, the derived review_status is reviewed, but stored status remains active. Such records cannot be deleted and return only reviewed or rejected review can be deleted, current status: active. This is the current behavior.

Error behavior

Condition

HTTP

errorMessage

review_id is missing.

400

Missing required parameter.

review_id is blank.

400

review_id is required

The record does not exist in the current workspace.

400

review not found: xxx

The stored status is neither reviewed nor rejected.

400

only reviewed or rejected review can be deleted, current status: xxx

Response parameters (in the data field)

Name

Type

Description

Example

review_id

string

The deleted review record ID.

rev-001

deleted

boolean

Whether deletion succeeded. Fixed to true.

true

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "review_id": "rev-001",
    "deleted": true
  }
}

ResolveConflicts

Description

Records decisions for individual conflicts in a unified envelope. Only audit fields are written: human_conflict_resolutions, human_action_by, and human_action_at. It does not write human_action, change stored status, or trigger ingestion or deletion. review_status remains pending; call ReviewAction to apply the review decision.

Request syntax

POST /v1/knowledge/reviews/resolve-conflicts

Request parameters

Name

Type

Required

Description

Example

review_id

string

Yes

The review record ID

rev-001

resolutions

array

Yes

A nonempty conflict resolution list. See the element fields below.

[{"conflict_id":"c1","resolution":"use_new"}]

resolutions elements:

Name

Type

Required

Description

Example

conflict_id

string

Yes

The conflict ID from id in conflicts.

c1

resolution

string

Yes

The resolution. Valid values: use_new, keep_old, merge, and annotate_divergence

use_new

Note

As with ReviewAction, the server serializes and stores the entire list. It does not validate whether conflict_id belongs to the review or whether resolution is defined. Repeated calls replace the previous list.

Error behavior

Condition

HTTP

errorMessage

review_id is missing or blank.

400

review_id is required

resolutions is missing or empty.

400

resolutions is required

The record does not exist in the current workspace.

400

review not found: xxx

Response parameters (in the data field)

Returns the updated review details with the same fields as GetReviewDetail. original_content always contains page 1:

Name

Type

Description

Example

review_id

string

The review record ID

rev-001

document_id

string

The document ID

doc-001

document_name

string

The document name

troubleshooting-guide.md

knowledge_base_id

string

The knowledge base ID

kb-001

member_id

string

The member ID that triggered ingestion.

member-001

logic_score

float

The logical coherence score.

0.82

noise_score

float

The noise ratio score.

0.12

contradiction_score

float

The internal contradiction score.

0.05

confidence_score

float

The overall confidence

0.85

source_type

string

The source type

upload

decision

string

The system decision.

pending_review

decision_reason

string

The explanation of the decision.

Facts conflict with the knowledge base

review_status

string

The review status, unchanged by this operation and usually still pending.

pending

has_contradictions

boolean

Whether unresolvable internal contradictions exist.

false

contradictions

string

Contradiction details as a JSON string.

Empty array

conflicts

string

Conflict details as a JSON string.

[{"id":"c1"}]

quality_details

string

Quality details as a JSON string.

{"logic_issues":[...]}

original_content

object

Page 1 of the original content.

See GetReviewDetail.

original_logic_score

float

The logical coherence score before rewriting.

0.61

original_noise_score

float

The noise score before rewriting.

0.30

original_contradiction_score

float

The contradiction score before rewriting.

0.10

original_contradictions

string

Contradiction details before rewriting, as a JSON string.

Empty array

rewrite_needed

boolean

Indicates whether a rewrite is required

false

rewrite_reason

string

The reason rewriting was triggered.

null

rewrite_strategy

string

The rewrite strategy

null

rewritten_content

string

The full AI-rewritten content.

null

rewrite_info_check

string

The rewrite information-preservation check as a JSON string.

null

human_action

string

The manual action type. Not written by this operation and remains null.

null

human_edited_content

string

The manually edited content

null

human_conflict_resolutions

string

The conflict resolutions saved by this call, as a JSON string.

[{"conflict_id":"c1","resolution":"use_new"}]

human_action_by

string

The acting member ID, supplied by the server.

member-001

human_action_at

string

The time of this operation.

2026-06-01T11:00:00Z

loop_iterations

integer

The number of completed review/rewrite iterations.

1

max_iterations

integer

The maximum iteration count.

3

created_at

string

The creation time

2026-06-01T10:00:00Z

updated_at

string

The update time

2026-06-01T11:00:00Z

Examples

Request body:

{
  "review_id": "rev-001",
  "resolutions": [
    {
      "conflict_id": "c1",
      "resolution": "use_new"
    }
  ]
}

BatchReviewAction

Description

Runs confirm or reject for up to 50 reviews. Items execute sequentially using single-item action logic. Individual failures do not stop the batch; each failed item includes an error in results.

Request syntax

POST /v1/knowledge/reviews/batch

Request parameters

Name

Type

Required

Description

Example

action

string

Yes

The batch action: confirm or reject.

confirm

ids

array

Yes

A nonempty list of up to 50 review IDs.

["rev-001"]

Validation and out-of-range behavior

Condition

HTTP

errorMessage

action is missing or blank.

400

action is required

action is neither confirm nor reject.

400

batch action only supports confirm or reject, got: xxx

ids is missing or empty.

400

ids is required and must not be empty

ids contains more than 50 entries.

400; not truncated.

ids must not exceed 50 items

ids contains blank entries.

400

ids must not contain blank values

The workspace is not active.

400

workspace is not active: xxx

Note

ids values are trimmed and processed in input order. Duplicates are not removed; the second occurrence fails because the review was already actioned.

Response parameters (in the data field)

Name

Type

Description

Example

total

integer

The submitted item count.

2

succeeded

integer

The number of successful records

1

failed

integer

The number of failed records

1

results

array

The per-item results. See the fields below.

See the example

Elements of the results array:

Name

Type

Description

Example

id

string

The review ID, echoing the original untrimmed input.

rev-001

success

boolean

Whether this item succeeded.

true

error

string

The failure reason. Omitted from JSON on success.

review not found: rev-002

Examples

Request body:

{
  "action": "confirm",
  "ids": [
    "rev-001",
    "rev-002"
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "total": 2,
    "succeeded": 1,
    "failed": 1,
    "results": [
      {
        "id": "rev-001",
        "success": true
      },
      {
        "id": "rev-002",
        "success": false,
        "error": "review not found: rev-002"
      }
    ]
  }
}

BatchDeleteReviews

Description

Permanently deletes up to 50 reviews with stored status reviewed or rejected. Items are prevalidated, then eligible records are deleted in a batch. Individual failures do not stop the batch.

Request syntax

DELETE /v1/knowledge/reviews/batch

Request parameters

Name

Type

Required

Description

Example

ids

array

Yes

A nonempty list of up to 50 review IDs.

["rev-001"]

Validation and out-of-range behavior

Condition

HTTP

errorMessage

ids is missing or empty.

400

ids is required and must not be empty

ids contains more than 50 entries.

400; not truncated.

ids must not exceed 50 items

ids contains blank entries.

400

ids must not contain blank values

Per-item failures

Condition

Item error

The record does not exist in the current workspace.

review not found

The stored status is neither reviewed nor rejected.

review is not deletable, current status: xxx

Response parameters (in the data field)

Name

Type

Description

Example

total

integer

The submitted item count.

2

succeeded

integer

The number of successful records

1

failed

integer

The number of failed records

1

results

array

The per-item results. See the fields below.

See the example

Elements of the results array:

Name

Type

Description

Example

id

string

The review record ID

rev-001

success

boolean

Whether this item succeeded.

true

error

string

The failure reason. Omitted from JSON on success.

review is not deletable, current status: active

Examples

Request body:

{
  "ids": [
    "rev-001",
    "rev-002"
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "total": 2,
    "succeeded": 1,
    "failed": 1,
    "results": [
      {
        "id": "rev-001",
        "success": true
      },
      {
        "id": "rev-002",
        "success": false,
        "error": "review is not deletable, current status: active"
      }
    ]
  }
}

KnowledgeReviewTemplates

Knowledge review rewrite templates belong to individual knowledge bases and control rewrite prompts. Reads require KB_READ; writes require KB_WRITE. Each knowledge base supports up to five active templates.

Isolation and limits:

Item

Value

Basis

Isolation scope

Knowledge base (KB)

The unique key is uk_kb_name (knowledge_base_id, name); service queries are scoped by knowledgeBaseId.

Active templates per KB

5

Application validation returns HTTP 400 if exceeded.

Maximum template name length

128 characters

Measured after trimming.

Section count range

1-15

Empty arrays and more than 15 sections return HTTP 400.

Heading level range

1 to 3, corresponding to #, ##, and ###.

Out-of-range values return HTTP 400.

Maximum rendered Markdown length

65,536 characters

Exceeding the limit returns HTTP 400.

Insufficient permissions

HTTP 400, with errorMessage starting with forbidden: .

Not 403.

Template object:

Name

Type

Description

Example

id

string

The template ID

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The template name

Customer service review template

is_default

boolean

Whether this is the KB's default template.

true

sections

array

The structured section array. See the fields below.

See the example

content

string

The Markdown template rendered by the server.

# Issue summary...

created_by

string

The creator's member ID.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:00:00Z

Elements of the sections array:

Name

Type

Description

Example

level

integer

The heading level, 1 to 3. Defaults to 1 if omitted.

1

title

string

The required, nonempty, single-line section title.

Issue summary

guidance

string

Required, nonempty writing guidance. Multiple lines are allowed.

Summarize the core issues in the original content that require rewriting

ListKnowledgeReviewTemplates

Description

Lists all active review rewrite templates in a knowledge base, sorted by name ascending. Requires KB_READ permission.

Request syntax

GET /v1/knowledge/review_templates?knowledge_base_id={knowledge_base_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID as a query parameter.

kb-001

Response parameters (in the data field)

Name

Type

Description

Example

data

array

Template objects sorted by name ascending. Empty if no active templates exist. See the fields below.

See the example

data elements (template objects):

Name

Type

Description

Example

id

string

The template ID

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The template name

Customer service review template

is_default

boolean

Whether this is the KB's default template.

true

sections

array

The structured section array, using the sections element fields above.

See the example

content

string

The Markdown template rendered by the server.

# Issue summary...

created_by

string

The creator's member ID.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:00:00Z

Error behavior

Condition

HTTP

errorMessage

knowledge_base_id is missing.

400

Missing required parameter.

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_READ permission.

400

forbidden: kb_read, knowledge base permission denied: xxx

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": [
    {
      "id": "tpl-001",
      "knowledge_base_id": "kb-001",
      "name": "Customer service review template",
      "is_default": true,
      "sections": [
        {
          "level": 1,
          "title": "Issue summary",
          "guidance": "Summarize the core issues in the original content that require rewriting"
        }
      ],
      "content": "# Issue summary\nSummarize the core issues in the original content that require rewriting",
      "created_by": "member-001",
      "created_at": "2026-06-01T10:00:00Z",
      "updated_at": "2026-06-01T10:00:00Z"
    }
  ]
}

CreateKnowledgeReviewTemplate

Description

Creates a review rewrite template. name is required, unique within the KB, and at most 128 characters. sections requires 1 to 15 entries. Each title must be nonempty and single-line; guidance must be nonempty and may span lines, but not blank lines. level defaults to 1 and must be 1 to 3. Each KB allows five active templates. Limit, duplicate-name, or section-validation failures return HTTP 400. is_default=true clears other KB defaults. Requires KB_WRITE.

Request syntax

POST /v1/knowledge/review_templates?knowledge_base_id={knowledge_base_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID as a query parameter.

kb-001

name

string

Yes

The template name, unique within the KB and at most 128 characters.

Customer service review template

is_default

boolean

No

Whether to make this the KB default. Default: false. True clears other default templates in the KB.

true

sections

array

Yes

The ordered section list, with 1 to 15 entries.

See the following table

Elements of the sections array:

Name

Type

Required

Description

Example

level

integer

No

The heading level, 1 to 3. Default: 1.

1

title

string

Yes

The section title, nonempty after trimming and single-line.

Issue summary

guidance

string

Yes

Writing guidance, nonempty after trimming. Multiple lines are allowed, but blank lines are prohibited.

Summarize the core issues in the original content that require rewriting

Validation rules and errors

Condition

HTTP

errorMessage

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_WRITE permission.

400

forbidden: kb_write, knowledge base permission denied: xxx

sections is missing or empty.

400

sections must not be empty

sections contains more than 15 entries.

400

sections must not contain more than 15 entries

sections[i] is null.

400

sections[i] must not be null

name is missing or blank.

400

name must not be blank

Trimmed name exceeds 128 characters.

400

name must not exceed 128 characters

The KB already has five active templates.

400

knowledge base template limit (5) reached

An active template with this name exists in the KB.

400

template name already exists in this knowledge base

sections[i].title is missing or blank.

400

sections[i].title must not be blank

sections[i].title contains a line break.

400

sections[i].title must not contain line breaks

sections[i].guidance is missing or blank.

400

sections[i].guidance must not be blank

sections[i].guidance contains a blank line.

400

sections[i].guidance must not contain blank lines

sections[i].level is outside 1 to 3.

400

sections[i].level must be between 1 and 3

Rendered Markdown exceeds 65,536 characters.

400

rendered template content must not exceed 65536 characters

Rendering and parsing do not round-trip consistently.

400

sections[i] cannot be represented as template Markdown

Note

Each line of title and guidance is trimmed before normalization and storage. Responses contain the normalized values.

Response parameters (in the data field)

Name

Type

Description

Example

id

string

The new template ID.

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The trimmed template name.

Customer service review template

is_default

boolean

Whether this is the KB's default template.

true

sections

array

The structured section array, using the sections element fields above.

See the example

content

string

The Markdown template rendered by the server.

# Issue summary...

created_by

string

The creator's member ID, supplied by the server.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:00:00Z

Examples

Request body:

{
  "name": "Customer service review template",
  "is_default": true,
  "sections": [
    {
      "level": 1,
      "title": "Issue summary",
      "guidance": "Summarize the core issues in the original content that require rewriting"
    },
    {
      "level": 2,
      "title": "Suggested rewrite",
      "guidance": "Produce rewritten content ready for ingestion"
    }
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "id": "tpl-001",
    "knowledge_base_id": "kb-001",
    "name": "Customer service review template",
    "is_default": true,
    "sections": [
      {
        "level": 1,
        "title": "Issue summary",
        "guidance": "Summarize the core issues in the original content that require rewriting"
      },
      {
        "level": 2,
        "title": "Suggested rewrite",
        "guidance": "Produce rewritten content ready for ingestion"
      }
    ],
    "content": "# Issue summary\nSummarize the core issues in the original content that require rewriting\n\n## Suggested rewrite\nProduce rewritten content ready for ingestion",
    "created_by": "member-001",
    "created_at": "2026-06-01T10:00:00Z",
    "updated_at": "2026-06-01T10:00:00Z"
  }
}

GetKnowledgeReviewTemplate

Description

Retrieves template details. Returns HTTP 200 with data=null if absent. Requires KB_READ permission.

Request syntax

GET /v1/knowledge/review_templates/detail?knowledge_base_id={knowledge_base_id}&template_id={template_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID

kb-001

template_id

string

Yes

The template ID

tpl-001

Response parameters (in the data field)

If the template is missing, belongs to another KB, or is soft-deleted, data is null, HTTP remains 200, and errorCode remains 0. Otherwise, returns:

Name

Type

Description

Example

id

string

The template ID

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The template name

Customer service review template

is_default

boolean

Whether this is the KB's default template.

true

sections

array

The structured section array, using the sections element fields above.

See the example

content

string

The Markdown template rendered by the server.

# Issue summary...

created_by

string

The creator's member ID.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:00:00Z

Error behavior

Condition

HTTP

errorMessage

knowledge_base_id or template_id is missing.

400

Missing required parameter.

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_READ permission.

400

forbidden: kb_read, knowledge base permission denied: xxx

The template does not exist.

200

data is null; no error.

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "id": "tpl-001",
    "knowledge_base_id": "kb-001",
    "name": "Customer service review template",
    "is_default": true,
    "sections": [
      {
        "level": 1,
        "title": "Issue summary",
        "guidance": "Summarize the core issues in the original content that require rewriting"
      }
    ],
    "content": "# Issue summary\nSummarize the core issues in the original content that require rewriting",
    "created_by": "member-001",
    "created_at": "2026-06-01T10:00:00Z",
    "updated_at": "2026-06-01T10:00:00Z"
  }
}

Template not found:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": null
}

UpdateKnowledgeReviewTemplate

Description

Updates a template by template_id. All three body fields are optional and support partial updates. Omitted or blank name preserves the name; renaming must remain unique in the KB. A nonempty sections array replaces all sections and rebuilds content; omission or an empty array preserves them. is_default=true clears other defaults and selects this template; false clears its default flag; omission preserves it. The body must not be null. Missing templates return HTTP 400. Requires KB_WRITE.

Request syntax

PUT /v1/knowledge/review_templates?knowledge_base_id={knowledge_base_id}&template_id={template_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID as a query parameter.

kb-001

template_id

string

Yes

The template ID as a query parameter.

tpl-001

name

string

No

The template name, unique within the KB and at most 128 characters. Omission or blank input preserves the current name.

Customer service review template v2

is_default

boolean

No

True selects this default and clears other KB defaults; false clears this template's flag; omission preserves it.

true

sections

array

No

An ordered list of 1 to 15 sections. A nonempty array replaces sections and rebuilds content; omission or an empty array preserves them.

See the following table

Elements of the sections array:

Name

Type

Required

Description

Example

level

integer

No

The heading level, 1 to 3. Default: 1.

1

title

string

Yes

The section title, nonempty after trimming and single-line.

Issue summary

guidance

string

Yes

Writing guidance, nonempty after trimming. Multiple lines are allowed, but blank lines are prohibited.

Summarize the core issues in the original content that require rewriting

Validation rules and errors

Condition

HTTP

errorMessage

The request body is missing.

400

request body is required

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_WRITE permission.

400

forbidden: kb_write, knowledge base permission denied: xxx

The template is missing, belongs to another KB, or is soft-deleted.

400

review template not found in this knowledge base

Trimmed name exceeds 128 characters.

400

name must not exceed 128 characters

The new name duplicates another active template in the KB.

400

template name already exists in this knowledge base

sections fails count, title, guidance, level, or round-trip validation.

400

The corresponding error from CreateKnowledgeReviewTemplate.

Response parameters (in the data field)

Name

Type

Description

Example

id

string

The template ID

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The updated template name.

Customer service review template v2

is_default

boolean

The updated default flag.

true

sections

array

The updated structured sections, using the fields above.

See the example

content

string

The rebuilt Markdown template.

# Issue summary...

created_by

string

The creator's member ID, unchanged by updates.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:10:00Z

Examples

Request body:

{
  "name": "Customer service review template v2",
  "sections": [
    {
      "level": 1,
      "title": "Issue summary",
      "guidance": "Summarize the issue"
    }
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "id": "tpl-001",
    "knowledge_base_id": "kb-001",
    "name": "Customer service review template v2",
    "is_default": true,
    "sections": [
      {
        "level": 1,
        "title": "Issue summary",
        "guidance": "Summarize the issue"
      }
    ],
    "content": "# Issue summary\nSummarize the issue",
    "created_by": "member-001",
    "created_at": "2026-06-01T10:00:00Z",
    "updated_at": "2026-06-01T10:10:00Z"
  }
}

DeleteKnowledgeReviewTemplate

Description

Soft-deletes the template: sets status=deleted, clears content, and renames it to avoid uniqueness conflicts. Repeated deletion is idempotent. Requires KB_WRITE.

Request syntax

DELETE /v1/knowledge/review_templates?knowledge_base_id={knowledge_base_id}&template_id={template_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID

kb-001

template_id

string

Yes

The template ID

tpl-001

Deletion behavior

Item

Behavior

Deletion method

Soft deletion: sets status to deleted, empties content and parsed_json, and retains the record.

Tombstone name

Rewrites name as original name + "__del_" + first 8 characters of template ID. If longer than 128 characters, retains the tail to avoid uk_kb_name conflicts. The original name can be reused immediately.

Idempotency

For missing or soft-deleted templates, returns {"deleted": true} without an error.

Default flag

Soft deletion does not explicitly clear is_default. Invalid templates cause runtime injection to fall back to no-template behavior.

Difference from review record deletion

Review records (DeleteReview and BatchDeleteReviews) are permanently deleted; templates are soft-deleted.

Error behavior

Condition

HTTP

errorMessage

knowledge_base_id or template_id is missing.

400

Missing required parameter.

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_WRITE permission.

400

forbidden: kb_write, knowledge base permission denied: xxx

Response parameters (in the data field)

Name

Type

Description

Example

deleted

boolean

Whether deletion succeeded. Fixed to true.

true

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "deleted": true
  }
}

SetDefaultKnowledgeReviewTemplate

Description

Sets the KB's default rewrite template and clears other defaults in the same transaction. Requires KB_WRITE.

Request syntax

POST /v1/knowledge/review_templates/set_default?knowledge_base_id={knowledge_base_id}&template_id={template_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID

kb-001

template_id

string

Yes

The template ID

tpl-001

Error behavior

Condition

HTTP

errorMessage

knowledge_base_id or template_id is missing.

400

Missing required parameter.

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_WRITE permission.

400

forbidden: kb_write, knowledge base permission denied: xxx

The template is missing, belongs to another KB, or is soft-deleted.

400

review template not found in this knowledge base

Response parameters (in the data field)

Name

Type

Description

Example

id

string

The template ID

tpl-001

knowledge_base_id

string

The knowledge base ID

kb-001

name

string

The template name

Customer service review template

is_default

boolean

Fixed to true after this operation.

true

sections

array

The structured section array, using the sections element fields above.

See the example

content

string

The Markdown template rendered by the server.

# Issue summary...

created_by

string

The creator's member ID.

member-001

created_at

string

The creation time in UTC with a Z suffix.

2026-06-01T10:00:00Z

updated_at

string

The update time in UTC with a Z suffix.

2026-06-01T10:00:00Z

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "id": "tpl-001",
    "knowledge_base_id": "kb-001",
    "name": "Customer service review template",
    "is_default": true,
    "sections": [
      {
        "level": 1,
        "title": "Issue summary",
        "guidance": "Summarize the core issues in the original content that require rewriting"
      }
    ],
    "content": "# Issue summary\nSummarize the core issues in the original content that require rewriting",
    "created_by": "member-001",
    "created_at": "2026-06-01T10:00:00Z",
    "updated_at": "2026-06-01T10:00:00Z"
  }
}

ClearDefaultKnowledgeReviewTemplate

Description

Clears all template is_default flags in the KB, restoring no-template runtime behavior. Succeeds idempotently if there is no default. Requires KB_WRITE.

Request syntax

DELETE /v1/knowledge/review_templates/default?knowledge_base_id={knowledge_base_id}

Request parameters

Name

Type

Required

Description

Example

knowledge_base_id

string

Yes

The knowledge base ID

kb-001

Error behavior

Condition

HTTP

errorMessage

knowledge_base_id is missing.

400

Missing required parameter.

The KB does not exist or belongs to another workspace.

400

knowledge base not found: xxx

No KB_WRITE permission.

400

forbidden: kb_write, knowledge base permission denied: xxx

Response parameters (in the data field)

Name

Type

Description

Example

cleared

boolean

Whether default flags were cleared. Fixed to true.

true

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "cleared": true
  }
}

ReviewSettings

Review settings have one workspace-scoped record keyed by knowledge_review_settings.workspace_id. The API key supplies the workspace. Neither reading nor writing requires an administrator role.

GetReviewSettings

Description

Retrieves workspace review settings in a unified envelope. If unconfigured, returns defaults without creating a stored record; created_at and updated_at are null.

Request syntax

GET /v1/knowledge/reviewSettings

Request parameters

None.

Response parameters (in the data field)

Name

Type

Description

Example

workspace_id

string

The workspace ID

ws-001

high_threshold

float

The automatic acceptance threshold. A document whose confidence is higher than this score is automatically ingested. If the confidence is lower than this score and rewriting is enabled, a document rewrite is triggered

0.8

rewrite_enabled

boolean

Specifies whether document rewriting is enabled

true

conflict_detection_enabled

boolean

Specifies whether conflict detection is enabled

true

rewrite_auto_ingest_enabled

boolean

Specifies whether rewritten documents are automatically ingested

false

logic_rewrite_threshold

float

The logic-based rewrite trigger threshold. Deprecated: a rewrite is now triggered when the confidence is lower than high_threshold, and this field no longer participates in triggering

0.5

noise_rewrite_threshold

float

The noise-based rewrite trigger threshold. Deprecated: same as above

0.3

max_rewrite_iterations

integer

The maximum number of rewrite iterations

3

created_at

string

The creation time, or null if never configured.

2026-06-01T00:00:00Z

updated_at

string

The update time, or null if never configured.

2026-06-01T10:00:00Z

Defaults for unconfigured workspaces

Field

Default

Source

high_threshold

0.6

System default

rewrite_enabled

true

Assigned when the service constructs default settings.

conflict_detection_enabled

true

Assigned when the service constructs default settings.

rewrite_auto_ingest_enabled

true

The entity field default.

logic_rewrite_threshold

0.4

System default

noise_rewrite_threshold

0.4

System default

max_rewrite_iterations

3

System default

Decision and rewrite rules

Rule

Behavior

confidence >= high_threshold

Sets auto_accept and ingests directly.

confidence < high_threshold

Sets pending_review for manual review. If rewriting is enabled, selects restructure for weak logic or denoise for high noise.

Unresolvable internal contradictions exist.

Forces pending_review, regardless of confidence.

High-severity hallucinations exist.

Forces pending_review, regardless of confidence.

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": {
    "workspace_id": "ws-001",
    "high_threshold": 0.8,
    "rewrite_enabled": true,
    "conflict_detection_enabled": true,
    "rewrite_auto_ingest_enabled": false,
    "logic_rewrite_threshold": 0.5,
    "noise_rewrite_threshold": 0.3,
    "max_rewrite_iterations": 3,
    "created_at": "2026-06-01T00:00:00Z",
    "updated_at": "2026-06-01T10:00:00Z"
  }
}

UpdateReviewSettings

Description

Partially updates workspace review settings in a unified envelope. Only supplied fields change. If no settings record exists, the first call creates one and assigns defaults to omitted fields.

Request syntax

PUT /v1/knowledge/reviewSettings

Request parameters

Name

Type

Required

Description

Example

high_threshold

float

No

The automatic acceptance threshold, which also serves as the trigger line for document rewriting: a rewrite is triggered when the confidence is lower than this value and rewriting is enabled

0.85

rewrite_enabled

boolean

No

Specifies whether document rewriting is enabled

true

conflict_detection_enabled

boolean

No

Specifies whether conflict detection is enabled

true

rewrite_auto_ingest_enabled

boolean

No

Specifies whether rewritten documents are automatically ingested

true

logic_rewrite_threshold

float

No

The logic-based rewrite trigger threshold. Deprecated: it no longer participates in triggering

0.5

noise_rewrite_threshold

float

No

The noise-based rewrite trigger threshold. Deprecated: it no longer participates in triggering

0.3

max_rewrite_iterations

integer

No

The maximum number of rewrite iterations

5

Response parameters

data is always null. The envelope's errorCode: 0 indicates success. Call GetReviewSettings again to retrieve the complete updated configuration.

Examples

Request body:

{
  "high_threshold": 0.85,
  "rewrite_auto_ingest_enabled": true
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-xxx",
  "data": null
}