Skip to main content

Memory management API

This page documents the 5 gateway endpoints tagged memory management in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/v1/memoryList memory entries
POST/v1/memoryCreate a memory entry
GET/v1/memory/{key}Read one memory entry
PUT/v1/memory/{key}Create or update a memory entry by key
DELETE/v1/memory/{key}Delete a memory entry

Endpoints​

GET /v1/memory​

List memory entries

The entries visible to the caller, their own and their team's, with admins seeing every scope. Filter with key, key_prefix or search and page with page and page_size. Nothing changes. Proxy admins may call it and admin viewers may read. Other keys answer 401 from the gateway's route checks today. A key is unique across the whole gateway, so namespace keys, for example user:123:notes. Docs (https://docs.spanway.ai/docs/proxy/memory)

Parameters:

NameInTypeRequiredDescription
keyquerystring or nullNoFilter by exact key match.
key_prefixquerystring or nullNoFilter by key prefix (Redis-style namespace scan). Mutually exclusive with key; if both are provided, key_prefix wins.
searchquerystring or nullNoMatch entries whose key starts with this value or whose memory_id equals it. Takes precedence over key_prefix and key when provided.
pagequeryintegerNoThe page to return, starting at 1.
page_sizequeryintegerNoEntries per page, from 1 to 500.

Example request:

curl -X GET "http://localhost:4000/v1/memory" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful responseapplication/json MemoryListResponse
401No valid key was sent, or the key is not a proxy admin key, which the memory routes need todayapplication/json ProxyError
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
memoriesarray of Spanway_MemoryRowYesMemories
totalintegerYesTotal

POST /v1/memory​

Create a memory entry

Saves a note an agent or person wants to keep between sessions, under a key, for the caller's user and team unless an admin names another scope. Proxy admins may call it and admin viewers may read. Other keys answer 401 from the gateway's route checks today. A key is unique across the whole gateway, so namespace keys, for example user:123:notes. Docs (https://docs.spanway.ai/docs/proxy/memory)

Request body (application/json, schema MemoryCreateRequest):

FieldTypeRequiredDescription
keystringYesMemory key (acts as the namespace in the URL).
valuestringYesMemory content. Typically markdown/text for LLM context.
metadataany or nullNoOptional JSON metadata (tags, structured fields).
user_idstring or nullNoScope to this user. Defaults to the caller's user_id.
team_idstring or nullNoScope to this team. Defaults to the caller's team_id.

Example request:

curl -X POST "http://localhost:4000/v1/memory" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "project/platform/summary",
"value": "Platform is a monorepo. Releases cut from main every Tuesday.",
"metadata": {
"source": "onboarding"
}
}'

Responses:

StatusDescriptionBody
200Successful responseapplication/json Spanway_MemoryRow
400Cannot create a memory entry without a user_id or team_id. Authenticate with a key that has a user_id or team_id, or call as a proxy admin.application/json ErrorDetail
401No valid key was sent, or the key is not a proxy admin key, which the memory routes need todayapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
409Memory with key 'project/platform/summary' already exists.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
memory_idstringYesMemory Id
keystringYesKey
valuestringYesValue
metadataany or nullNoMetadata
user_idstring or nullNoUser Id
team_idstring or nullNoTeam Id
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated By

GET /v1/memory/{key}​

Read one memory entry

Returns the entry stored under key if the caller may see it, otherwise 404. Nothing changes. Proxy admins may call it and admin viewers may read. Other keys answer 401 from the gateway's route checks today. A key is unique across the whole gateway, so namespace keys, for example user:123:notes. Docs (https://docs.spanway.ai/docs/proxy/memory)

Parameters:

NameInTypeRequiredDescription
keypathstringYesThe memory key, slashes allowed, for example project/platform/summary

Example request:

curl -X GET "http://localhost:4000/v1/memory/key-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful responseapplication/json Spanway_MemoryRow
401No valid key was sent, or the key is not a proxy admin key, which the memory routes need todayapplication/json ProxyError
404Memory with key 'project/platform/summary' not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
memory_idstringYesMemory Id
keystringYesKey
valuestringYesValue
metadataany or nullNoMetadata
user_idstring or nullNoUser Id
team_idstring or nullNoTeam Id
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated By

PUT /v1/memory/{key}​

Create or update a memory entry by key

Updates the value or metadata of the entry stored under key, or creates it for the caller when no entry has that key. Because keys are unique across the gateway, a key held by an entry the caller cannot see answers 409. Proxy admins may call it and admin viewers may read. Other keys answer 401 from the gateway's route checks today. A key is unique across the whole gateway, so namespace keys, for example user:123:notes. Docs (https://docs.spanway.ai/docs/proxy/memory)

Parameters:

NameInTypeRequiredDescription
keypathstringYesThe memory key, slashes allowed, for example project/platform/summary

Request body (application/json, schema MemoryUpdateRequest):

FieldTypeRequiredDescription
valuestring or nullNoNew memory content. Required when PUT creates the entry.
metadataany or nullNoNew JSON metadata. Send null to clear it, leave it out to keep it.
user_idstring or nullNoScope of a newly created entry. Only proxy admins may name another user.
team_idstring or nullNoScope of a newly created entry. Only proxy admins may name another team.

Example request:

curl -X PUT "http://localhost:4000/v1/memory/key-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"value": "Platform is a monorepo. Releases cut from main every Wednesday.",
"metadata": {
"source": "onboarding"
}
}'

Responses:

StatusDescriptionBody
200Successful responseapplication/json Spanway_MemoryRow
400The request is malformed or breaks a rule named in the detailapplication/json ErrorDetail
401No valid key was sent, or the key is not a proxy admin key, which the memory routes need todayapplication/json ProxyError
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404Memory with key 'project/platform/summary' not foundapplication/json ErrorDetail
409Memory with key 'project/platform/summary' already exists.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
memory_idstringYesMemory Id
keystringYesKey
valuestringYesValue
metadataany or nullNoMetadata
user_idstring or nullNoUser Id
team_idstring or nullNoTeam Id
created_atstring or nullNoCreated At
created_bystring or nullNoCreated By
updated_atstring or nullNoUpdated At
updated_bystring or nullNoUpdated By

DELETE /v1/memory/{key}​

Delete a memory entry

Deletes the entry stored under key. Only its owner, a team admin for a team entry, or a proxy admin may delete it. Proxy admins may call it and admin viewers may read. Other keys answer 401 from the gateway's route checks today. A key is unique across the whole gateway, so namespace keys, for example user:123:notes. Docs (https://docs.spanway.ai/docs/proxy/memory)

Parameters:

NameInTypeRequiredDescription
keypathstringYesThe memory key, slashes allowed, for example project/platform/summary

Example request:

curl -X DELETE "http://localhost:4000/v1/memory/key-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Successful responseapplication/json MemoryDeleteResponse
401No valid key was sent, or the key is not a proxy admin key, which the memory routes need todayapplication/json ProxyError
403You do not have permission to modify this memory entry.application/json ErrorDetail
404Memory with key 'project/platform/summary' not foundapplication/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500DB not connected. This endpoint needs a database; set DATABASE_URL to a PostgreSQL connection string (postgresql://...) to enable it. See https://docs.spanway.ai/docs/proxy/virtual_keysapplication/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
keystringYesKey
deletedbooleanYesDeleted