Agentic Memory REST API Reference

更新时间:
复制 MD 格式

Provides long-term, short-term, and contextual memory storage and retrieval for Agentic AI agents and intelligent search services. Supports storage, query, update, and deletion of three data types: personalized Memory, reusable Skill, and Knowledge Base. Uses hybrid retrieval combining BM25 and vector search with multi-way recall for efficient and accurate results.

Service name

Service ID

Description

API QPS limit (including primary account and RAM users)

Agentic Memory

agentic-memory

Provides storage and management for three data types: Memory (V4), Skill (V3), and Knowledge Base (V3). Memory stores long-term preferences such as user personal preferences. Skill stores reusable execution logic and skills. Knowledge Base stores knowledge assets in document form.

10

To increase the QPS limit, submit a ticket to technical support.

API versioning

Memory API URI prefix is /v4/openapi/workspaces/{workspace_name}/.

Skill and Knowledge Base API URI prefix is /v3/openapi/workspaces/{workspace_name}/.

Health check API is under the Service status category, using V3 prefix /v3/openapi/workspaces/{workspace_name}/.

Prerequisites

  • Obtain authentication credentials

    When calling AI Search Platform services through APIs, caller identity authentication is required. For information about how to obtain authentication credentials, see Authentication.

  • Obtain the service endpoint

    You can call the service through public network or VPC. For more information, see Obtain a service endpoint.

Common request

Common URI

Memory API (V4):

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}

Skill / Knowledge Base / Health check API (V3):

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}

Parameter description:

  • host: The service endpoint. You can call the API through public network or VPC. For more information, see Obtain a service endpoint.

  • workspace_name: The workspace name, for example, default.

  • service_id: The service ID. The fixed value is agentic-memory.

Header parameters

API-KEY authentication

Parameter

Type

Required

Description

Example

Content-Type

String

Yes

Request type: application/json

application/json

Authorization

String

Yes

API-Key

Bearer OS-d1**2a

Memory API (V4)

All Memory operations in this section use the URI prefix /v4/openapi/workspaces/{workspace_name}/memory/{service_id}. The Memory async event ID prefix is me-.

Store memory

Intelligently extracts user preference information from message content and stores it as Memory. The storage process is asynchronous. The API returns an event ID (event_id), and you can use the Check event status API to obtain the processing result. The system automatically searches existing memories for deduplication and determines whether to create or update.

Request method

POST

URL

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}/memories/add

Body parameters

Parameter

Type

Required

Description

Example

messages

String/Object/Array

Yes

Message content. Three formats are supported: String (plain text), Object (single message), and Array (multi-turn conversation).

  • String: "I like coffee"

  • Object:

    {
      "role": "user",
      "content": "I like coffee"
    }
  • Array (multi-turn conversation):

    [
      {"role": "user", "content": "I like coffee, please recommend some"},
      {"role": "assistant", "content": "Here are some Americano recommendations..."}
    ]

user_id

String

Yes

The user ID.

user_123

agent_id

String

No

The Agent ID. Used only as a filter dimension.

agent_001

run_id

String

No

The Run ID. Used only as a filter dimension.

run_001

metadata

Object

No

Custom key-value pairs stored with the Memory. Can be used to tag sources, categories, and other business fields.

{"source": "example"}

infer

Boolean

No

Specifies whether to perform semantic extraction on the message to generate Memory. Default is true, which means the system intelligently extracts key information. Set to false to store the original text as-is.

true

Response parameters

Parameter

Type

Description

Example

event_id

String

The async event ID with prefix me-. You can use the Check event status API to obtain the processing result.

me-06bde8b5-d123-43cf-9898-64d08fbfaafc

status

String

The initial event status. Fixed value: PENDING.

PENDING

message

String

The prompt message.

Memory creation accepted; poll the event endpoint for status.

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v4/openapi/workspaces/default/memory/agentic-memory/memories/add' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "messages": [
    {"role": "user", "content": "I like coffee, please recommend some"},
    {"role": "assistant", "content": "Here are some Americano recommendations..."}
  ],
  "user_id": "user_123",
  "metadata": {"source": "example"}
}'

Response example

{
  "message": "Memory creation accepted; poll the event endpoint for status.",
  "status": "PENDING",
  "event_id": "me-06bde8b5-d123-43cf-9898-64d08fbfaafc"
}

Check event status

Queries the async event processing status and the list of generated Memories for a Store memory operation.

Request method

GET

URL

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}/events/{event_id}

Path parameters

Parameter

Type

Required

Description

Example

event_id

String

Yes

The event ID returned when storing Memory. The prefix is me-.

me-06bde8b5-d123-43cf-9898-64d08fbfaafc

Response parameters

Parameter

Type

Description

Example

id

String

The event ID.

me-06bde8b5-d123-43cf-9898-64d08fbfaafc

status

String

The event status. Valid values: PENDING (pending), SUCCEEDED (completed), and FAILED (failed).

SUCCEEDED

results

Array

The list of Memory IDs generated after processing is complete.

["m-8d0417d7-9368-4777-9016-b7ee6daeb70b"]

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v4/openapi/workspaces/default/memory/agentic-memory/events/me-06bde8b5-d123-43cf-9898-64d08fbfaafc' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "id": "me-06bde8b5-d123-43cf-9898-64d08fbfaafc",
  "status": "SUCCEEDED",
  "results": [
    "m-8d0417d7-9368-4777-9016-b7ee6daeb70b",
    "m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04"
  ]
}

Get memory

Retrieves a single Memory by Memory ID.

Request method

GET

URL

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}/memories/{memory_id}

Path parameters

Parameter

Type

Required

Description

Example

memory_id

String

Yes

The Memory ID with prefix m-.

m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04

Response parameters

The response contains the id, memory, user_id, metadata, created_at, and updated_at fields. The field definitions are the same as those of a single record in the Search memory response.

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v4/openapi/workspaces/default/memory/agentic-memory/memories/m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "id": "m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04",
  "memory": "The assistant recommended Americano to the user",
  "user_id": "user_123",
  "agent_id": "agent_001",
  "run_id": "run_001",
  "metadata": {"source": "example"},
  "created_at": "2026-06-02T08:39:21.482047Z",
  "updated_at": "2026-06-02T08:39:21.482047Z"
}

Update memory

Updates existing memory content or appends metadata by Memory ID.

Request method

PUT

URL

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}/memories/{memory_id}

Body parameters

Parameter

Type

Required

Description

Example

text

String

Yes

The updated memory content.

The assistant recommended latte to the user

metadata

Object

No

Custom key-value pairs to append to or overwrite business fields.

{"category": "updated"}

cURL request example

curl --location --request PUT 'http://****-hangzhou.opensearch.aliyuncs.com/v4/openapi/workspaces/default/memory/agentic-memory/memories/m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "text": "The assistant recommended latte to the user",
  "metadata": {"category": "updated"}
}'

Response example

{
  "id": "m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04",
  "text": "The assistant recommended latte to the user",
  "user_id": "user_123",
  "agent_id": "agent_001",
  "run_id": "run_001",
  "metadata": {"source": "example", "category": "updated"},
  "created_at": "2026-06-02T08:39:21.482047Z",
  "updated_at": "2026-06-02T08:40:18.428159Z"
}

Delete memory

Deletes a Memory by Memory ID. The message field in the response indicates the deletion result.

Request method

DELETE

URL

{host}/v4/openapi/workspaces/{workspace_name}/memory/{service_id}/memories/{memory_id}

cURL request example

curl --location --request DELETE 'http://****-hangzhou.opensearch.aliyuncs.com/v4/openapi/workspaces/default/memory/agentic-memory/memories/m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "message": "Memory m-877edf7b-cb5a-4f43-bc6b-f8fa022a3a04 deleted successfully"
}

Skill API (V3)

All Skill operations in this section use the URI prefix /v3/openapi/workspaces/{workspace_name}/memory/{service_id}. The Skill async task ID prefix is st-.

Extract and store skill

Intelligently extracts reusable skills (Skill) from multi-turn conversations and stores them. Processing is asynchronous. The API returns a task ID, and you can use the Check skill task status API to obtain the result.

Request method

POST

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/add

Body parameters

Parameter

Type

Required

Description

Example

messages

Array

Yes

The multi-turn conversation message list. Only the Array format is supported.

[{"role":"user","content":"..."},{"role":"assistant","content":"..."}]

user_id

String

Yes

The user ID.

user_123

agent_id

String

No

The Agent ID.

agent_001

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/add' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "messages": [
    {"role": "user", "content": "Unify login failure message across platforms"},
    {"role": "assistant", "content": "Standardize the login failure message to "Login failed, please try again" across Android, iOS, and Web"}
  ],
  "user_id": "user_123"
}'

Response example

{
  "request_id": "3bb081b08c7e4fc8516d26f647f0b2bc",
  "latency": 1659,
  "status": "OK",
  "result": {
    "task_id": "st-73a7c2f1-5600-435e-a4a2-7a9dff6186cf"
  }
}

Upload skill (ZIP import)

Batch uploads Skills through a ZIP package. Returns the number of successfully imported Skills and a metadata list.

Request method

POST

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/import

Body parameters

Parameter

Type

Required

Description

Example

zip_base64

String

Yes

The Base64-encoded content of the ZIP file.

<base64>

user_id

String

Yes

The user ID.

user_123

agent_id

String

No

The Agent ID.

agent_001

Response parameters

Parameter

Type

Description

Example

result.imported_count

Int

The number of successfully imported Skills.

1

result.data

Array

The list of imported Skills. Each Skill contains the following fields.

-

result.data[].id

String

The Skill ID with prefix s-. Can be used as the skill_id parameter for the Get skill, Update skill, and Delete skill APIs.

s-8f9ac898-820b-4ac5-b981-88c7a7f0edae

result.data[].name

String

The Skill name. Obtained from the name field in the SKILL.md file within the ZIP package.

Upload test skill

result.data[].description

String

The Skill description. Obtained from the description field in SKILL.md.

Verify the response field structure of the Upload Skill API via doctest

result.data[].version

String

The Skill version. Obtained from the version field in SKILL.md.

0.2.0

result.data[].owner

String

The Skill owner. Obtained from the user_id in the request body.

user_123

result.data[].tags

Array of String

The Skill tag list. Obtained from the tags field in SKILL.md.

["test", "doc"]

result.data[].triggers

Array of String

The Skill trigger keyword list. Obtained from the triggers field in SKILL.md.

["test upload", "verify upload"]

result.data[].resource_paths

Array of String

The list of relative paths for resource files in the ZIP package other than SKILL.md (such as _meta.json, scripts/, and references/). SKILL.md is parsed as the entry point and is not included in this list.

["_meta.json", "scripts/echo.py", "references/notes.md"]

result.data[].updated_at

String

The time when the Skill was stored or updated, in ISO 8601 format (with timezone offset).

2026-06-02T09:17:57+00:00

cURL request example

curl -X POST --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/import' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "zip_base64": "<base64-encoded ZIP file content>",
  "user_id": "user_123"
}'

Response example

{
  "request_id": "18d236243f851d13c6fd456743fbec8a",
  "latency": 246,
  "status": "OK",
  "result": {
    "imported_count": 1,
    "data": [
      {
        "id": "s-8f9ac898-820b-4ac5-b981-88c7a7f0edae",
        "name": "Upload test skill",
        "description": "Verify the response field structure of the Upload Skill API via doctest",
        "version": "0.2.0",
        "owner": "user_123",
        "tags": ["test", "doc"],
        "triggers": ["test upload", "verify upload"],
        "resource_paths": ["_meta.json", "scripts/echo.py", "references/notes.md"],
        "updated_at": "2026-06-02T09:17:57+00:00"
      }
    ]
  }
}

Check skill task status

Queries the async task processing status and the list of generated Skill IDs for an Extract and store skill operation.

Request method

GET

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/tasks/{task_id}

Response parameters

The response contains result.task_id, result.status (pending/running/completed/failed), result.skill_ids (the list of generated Skill IDs), and result.error_message.

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/tasks/st-73a7c2f1-5600-435e-a4a2-7a9dff6186cf' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "request_id": "2c941feb3468ff5d6ef229204734cddb",
  "latency": 3,
  "status": "OK",
  "result": {
    "task_id": "st-73a7c2f1-5600-435e-a4a2-7a9dff6186cf",
    "status": "completed",
    "skill_ids": ["s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166"]
  }
}

Get skill

Retrieves a single Skill by Skill ID, including file content such as SKILL.md. The response contains result.skill_id, result.name, result.version, result.files, user_id, and result.agent_id.

Request method

GET

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/{skill_id}

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "request_id": "6d46c81b462f5ec93b94281d5be1ca3a",
  "latency": 89,
  "status": "OK",
  "result": {
    "skill_id": "s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166",
    "name": "Test skill",
    "version": "0.1.0",
    "files": {
      "SKILL.md": "---\nid: \"s-c0e6aaf9-...\"\nname: \"Test skill\"\nversion: \"0.1.0\"\n---\n# Test skill"
    },
    "user_id": "user_123",
    "agent_id": ""
  }
}

Update skill

Updates the information of a specified Skill. You can update one or more fields individually. The user_id is required in the body. Other fields (name, version, files, agent_id, description, tags) are provided as needed. The response structure is the same as that of Get skill.

Request method

PUT

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/{skill_id}

cURL request example

curl -X PUT --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "version": "1.0",
  "user_id": "user_123"
}'

Response example

{
  "request_id": "224c2313-7b70-47f7-8748-8f583d7b9ae1",
  "latency": 284,
  "status": "OK",
  "result": {
    "name": "Unify login failure message across platforms",
    "version": "1.0",
    "files": {
      "SKILL.md": "---\nid: \"s-c0e6aaf9-...\"\nname: \"Unify login failure message across platforms\"\n..."
    }
  }
}

Delete skill

Deletes a Skill by Skill ID. The response contains result.skill_id, status, and message.

Request method

DELETE

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/skills/{skill_id}

cURL request example

curl --location --request DELETE 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/skills/s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "request_id": "477bdd93f61dfb229452febd6f7d1725",
  "latency": 181,
  "status": "OK",
  "result": {
    "skill_id": "s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166",
    "status": "success",
    "message": "Skill s-c0e6aaf9-8dea-4729-a958-f11b9a2e3166 deleted"
  }
}

Knowledge Base API (V3)

All Knowledge Base operations in this section use the URI prefix /v3/openapi/workspaces/{workspace_name}/memory/{service_id}. You must first Create a knowledge base in the console to obtain the kb_id.

Upload KB document

Uploads a document to the knowledge base. Two source types are supported: LOCAL (local file URL) and OSS.

Request method

POST

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/knowledge-bases/{kb_id}/docs

Body parameters

Parameter

Type

Required

Description

Example

type

String

Yes

The document source type. Valid values:

  • LOCAL: Local file URL

  • OSS: OSS object.

LOCAL

doc.id

String

No

The custom ID for the local document (optional when type=LOCAL).

doc-001

doc.title

String

No

The document title (optional when type=LOCAL).

User manual

doc.file_url

String

Conditional

The accessible URL for the local document. Required when type=LOCAL.

https://example.com/manual.pdf

doc.oss_path

String

Conditional

The OSS object path. Required when type=OSS.

docs/manual.pdf

doc.oss_bucket

String

Conditional

The OSS bucket name. Required when type=OSS.

my-bucket

doc.oss_endpoint

String

Conditional

The OSS endpoint. Required when type=OSS.

oss-cn-hangzhou.aliyuncs.com

Response parameters

The response contains id (the document ID generated after successful upload) and result.error_message (not empty on failure).

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/knowledge-bases/kb-001/docs' \
--header 'Authorization: Bearer your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
  "type": "LOCAL",
  "doc": {
    "id": "doc-001",
    "title": "User manual",
    "file_url": "https://example.com/manual.pdf"
  }
}'

List KB documents

Retrieves the document list in a knowledge base with pagination. The optional query parameters are page_number (default 1) and page_size (default 10, maximum 100). The response result.results[] contains id, title, timestamp, and status (PROCESSING / SUCCESS / FAIL). result.total indicates the total count.

Request method

GET

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/knowledge-bases/{kb_id}/docs

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/knowledge-bases/kb-001/docs?page_number=1&page_size=10' \
--header 'Authorization: Bearer your-API-KEY'

Get KB document details

Retrieves knowledge base document details by document ID. The response result contains the id, title, content, status, and timestamp fields.

Request method

GET

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/knowledge-bases/{kb_id}/docs/{doc_id}

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/knowledge-bases/kb-001/docs/doc-001' \
--header 'Authorization: Bearer your-API-KEY'

Delete KB document

Deletes a knowledge base document by document ID. The response result contains id (the deleted document ID) and error_message (not empty on failure).

Request method

DELETE

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/knowledge-bases/{kb_id}/docs/{doc_id}

cURL request example

curl --location --request DELETE 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/knowledge-bases/kb-001/docs/doc-001' \
--header 'Authorization: Bearer your-API-KEY'

Service status

Health check

Checks the health status of the Memory service. This API is under the Service status category and uses the V3 prefix (no health endpoint exists under the V4 path).

Request method

GET

URL

{host}/v3/openapi/workspaces/{workspace_name}/memory/{service_id}/health

Response parameters

Parameter

Type

Description

Example

result.status

String

The service health status. Valid values: healthy and unhealthy.

healthy

cURL request example

curl --location 'http://****-hangzhou.opensearch.aliyuncs.com/v3/openapi/workspaces/default/memory/agentic-memory/health' \
--header 'Authorization: Bearer your-API-KEY'

Response example

{
  "request_id": "287d9462-3c9a-2706-780e-b49aa3702e01",
  "latency": 6,
  "status": "OK",
  "result": {
    "status": "healthy"
  }
}

Common response parameters

The following fields are included in the outer layer of all API responses.

Parameter

Type

Description

Example

request_id

String

The unique identifier assigned by the system to an API call.

9907b179-7bcc-2c43-21db-d3c9d777bbfe

latency

Int

The request latency in milliseconds.

161

status

String

The request status.

OK

Status codes

HTTP status code

Error code

Description

200

-

The request is successful. For async tasks, the actual processing status must be determined from status (V3 lowercase: completed/running/pending/failed; V4 uppercase: SUCCEEDED/PENDING/FAILED).

400

InvalidParameter

The request parameters are invalid.

400

CredentialsNotFound

The authentication credentials are invalid (Invalid token). Check whether the API-Key in the Authorization request header is correct.

200

InternalServerError / NotFound

The resource does not exist (Memory / Skill / Task / Knowledge Base, etc.). The server wraps business-level NotFound errors in HTTP 200 with a code field. Check the code and message fields in the response body for specific errors instead of relying solely on the HTTP status code.

429

RateLimitExceeded

The request rate exceeds the limit.

500

InternalServerError

An internal server error occurred.

Error response example

{
  "request_id": "590A7EB8-AA84-****-AF31-8C35DC965972",
  "latency": 0,
  "code": "InvalidParameter",
  "http_code": 400,
  "message": "user_id is required"
}