Claude Platform Docs

Create a memory

$client->beta->memoryStores->memories->create(string memoryStoreID, ?string content, string path, ?ManagedAgentsMemoryView view, ?list<AnthropicBeta> betas, ?string workspaceID): ManagedAgentsMemory
POST/v1/memory_stores/{memory_store_id}/memories

Create a memory

Parameters
memoryStoreID: string⁠Path parameter

The ID of the memory store to create the memory in (memstore_...).

content: string

UTF-8 text content for the new memory. Maximum 100 kB (102,400 bytes). Required; pass "" explicitly to create an empty memory.

path: string

Hierarchical path for the new memory, e.g. /projects/foo/notes.md. Must start with /, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, . or .. segments, control or format characters, or the Unicode line and paragraph separators (U+2028, U+2029), and must be NFC-normalized. Paths are case-sensitive.

view?:optional ManagedAgentsMemoryView⁠Query parameter

Selects which projection of a memory or memory_version the server returns. basic returns the object with content set to null; full populates content. When omitted, the default is endpoint-specific: retrieve operations default to full; list, create, and update operations default to basic. Listing with view=full caps limit at 20.

betas?:optional list<AnthropicBeta>⁠Header parameter

Optional header to specify the beta version(s) you want to use.

workspaceID?:optional string⁠Header parameter

Optional header to select the Workspace for this request. The value is a Workspace ID (for example, wrkspc_011CZkZaBF1tNoB5wlCeusgy).

Only needed for credentials that can act on more than one Workspace. A credential that belongs to a specific Workspace may omit it; if sent, it must match that Workspace.

Returns
class ManagedAgentsMemory { $type; $id; $contentSha256; /* 7 more */ }
Type type
string id

Unique identifier for this memory (a mem_... value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

string contentSha256

Lowercase hex SHA-256 digest of the UTF-8 content bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a content_sha256 precondition on update. Always populated, regardless of view.

int contentSizeBytes

Size of content in bytes (the UTF-8 plaintext length). Always populated, regardless of view.

\Datetime createdAt

When this memory was created, in RFC 3339 format.

string memoryStoreID

ID of the memory store this memory belongs to (a memstore_... value).

string memoryVersionID

ID of the memory_version representing this memory's current content (a memver_... value). This is the authoritative head pointer; memory_version objects do not carry an is_latest flag, so compare against this field instead. Enumerate the history via List memory versions.

string path

Hierarchical path of the memory within the store, e.g. /projects/foo/notes.md. Always starts with /. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

\Datetime updatedAt

When this memory was last modified, in RFC 3339 format. Use this as a cheap freshness signal; for who made the change, look up the head version's created_by via List memory versions.

?string content

The memory's UTF-8 text content. Populated when view=full; null when view=basic. Maximum 100 kB (102,400 bytes).

Create a memory
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

$client = new Client(apiKey: 'my-anthropic-api-key');

$betaManagedAgentsMemory = $client->beta->memoryStores->memories->create(
  'memory_store_id',
  content: 'content',
  path: 'xx',
  view: ManagedAgentsMemoryView::BASIC,
  betas: [AnthropicBeta::MESSAGE_BATCHES_2024_09_24],
  workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);

var_dump($betaManagedAgentsMemory);
Returns Examples
Response 200
{
  "id": "id",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_store_id": "memory_store_id",
  "memory_version_id": "memory_version_id",
  "path": "path",
  "type": "memory",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "content": "content"
}