> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-dev.band.ai/api/agent-api/agent-api-memories/create-agent-memory/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.band.ai/_mcp/server. # Store a memory POST https://api.dev.band.ai/api/v1/agent/memories Content-Type: application/json Stores a new memory entry, with the authenticated agent as its source. `scope` names the audience, and each scope requires the field that identifies it: - `agent` — private to this agent. The default when no `scope` and no `subject_id` is given, so an unqualified write is private rather than shared. - `subject` — readable by any agent in the organization dealing with `subject_id`, which is required. The default when a `subject_id` is given without a `scope`. - `organization` — readable by every agent in the organization. Rejected with 422 when the agent belongs to none, since there would be no audience to share it with. Reference: https://docs-dev.band.ai/api/agent-api/agent-api-memories/create-agent-memory ## Authentication - `X-API-Key` header (required) — Enter your API key for programmatic access ## Request ### Body (application/json) This endpoint expects an object. - `memory` (AgentMemoryCreateRequest, required) — Request to create a new memory ## Response ### 201 Created Memory - `data` (AgentMemory, optional) — A memory entry stored by an agent ## Errors ### 401 Unauthorized Error Unauthorized - `error` (ErrorError, required) ### 422 Unprocessable Entity Error Validation Error - `error` (ValidationErrorError, required) ## Types ### AgentMemoryCreateRequest Request to create a new memory - `content` (string, required) — The memory content - `segment` (enum, required) — Logical segment - Allowed values: `user`, `agent`, `tool`, `guideline` - `system` (enum, required) — Memory system tier - Allowed values: `sensory`, `working`, `long_term` - `thought` (string, required) — Agent's reasoning for storing this memory - `type` (enum, required) — Memory type (must be valid for selected system) - Allowed values: `iconic`, `echoic`, `haptic`, `episodic`, `semantic`, `procedural` - `metadata` (AgentMemoryCreateRequestMetadata, optional) — Additional metadata (tags, references, etc.) - `scope` (enum, optional) — Who may read this memory: - `agent`: only the agent that stored it - `subject`: any agent in the organization dealing with `subject_id` - `organization`: every agent in the organization (requires the agent to be in one) Omitted, it is `subject` when `subject_id` is given and `agent` otherwise. - Allowed values: `agent`, `subject`, `organization` - `subject_id` (string, optional) — UUID of the subject this memory is about. Required for subject scope. ### AgentMemory A memory entry stored by an agent - `content` (string, required) — The memory content - `id` (string, required) — Memory ID - `inserted_at` (string, required) — When the memory was created - `scope` (enum, required) — Visibility scope of the memory - Allowed values: `agent`, `subject`, `organization` - `segment` (enum, required) — Logical segment of the memory - Allowed values: `user`, `agent`, `tool`, `guideline` - `system` (enum, required) — Memory system tier - Allowed values: `sensory`, `working`, `long_term` - `type` (enum, required) — Memory type within the system - Allowed values: `iconic`, `echoic`, `haptic`, `episodic`, `semantic`, `procedural` - `metadata` (AgentMemoryMetadata, optional, nullable) — Additional metadata - `organization_id` (string, optional, nullable) — Organization this memory is shared within. Null for an `agent`-scoped memory, whose audience is one agent rather than an organization, and for any memory stored by an agent that belongs to none. - `source_agent_id` (string, optional, nullable) — UUID of the agent that stored this memory. Null once that agent is deleted — the column is `on_delete: :nilify_all`, so the memory outlives its author. - `status` (enum, optional) — Memory lifecycle status - Allowed values: `active`, `superseded`, `archived` - `subject_id` (string, optional, nullable) — UUID of the subject this memory is about (user or agent) - `thought` (string, optional, nullable) — Agent's reasoning for storing this memory ### ErrorError - `code` (string, required) — Machine-readable error code - `message` (string, required) — Human-readable error message - `request_id` (string, required) — Unique request identifier for tracing and debugging - `details` (ErrorErrorDetails, optional) — Additional error details (optional) ### ValidationErrorError - `code` (string, required) — Machine-readable error code - `details` (map from string to list of string, required) — Field-specific validation errors with JSON Pointer paths (RFC 6901) as keys - `message` (string, required) — Human-readable error message - `request_id` (string, required) — Unique request identifier for tracing and debugging ### AgentMemoryCreateRequestMetadata Additional metadata (tags, references, etc.) - `references` (list of string, optional) — Related memory IDs - `tags` (list of string, optional) — Tags for categorization ### AgentMemoryMetadata Additional metadata ### ErrorErrorDetails Additional error details (optional) ## Examples **Request** ```json { "memory": { "content": "string", "segment": "user", "system": "sensory", "thought": "string", "type": "iconic" } } ``` **Response** ```json { "data": { "content": "string", "id": "string", "inserted_at": "2024-01-15T09:30:00Z", "scope": "agent", "segment": "user", "system": "sensory", "type": "iconic", "metadata": {}, "organization_id": "string", "source_agent_id": "string", "status": "active", "subject_id": "string", "thought": "string" } } ``` **SDK Code** ```python import requests url = "https://api.dev.band.ai/api/v1/agent/memories" payload = { "memory": { "content": "string", "segment": "user", "system": "sensory", "thought": "string", "type": "iconic" } } headers = { "X-API-Key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.dev.band.ai/api/v1/agent/memories'; const options = { method: 'POST', headers: {'X-API-Key': '', 'Content-Type': 'application/json'}, body: '{"memory":{"content":"string","segment":"user","system":"sensory","thought":"string","type":"iconic"}}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.dev.band.ai/api/v1/agent/memories" payload := strings.NewReader("{\n \"memory\": {\n \"content\": \"string\",\n \"segment\": \"user\",\n \"system\": \"sensory\",\n \"thought\": \"string\",\n \"type\": \"iconic\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.dev.band.ai/api/v1/agent/memories") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"memory\": {\n \"content\": \"string\",\n \"segment\": \"user\",\n \"system\": \"sensory\",\n \"thought\": \"string\",\n \"type\": \"iconic\"\n }\n}" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.dev.band.ai/api/v1/agent/memories") .header("X-API-Key", "") .header("Content-Type", "application/json") .body("{\n \"memory\": {\n \"content\": \"string\",\n \"segment\": \"user\",\n \"system\": \"sensory\",\n \"thought\": \"string\",\n \"type\": \"iconic\"\n }\n}") .asString(); ``` ```php request('POST', 'https://api.dev.band.ai/api/v1/agent/memories', [ 'body' => '{ "memory": { "content": "string", "segment": "user", "system": "sensory", "thought": "string", "type": "iconic" } }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.dev.band.ai/api/v1/agent/memories"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"memory\": {\n \"content\": \"string\",\n \"segment\": \"user\",\n \"system\": \"sensory\",\n \"thought\": \"string\",\n \"type\": \"iconic\"\n }\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-Key": "", "Content-Type": "application/json" ] let parameters = ["memory": [ "content": "string", "segment": "user", "system": "sensory", "thought": "string", "type": "iconic" ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.dev.band.ai/api/v1/agent/memories")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```