Memory promotion

Updated at:

This topic describes RDS ContextDB memory promotion APIs for candidate generation, manual review, automatic ingestion settings, and templates.

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>

Unified 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 ID to provide when troubleshooting.

req-abc123

data

object/array

Business data as defined in each operation's response parameters; null on failure.

See the individual operation.

Error codes

errorCode

HTTP status code

Meaning

0

200

Success

1001

400

Invalid parameters, missing records, inoperable states, or missing target knowledge bases.

1000

500

Internal service error.

Note

Missing promotion records return HTTP 400 with errorCode 1001. Missing-template behavior varies: detail queries return HTTP 200 with null data, deletion succeeds idempotently, and generation falls back to a default template. Updating or selecting a default template returns HTTP 400.

Common conventions

Convention

Description

Member identity

The server supplies workspace_id and member_id from API key authentication. Callers cannot provide them; they are excluded from request parameter tables.

Data isolation

Records are filtered strictly by workspace_id and initiating member. Members can read or modify only their own promotions.

Batch operation format

Batch actions use POST /v1/**/batch with {"action","ids"}; batch deletion uses DELETE /v1/**/batch with {"ids"}. Each request supports up to 50 items.

Timestamp format

All timestamps use UTC ISO 8601 with a Z suffix, such as 2026-07-01T08:00:00Z.

Data API overview

The following table lists the operations covered in this topic.

API

Description

Generate

Generates a promotion candidate asynchronously.

ListPromotions

Lists the promotion records initiated by the current member by page.

PromotionDetail

Retrieves a promotion's draft, evidence, doubts, and current status.

ApprovePromotion

Approves a candidate for ingestion into the specified KB.

RejectPromotion

Rejects a candidate.

ResolveDoubts

Resolves generation doubts and optionally edits the title or content of the current member's pending_review record.

BatchActionPromotions

Approves or rejects up to 50 candidates independently.

BatchDeletePromotions

Permanently deletes up to 50 of the current member's own rejected candidates.

GetPromotionSettings

Retrieves automatic ingestion settings scoped to (workspace, member).

UpdatePromotionSettings

Partially updates automatic ingestion settings for the current (workspace, member) only.

ListPromotionTemplates

Lists active promotion templates visible to the caller, sorted by name ascending.

CreatePromotionTemplate

Creates a template owned by the current member.

GetPromotionTemplate

Retrieves a visible promotion template.

UpdatePromotionTemplate

Updates a visible promotion template; a missing template returns HTTP 400.

DeletePromotionTemplate

Soft-deletes a visible promotion template and renames it with a tombstone so the original name can be reused.

SetDefaultPromotionTemplate

Sets the specified template as default and clears other visible defaults.

ClearDefaultPromotionTemplate

Clears all visible template default flags.

Memory Promotion API

Aggregates and promotes short-term memories into long-term knowledge base documents.

Generate

Description

Generates a promotion candidate asynchronously. knowledge_base_id is always optional: a supplied missing KB returns HTTP 400. If omitted with automatic ingestion enabled, uses default_kb_id from promotion settings; an unconfigured default causes no error. Without template_id, uses the member's default template, then the built-in template. Returns business data in the unified envelope's data field.

Generation immediately returns promotion_id and event_id with status generating. Completion changes status to pending_review; failure changes it to generation_failed. Two consecutive deterministic-check failures or unresolved source conflicts produce doubts for manual decisions through ResolveDoubts.

Request syntax

POST /v1/memory_promotions/generate

Request parameters

Name

Type

Required

Description

Example

topic

string

Yes

The promotion topic; nonempty after trimming and at most 512 characters. Invalid length returns HTTP 400.

Summary of user dietary preferences

knowledge_base_id

string

No

The target KB ID. If supplied, the KB must exist or HTTP 400 is returned. If omitted with automatic ingestion enabled, falls back to default_kb_id.

kb-001

template_id

string

No

The promotion template ID, resolved for the current workspace and member. Omitted, missing, deleted, or other-member IDs silently fall back to the member's default template, then the built-in template. Only a server warning is logged; no error or hint is returned.

tpl-001

Response parameters (in the data field)

Name

Type

Description

Example

promotion_id

string

The promotion record ID

promo-001

event_id

string

The asynchronous event ID

evt-promo-001

status

string

The current status, fixed to generating.

generating

ListPromotions

Description

Lists the promotion records initiated by the current member by page. The records can be filtered by status. The response uses the unified envelope structure, and business data is in the data field.

Request syntax

GET /v1/memory_promotions

Request parameters

Name

Type

Required

Description

Example

status

string

No

The status filter. See values below. Omission includes all statuses; invalid values return HTTP 400.

pending_review

page

integer

No

The page number. Default: 1. Values below 1 silently become 1 without HTTP 400.

1

page_size

integer

No

Items per page. Default: 20. Silently clamped to [1, 100] without HTTP 400.

20

sort_by

string

No

Sort field: only quality_score is supported; other values return HTTP 400. Omission sorts by created_at descending.

quality_score

sort_order

string

No

Case-insensitive asc/desc. Requires sort_by; using it alone returns HTTP 400. Defaults to desc when sort_by is supplied. Null scores always sort last.

desc

status values:

Value

Description

generating

Generating, including retries. Check attempt_count and last_error for progress.

pending_review

Generated and awaiting manual review.

approving

Approval ingestion in progress.

approved

Approved and ingested, including automatic ingestion.

rejected

Rejected.

generation_failed

Generation failed.

Note

When sorting by quality_score, unscored records always come last. Ties use created_at descending, then ID ascending for stable ordering.

Response parameters (in the data field)

Name

Type

Description

Example

promotions

array

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

See the following table

total

integer

The total number of entries

5

page

integer

The current page number

1

page_size

integer

The number of entries per page

20

Elements of the promotions array: The fields are the same as those of the data field of PromotionDetail. See the response parameters of PromotionDetail below.

PromotionDetail

Description

Retrieves a promotion's draft, evidence, doubts, and current status. Only the current member's own records are accessible; missing or other-member records return HTTP 400. Returns data in a unified envelope.

Request syntax

GET /v1/memory_promotions/detail

Request parameters

Name

Type

Required

Description

Example

promotion_id

string

Yes

The promotion record ID

promo-001

Response parameters (in the data field)

Name

Type

Description

Example

promotion_id

string

The promotion record ID

promo-001

workspace_id

string

The workspace ID

ws-001

source_type

string

The source type. See values below.

manual

requested_by

string

The member ID of the initiator

member-001

topic

string

The promotion topic

Summary of user dietary preferences

title

string

The title of the generated document. Before generation, the value is null

User dietary preferences

content

string

The content of the generated document. Before generation, the value is null

The user prefers Americano coffee...

whats_new

string

The description of new information compared with existing knowledge

Added coffee preference information

source_memory_ids

array

The list of source memory IDs

["mem-001"]

source_member_ids

array

The list of source member IDs

["member-001"]

source_entity_ids

array

The list of source entity IDs

["entity-001"]

excluded_memory_ids

array

The list of excluded memory IDs

Empty array

memory_count

integer

The number of aggregated memories

12

doubts

array

Generation doubts. See the element fields below. Empty if there are no doubts; cleared to null after regeneration.

See the following table

doubt_resolutions

array

Doubt decisions, using ResolveDoubts request doubt_resolutions fields. Cleared to null after regeneration.

See ResolveDoubts.

status

string

The status. Valid values: generating, pending_review, approving, approved, rejected, and generation_failed

pending_review

reviewed_by

string

The reviewer, or null before review. Automatic ingestion does not populate this field.

member-002

reviewed_at

string

The review time. If the record is not reviewed, the value is null

2026-07-01T10:00:00Z

rejection_reason

string

The rejection reason. If the record is not rejected, the value is null

null

target_kb_id

string

The target KB ID, set during generation or default-KB fallback; null if undecided.

kb-001

target_document_id

string

The ingested document ID, or null before ingestion.

doc-001

generate_event_id

string

The generation event ID

evt-promo-001

last_error

string

The latest failure reason, at most 1,024 characters. Null if unavailable.

null

attempt_count

integer

The number of generation attempts

1

created_at

string

The creation time

2026-07-01T08:00:00Z

updated_at

string

The update time

2026-07-01T10:00:00Z

quality_score

float

The deterministically combined quality score in [0,1]. See the quality_score calculation below. Null before generation completes, for check failures converted to doubts, for outputs with no reusable content, and for older records. ResolveDoubts regeneration preserves the existing score rather than rescoring.

0.85

auto_ingested

boolean

Indicates whether the record entered the knowledge base through the automatic ingestion channel, as distinguished from manual approval

false

source_type values:

Value

Description

manual

Manually initiated through Generate.

agent_patrol

Automatically nominated by agent patrol. Legacy auto markers are mapped to this value.

doubts elements generated by the pipeline. options and current_choice are required for manual decisions:

Name

Type

Description

Example

title

string

The doubt title.

Deterministic checks failed

description

string

The detailed doubt description.

The cited material does not support conclusion 2

options

array

Decision options with label and text fields.

[{"label":"A","text":"Retry promotion after manual verification."}]

current_choice

string

The pipeline's default option label.

A

severity

string

Severity, fixed to high for check-generated doubts and present only for those doubts. That path does not score the candidate, leaving quality_score null; severity therefore causes no score deduction in that path.

high

source

string

The doubt source marker, present only for check-generated doubts.

gates

type

string

The doubt type marker, present only for check-generated doubts.

gate_rejection

reason

string

The check rejection reason, present only for check-generated doubts.

claim 3 lacks citations

quality_score calculation: combines relevance, coherence, cleanliness, and penalties. V2 multi-signal scoring is the default; V1 is the fallback.

V2 (default): score = clamp(0.40×relevance + 0.30×coherence + 0.30×cleanliness − 0.3×hasHighDoubt − 0.2×verificationDegraded − 0.2×lowConfidenceRatio)

V1 (fallback): score = clamp(0.9 − 0.3×hasHighDoubt − 0.2×verificationDegraded − 0.2×lowConfidenceRatio)

Component

Default weight

Value and source

relevance

0.40

Topic relevance: 0.7×rel_source + 0.3×rel_content. rel_source is normalized reranker relevance of cited material to the topic; rel_content is the LLM judge's content relevance. With judging disabled, relevance equals rel_source.

coherence

0.30

LLM-judged coherence. Uses 0.5 when judging is disabled or degraded. If inference claims exceed 0.5 of all claims, deducts another 0.1 from this component.

cleanliness

0.30

LLM-judged cleanliness, reflecting low noise. Uses 0.5 when judging is disabled or degraded.

hasHighDoubt

Subtract 0.3

Whether any doubt has severity=high. Currently false at the scoring stage because checks have passed, so this penalty is inactive.

verificationDegraded

Subtract 0.2

Whether final auditing or deduplication degraded, such as budget-exhaustion fallback or skipped recall. Deducts 0.2 when true. The underlying marker is not exposed by PromotionDetail.

lowConfidenceRatio

Subtract 0.2 × ratio

The fraction of LOW-confidence claims. Current agent claims do not carry confidence, so the ratio is 0 and no penalty is applied.

Note

Hard gate: publishable=false from final auditing forces the score to 0, bypassing weighted scoring. Otherwise, scores are clamped to [0,1]; NaN becomes 0.

The table shows default weights. The Data API does not expose scorer versions or individual component scores.

Check failures converted to doubts and explanatory outputs with no reusable content are unscored, leaving quality_score null. These records never trigger automatic ingestion.

ApprovePromotion

Description

Approves a candidate for ingestion into the specified KB. Only the current member's own pending_review record with saved nonempty title/content can be approved. Status changes to approving before ingestion, then approved on success. Business data is returned in data.

Request syntax

POST /v1/memory_promotions/approve

Request parameters

Name

Type

Required

Description

Example

promotion_id

string

Yes

The promotion record ID

promo-001

knowledge_base_id

string

Yes

The target KB ID. A missing KB returns HTTP 400.

kb-001

Response parameters (in the data field)

Name

Type

Description

Example

promotion_id

string

The promotion record ID

promo-001

status

string

The updated status

approved

target_kb_id

string

The destination knowledge base ID

kb-001

target_document_id

string

The ID of the knowledge base document that is written

doc-001

Validation and errors

Scenario

HTTP status code

Error message

promotion_id is missing.

400

promotion_id is required

knowledge_base_id is missing.

400

knowledge_base_id is required

The record is missing or belongs to another member.

400

promotion not found: {id}

Status is not pending_review.

400

promotion is not in reviewable status, current: {status}

title is empty.

400

title must not be empty (save title edits before approval)

content is empty.

400

content must not be empty (save content edits before approval)

RejectPromotion

Description

Rejects a candidate. Only the current member's own pending_review records are eligible. Returns business data in the envelope's data field.

Request syntax

POST /v1/memory_promotions/reject

Request parameters

Name

Type

Required

Description

Example

promotion_id

string

Yes

The promotion record ID

promo-001

reason

string

No

The rejection reason, at most 1,024 characters. Excess length returns HTTP 400; blank trimmed input is stored as null.

Insufficient content quality

Response parameters (in the data field)

Name

Type

Description

Example

promotion_id

string

The promotion record ID

promo-001

status

string

The updated status

rejected

ResolveDoubts

Description

Resolves generation doubts and optionally edits the title or content of the current member's pending_review record. Supply doubt_resolutions or nonempty title/content; omitting both returns HTTP 400. Edits alone preserve pending_review and return event_id=null. Decisions change status to generating and dispatch an event. Regeneration appends decisions as quotations, restores pending_review, and clears doubts and doubt_resolutions.

Request syntax

POST /v1/memory_promotions/resolve_doubts

Request parameters

Name

Type

Required

Description

Example

promotion_id

string

Yes

The promotion record ID

promo-001

doubt_resolutions

array

No

Doubt decisions, with fields below. Supply this list or title/content.

[{"index":0,"choice":"A"}]

title

string

No

The edited title used as the knowledge document name. Maximum: 255 characters; excess returns HTTP 400.

User dietary preferences

content

string

No

The edited content

The user prefers Americano coffee...

doubt_resolutions elements:

Name

Type

Required

Description

Example

index

integer

Yes

The zero-based doubts index from PromotionDetail. Missing or negative values return HTTP 400. No upper-bound validation: indexes beyond the array are silently ignored.

0

choice

string

Yes

An option label from doubts[index].options, or custom for a free-form response. Empty values return HTTP 400. Membership in options is not validated; unmatched values themselves become decision text in the content.

A

comment

string

No

The custom response, used when choice is custom. Maximum: 1,024 characters; excess returns HTTP 400.

Use the latest memory as the source of truth

Response parameters (in the data field)

Name

Type

Description

Example

promotion_id

string

The promotion record ID

promo-001

event_id

string

The regeneration event ID. If only the edits are saved, the value is null

evt-promo-002

status

string

generating when decisions are provided; pending_review for edits only.

generating

Examples

Request body with decisions, triggering regeneration:

{
  "promotion_id": "promo-001",
  "doubt_resolutions": [
    {
      "index": 0,
      "choice": "A"
    },
    {
      "index": 1,
      "choice": "custom",
      "comment": "Use the latest memory as the source of truth"
    }
  ]
}

Request body with manual edits only, without regeneration:

{
  "promotion_id": "promo-001",
  "title": "User dietary preferences",
  "content": "The user prefers Americano coffee..."
}

BatchActionPromotions

Description

Approves or rejects up to 50 candidates independently. Individual failures do not affect other items; their exception messages appear in results[].error while HTTP remains 200. Returns data in a unified envelope.

Request syntax

POST /v1/memory_promotions/batch

Request parameters

Name

Type

Required

Description

Example

action

string

Yes

The case-sensitive batch action: approve or reject. Other values return HTTP 400.

approve

ids

array

Yes

A nonempty list of up to 50 promotion IDs, without blank entries.

["promo-001","promo-002"]

knowledge_base_id

string

Required for approve

The target KB shared by the batch, ignored for reject. If missing for approval, each item fails with knowledge_base_id is required.

kb-001

reason

string

No

The shared rejection reason, optional for reject and at most 1,024 characters.

Insufficient content quality

Response parameters (in the data field)

Name

Type

Description

Example

total

integer

The total number of entries

2

succeeded

integer

The number of successful records

2

failed

integer

The number of failed records

0

results

array

The list of per-record results. For the fields of each element, see the following table

See the following table

Elements of the results array:

Name

Type

Description

Example

id

string

The promotion record ID

promo-001

success

boolean

Indicates whether the record is processed

true

error

string

The failure reason. For successful records, this field is not returned

promotion is not in reviewable status, current: approved

Validation and errors

The following request-level validation failures reject the entire request without per-item results:

Scenario

HTTP status code

Error message

The request body is missing.

400

request body is required

action is missing or blank.

400

action is required

action is neither approve nor reject.

400

batch action only supports approve or reject, got: {action}

ids is missing or empty.

400

ids is required and must not be empty

ids contains more than 50 entries.

400

ids must not exceed 50 items

ids contains blank entries.

400

ids must not contain blank values

Examples

Request body:

{
  "action": "approve",
  "ids": [
    "promo-001",
    "promo-002"
  ],
  "knowledge_base_id": "kb-001"
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": {
    "total": 2,
    "succeeded": 2,
    "failed": 0,
    "results": [
      {
        "id": "promo-001",
        "success": true
      },
      {
        "id": "promo-002",
        "success": true
      }
    ]
  }
}

BatchDeletePromotions

Description

Permanently deletes up to 50 of the current member's own rejected candidates. Deletion cannot be undone. Ineligible items are skipped with reasons in results; eligible records are deleted together in one transaction. Returns data in a unified envelope.

Request syntax

DELETE /v1/memory_promotions/batch

Request parameters

Name

Type

Required

Description

Example

ids

array

Yes

A nonempty list of up to 50 promotion IDs, without blank entries.

["promo-003","promo-004"]

Response parameters (in the data field)

Name

Type

Description

Example

total

integer

The total number of entries

2

succeeded

integer

The successful deletion count.

1

failed

integer

The number of failed records

1

results

array

The list of per-record results. For the fields of each element, see the following table

See the following table

Elements of the results array:

Name

Type

Description

Example

id

string

The promotion record ID

promo-003

success

boolean

Whether deletion succeeded.

true

error

string

The failure reason. For successful records, this field is not returned

promotion is not in rejected status, current: approved

Validation and errors

Scenario

HTTP status or result location

Error message

ids is missing or empty.

400 for the entire request.

ids is required and must not be empty

ids contains more than 50 entries.

400 for the entire request.

ids must not exceed 50 items

ids contains blank entries.

400 for the entire request.

ids must not contain blank values

The record is missing or belongs to another member.

200, results[].error

promotion not found

The record status is not rejected.

200, results[].error

promotion is not in rejected status, current: {status}

Examples

Request body:

{
  "ids": [
    "promo-003",
    "promo-004"
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": {
    "total": 2,
    "succeeded": 1,
    "failed": 1,
    "results": [
      {
        "id": "promo-003",
        "success": true
      },
      {
        "id": "promo-004",
        "success": false,
        "error": "promotion is not in rejected status, current: approved"
      }
    ]
  }
}

GetPromotionSettings

Description

Retrieves automatic ingestion settings scoped to (workspace, member). Each member has independent settings in each workspace; the API key selects the member. Unconfigured members receive defaults without creating a record. Returns data in a unified envelope.

Request syntax

GET /v1/memory_promotions/settings

Request parameters

None.

Response parameters (in the data field)

Name

Type

Description

Example

auto_ingest_enabled

boolean

Specifies whether automatic ingestion for promotion is enabled

true

auto_ingest_threshold

float

The automatic ingestion quality threshold in the inclusive range [0, 1].

0.8

default_kb_id

string

The default destination knowledge base ID. If it is not configured, the value is null

kb-001

Defaults when unconfigured:

Name

Default

Description

auto_ingest_enabled

false

Automatic ingestion is disabled; all candidates await manual review in pending_review.

auto_ingest_threshold

0.8

The minimum score for automatic ingestion. Unscored records with null quality_score never qualify.

default_kb_id

null

No default KB configured.

Validation and errors

Scenario

HTTP status code

Error message

The API key has no bound member identity.

400

memberId is required for settings

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": {
    "auto_ingest_enabled": true,
    "auto_ingest_threshold": 0.8,
    "default_kb_id": "kb-001"
  }
}

UpdatePromotionSettings

Description

Partially updates automatic ingestion settings for the current (workspace, member) only. Omitted fields remain unchanged. The first call creates a settings record if needed. Returns data in a unified envelope.

Request syntax

PUT /v1/memory_promotions/settings

Request parameters

Name

Type

Required

Description

Example

auto_ingest_enabled

boolean

No

Whether automatic promotion ingestion is enabled. Omission preserves the value.

true

auto_ingest_threshold

float

No

The quality threshold in [0, 1]. Out-of-range values return HTTP 400, not clamping. Omission preserves the value.

0.7

default_kb_id

string

No

The default target KB ID. Blank input clears it to null. Required when the effective switch is true; the KB must exist in the current workspace.

kb-001

Response parameters (in the data field)

Returns the complete updated settings:

Name

Type

Description

Example

auto_ingest_enabled

boolean

The updated automatic ingestion switch.

true

auto_ingest_threshold

float

The updated threshold in the inclusive range [0, 1].

0.7

default_kb_id

string

The updated default KB ID, or null after clearing.

kb-001

Validation and errors

Scenario

HTTP status code

Error message

The API key has no bound member identity.

400

memberId is required for settings

auto_ingest_threshold is out of range.

400

auto_ingest_threshold must be within [0, 1]: {value}

The effective switch is true but the default KB is empty.

400

default_kb_id is required when auto_ingest_enabled is true

default_kb_id refers to a missing KB.

400

Reported by knowledge base validation.

Note

Validation uses supplied auto_ingest_enabled, otherwise the stored value; the same applies to default_kb_id. Therefore, changing only the threshold while already enabled does not require resupplying default_kb_id.

Examples

Request body:

{
  "auto_ingest_enabled": true,
  "auto_ingest_threshold": 0.7,
  "default_kb_id": "kb-001"
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": {
    "auto_ingest_enabled": true,
    "auto_ingest_threshold": 0.7,
    "default_kb_id": "kb-001"
  }
}

ListPromotionTemplates

Description

Lists active promotion templates visible to the caller. Templates are scoped to (workspace, member). Returns data in a unified envelope.

Request syntax

GET /v1/memory_promotions/templates

Request parameters

None.

Response parameters (in the data field)

The data field is an array of template objects. For the fields of each element, see the following table:

Name

Type

Description

Example

id

string

The template ID

tpl-001

name

string

The template name

Preference summary template

is_default

boolean

Whether this is the default template for its owning member.

true

sections

array

The ordered section list. See fields below.

See the following table

content

string

The rendered Markdown text

## Overview&#92;n...

updatedAt

string

The update time. The field name uses camelCase, not snake_case.

2026-07-01T08:00:00Z

Elements of the sections array:

Name

Type

Description

Example

level

integer

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

2

title

string

The single-line section title.

Overview

guidance

string

Generation guidance, allowing multiple lines but no blank lines.

Summarize the core preferences of the user

Note

Generation resolves explicit template_id and default templates only within templates owned by the current member.

Examples

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": [
    {
      "id": "tpl-001",
      "name": "Preference summary template",
      "is_default": true,
      "sections": [
        {
          "level": 2,
          "title": "Overview",
          "guidance": "Summarize the core preferences of the user"
        },
        {
          "level": 2,
          "title": "Details",
          "guidance": "List specific preferences and supporting evidence"
        }
      ],
      "content": "## Overview\n...\n## Details\n...",
      "updatedAt": "2026-07-01T08:00:00Z"
    }
  ]
}

CreatePromotionTemplate

Description

Creates a template owned by the current member. name must be unique within that member. Each member can have five active templates; exceeding the limit returns HTTP 400. Structured sections are rendered as Markdown and round-trip validated before storage. Returns a unified envelope.

Request syntax

POST /v1/memory_promotions/templates

Request parameters

Name

Type

Required

Description

Example

name

string

Yes

The trimmed nonempty name, at most 128 characters and unique within the member.

Preference summary template

is_default

boolean

No

Whether to set this template as default. Default: false. true clears other defaults for the current member.

true

sections

array

Yes

The list of sections in document order. Quantity: 1 to 15 items. For the fields of each element, see the following table

See the following table

Elements of the sections array:

Name

Type

Required

Description

Example

level

integer

No

Heading level 1 to 3, corresponding to #, ##, and ###. Default: 1. Invalid values return HTTP 400.

2

title

string

Yes

The nonempty single-line section title. Line breaks return HTTP 400.

Overview

guidance

string

Yes

Nonempty generation guidance. Multiple lines are allowed; blank lines are prohibited.

Summarize the core preferences of the user

Response parameters (in the data field)

The created template with ListPromotionTemplates element fields: id, name, is_default, sections, content, and updatedAt.

Validation and errors

Scenario

HTTP status code

Error message

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

name is missing or blank.

400

name must not be blank

name exceeds 128 characters.

400

name must not exceed 128 characters

The current member already has five active templates.

400

member template limit (5) reached

A template with this name already exists.

400

template name already exists for this member

The section title is empty.

400

sections[i].title must not be blank

The section title contains a line break.

400

sections[i].title must not contain line breaks

Section guidance is empty.

400

sections[i].guidance must not be blank

Section guidance contains a blank line.

400

sections[i].guidance must not contain blank lines

level is out of range.

400

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

The rendered content exceeds the length limit.

400

rendered template content must not exceed 65536 characters

The sections cannot be represented losslessly as template Markdown.

400

sections[i] cannot be represented as template Markdown

Examples

Request body:

{
  "name": "Preference summary template",
  "is_default": true,
  "sections": [
    {
      "level": 2,
      "title": "Overview",
      "guidance": "Summarize the core preferences of the user"
    },
    {
      "level": 2,
      "title": "Details",
      "guidance": "List specific preferences and supporting evidence"
    }
  ]
}

Sample success response:

{
  "errorCode": 0,
  "errorMessage": null,
  "requestId": "req-abc123",
  "data": {
    "id": "tpl-001",
    "name": "Preference summary template",
    "is_default": true,
    "sections": [
      {
        "level": 2,
        "title": "Overview",
        "guidance": "Summarize the core preferences of the user"
      },
      {
        "level": 2,
        "title": "Details",
        "guidance": "List specific preferences and supporting evidence"
      }
    ],
    "content": "## Overview\n...\n## Details\n...",
    "updatedAt": "2026-07-01T08:00:00Z"
  }
}

GetPromotionTemplate

Description

Retrieves a visible promotion template. Missing, deleted, or invisible templates return HTTP 200 with null data, not HTTP 400. Returns a unified envelope.

Request syntax

GET /v1/memory_promotions/templates/{template_id}

Request parameters

Name

Type

Required

Description

Example

template_id

string

Yes

The template ID (path parameter)

tpl-001

Response parameters (in the data field)

The template with ListPromotionTemplates fields: id, name, is_default, sections, content, and updatedAt. null if missing or invisible.

UpdatePromotionTemplate

Description

Updates a visible promotion template; a missing template returns HTTP 400. Supplied name must be unique within the actual owning member. Nonempty sections rebuilds all content; individual-section patches are unsupported. is_default=true claims the default, false clears this flag, and omission preserves it. Returns a unified envelope.

Request syntax

PUT /v1/memory_promotions/templates/{template_id}

Request parameters

Name

Type

Required

Description

Example

template_id

string

Yes

The template ID (path parameter)

tpl-001

name

string

No

The name, at most 128 characters and unique within the owner. Omission or blank input preserves it.

Preference summary template v2

is_default

boolean

No

Default selection: true claims it, false clears this flag, and omission preserves it.

true

sections

array

No

A nonempty array replaces all 1 to 15 sections, using CreatePromotionTemplate fields. Omission or an empty array preserves content.

See CreatePromotionTemplate

Response parameters (in the data field)

The updated template with ListPromotionTemplates fields: id, name, is_default, sections, content, and updatedAt.

Validation and errors

Scenario

HTTP status code

Error message

The request body is missing.

400

request body is required

The template is missing or invisible.

400

template not found

name exceeds 128 characters.

400

name must not exceed 128 characters

The new name duplicates another template owned by the same member.

400

template name already exists for this member

Section validation fails.

400

The section validation error from CreatePromotionTemplate.

DeletePromotionTemplate

Description

Soft-deletes a visible promotion template and renames it with a tombstone so the original name can be reused. Idempotent: missing or deleted templates also return deleted=true without an error. Returns a unified envelope.

Request syntax

DELETE /v1/memory_promotions/templates/{template_id}

Request parameters

Name

Type

Required

Description

Example

template_id

string

Yes

The template ID (path parameter)

tpl-001

Response parameters (in the data field)

Name

Type

Description

Example

deleted

boolean

Fixed to true, including idempotent success for a missing template.

true

SetDefaultPromotionTemplate

Description

Sets the specified template as default and clears other visible defaults. Missing templates return HTTP 400. Generation without template_id prioritizes the current member's default template. Returns a unified envelope.

Request syntax

POST /v1/memory_promotions/templates/{template_id}/set_default

Request parameters

Name

Type

Required

Description

Example

template_id

string

Yes

The template ID (path parameter)

tpl-001

Response parameters (in the data field)

The selected default template with ListPromotionTemplates fields; is_default is true.

Validation and errors

Scenario

HTTP status code

Error message

The template does not exist.

400

template not found

ClearDefaultPromotionTemplate

Description

Clears all visible template default flags. Generation then uses the built-in template. Succeeds idempotently if no default exists. Returns a unified envelope.

Request syntax

DELETE /v1/memory_promotions/templates/default

Request parameters

None.

Response parameters (in the data field)

Name

Type

Description

Example

cleared

boolean

Fixed as true

true