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.
| Method | Path | Summary |
|---|---|---|
| GET | /v1/memory | List memory entries |
| POST | /v1/memory | Create 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
key | query | string or null | No | Filter by exact key match. |
key_prefix | query | string or null | No | Filter by key prefix (Redis-style namespace scan). Mutually exclusive with key; if both are provided, key_prefix wins. |
search | query | string or null | No | Match entries whose key starts with this value or whose memory_id equals it. Takes precedence over key_prefix and key when provided. |
page | query | integer | No | The page to return, starting at 1. |
page_size | query | integer | No | Entries per page, from 1 to 500. |
Example request:
curl -X GET "http://localhost:4000/v1/memory" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json MemoryListResponse |
| 401 | No valid key was sent, or the key is not a proxy admin key, which the memory routes need today | application/json ProxyError |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB 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_keys | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
memories | array of Spanway_MemoryRow | Yes | Memories |
total | integer | Yes | Total |
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):
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Memory key (acts as the namespace in the URL). |
value | string | Yes | Memory content. Typically markdown/text for LLM context. |
metadata | any or null | No | Optional JSON metadata (tags, structured fields). |
user_id | string or null | No | Scope to this user. Defaults to the caller's user_id. |
team_id | string or null | No | Scope 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json Spanway_MemoryRow |
| 400 | Cannot 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 |
| 401 | No valid key was sent, or the key is not a proxy admin key, which the memory routes need today | application/json ProxyError |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 409 | Memory with key 'project/platform/summary' already exists. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB 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_keys | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
memory_id | string | Yes | Memory Id |
key | string | Yes | Key |
value | string | Yes | Value |
metadata | any or null | No | Metadata |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
key | path | string | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json Spanway_MemoryRow |
| 401 | No valid key was sent, or the key is not a proxy admin key, which the memory routes need today | application/json ProxyError |
| 404 | Memory with key 'project/platform/summary' not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB 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_keys | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
memory_id | string | Yes | Memory Id |
key | string | Yes | Key |
value | string | Yes | Value |
metadata | any or null | No | Metadata |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
key | path | string | Yes | The memory key, slashes allowed, for example project/platform/summary |
Request body (application/json, schema MemoryUpdateRequest):
| Field | Type | Required | Description |
|---|---|---|---|
value | string or null | No | New memory content. Required when PUT creates the entry. |
metadata | any or null | No | New JSON metadata. Send null to clear it, leave it out to keep it. |
user_id | string or null | No | Scope of a newly created entry. Only proxy admins may name another user. |
team_id | string or null | No | Scope 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json Spanway_MemoryRow |
| 400 | The request is malformed or breaks a rule named in the detail | application/json ErrorDetail |
| 401 | No valid key was sent, or the key is not a proxy admin key, which the memory routes need today | application/json ProxyError |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 404 | Memory with key 'project/platform/summary' not found | application/json ErrorDetail |
| 409 | Memory with key 'project/platform/summary' already exists. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB 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_keys | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
memory_id | string | Yes | Memory Id |
key | string | Yes | Key |
value | string | Yes | Value |
metadata | any or null | No | Metadata |
user_id | string or null | No | User Id |
team_id | string or null | No | Team Id |
created_at | string or null | No | Created At |
created_by | string or null | No | Created By |
updated_at | string or null | No | Updated At |
updated_by | string or null | No | Updated 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:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
key | path | string | Yes | The 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:
| Status | Description | Body |
|---|---|---|
| 200 | Successful response | application/json MemoryDeleteResponse |
| 401 | No valid key was sent, or the key is not a proxy admin key, which the memory routes need today | application/json ProxyError |
| 403 | You do not have permission to modify this memory entry. | application/json ErrorDetail |
| 404 | Memory with key 'project/platform/summary' not found | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | DB 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_keys | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
key | string | Yes | Key |
deleted | boolean | Yes | Deleted |