Agno Memory API
The Memory API from Agno — 5 operation(s) for memory.
The Memory API from Agno — 5 operation(s) for memory.
openapi: 3.1.0
info:
title: Agno API Reference A2A Memory API
description: The all-in-one, private, secure agent platform that runs in your cloud.
version: 2.5.6
tags:
- name: Memory
paths:
/memories:
post:
tags:
- Memory
summary: Create Memory
description: Create a new user memory with content and associated topics. Memories are used to store contextual information for users across conversations.
operationId: create_memory
security:
- HTTPBearer: []
parameters:
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to use for memory storage
title: Db Id
description: Database ID to use for memory storage
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to use for memory storage
title: Table
description: Table to use for memory storage
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserMemoryCreateSchema'
responses:
'200':
description: Memory created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserMemorySchema'
example:
memory_id: mem-123
memory: User prefers technical explanations with code examples
topics:
- preferences
- communication_style
- technical
user_id: user-456
created_at: '2024-01-15T10:30:00Z'
updated_at: '2024-01-15T10:30:00Z'
'400':
description: Invalid request data
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation error in payload
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to create memory
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
delete:
tags:
- Memory
summary: Delete Multiple Memories
description: Delete multiple user memories by their IDs in a single operation. This action cannot be undone and all specified memories will be permanently removed.
operationId: delete_memories
security:
- HTTPBearer: []
parameters:
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to use for deletion
title: Db Id
description: Database ID to use for deletion
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to use for deletion
title: Table
description: Table to use for deletion
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteMemoriesRequest'
responses:
'204':
description: Memories deleted successfully
'400':
description: Invalid request - empty memory_ids list
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to delete memories
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
get:
tags:
- Memory
summary: List Memories
description: Retrieve paginated list of user memories with filtering and search capabilities. Filter by user, agent, team, topics, or search within memory content.
operationId: get_memories
security:
- HTTPBearer: []
parameters:
- name: user_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Filter memories by user ID
title: User Id
description: Filter memories by user ID
- name: agent_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Filter memories by agent ID
title: Agent Id
description: Filter memories by agent ID
- name: team_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Filter memories by team ID
title: Team Id
description: Filter memories by team ID
- name: search_content
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Fuzzy search within memory content
title: Search Content
description: Fuzzy search within memory content
- name: limit
in: query
required: false
schema:
anyOf:
- type: integer
minimum: 1
- type: 'null'
description: Number of memories to return per page
default: 20
title: Limit
description: Number of memories to return per page
- name: page
in: query
required: false
schema:
anyOf:
- type: integer
minimum: 0
- type: 'null'
description: Page number for pagination
default: 1
title: Page
description: Page number for pagination
- name: sort_by
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Field to sort memories by
default: updated_at
title: Sort By
description: Field to sort memories by
- name: sort_order
in: query
required: false
schema:
anyOf:
- $ref: '#/components/schemas/SortOrder'
- type: 'null'
description: Sort order (asc or desc)
default: desc
title: Sort Order
description: Sort order (asc or desc)
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to query memories from
title: Db Id
description: Database ID to query memories from
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: The database table to use
title: Table
description: The database table to use
- name: topics
in: query
required: false
schema:
anyOf:
- type: array
items:
type: string
- type: 'null'
description: Comma-separated list of topics to filter by
examples:
- preferences,technical,communication_style
title: Topics
description: Comma-separated list of topics to filter by
responses:
'200':
description: Memories retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedResponse_UserMemorySchema_'
example:
data:
- memory_id: f9361a69-2997-40c7-ae4e-a5861d434047
memory: User likes coffee.
topics:
- preferences
user_id: '123'
updated_at: '2025-09-01T07:53:17Z'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
/memories/{memory_id}:
delete:
tags:
- Memory
summary: Delete Memory
description: Permanently delete a specific user memory. This action cannot be undone.
operationId: delete_memory
security:
- HTTPBearer: []
parameters:
- name: memory_id
in: path
required: true
schema:
type: string
description: Memory ID to delete
title: Memory Id
description: Memory ID to delete
- name: user_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: User ID to delete memory for
title: User Id
description: User ID to delete memory for
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to use for deletion
title: Db Id
description: Database ID to use for deletion
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to use for deletion
title: Table
description: Table to use for deletion
responses:
'204':
description: Memory deleted successfully
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Memory not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to delete memory
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
get:
tags:
- Memory
summary: Get Memory by ID
description: Retrieve detailed information about a specific user memory by its ID.
operationId: get_memory
security:
- HTTPBearer: []
parameters:
- name: memory_id
in: path
required: true
schema:
type: string
description: Memory ID to retrieve
title: Memory Id
description: Memory ID to retrieve
- name: user_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: User ID to query memory for
title: User Id
description: User ID to query memory for
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to query memory from
title: Db Id
description: Database ID to query memory from
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to query memory from
title: Table
description: Table to query memory from
responses:
'200':
description: Memory retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserMemorySchema'
example:
memory_id: f9361a69-2997-40c7-ae4e-a5861d434047
memory: User likes coffee.
topics:
- preferences
user_id: '123'
updated_at: '2025-09-01T07:53:17Z'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Memory not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
patch:
tags:
- Memory
summary: Update Memory
description: Update an existing user memory's content and topics. Replaces the entire memory content and topic list with the provided values.
operationId: update_memory
security:
- HTTPBearer: []
parameters:
- name: memory_id
in: path
required: true
schema:
type: string
description: Memory ID to update
title: Memory Id
description: Memory ID to update
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to use for update
title: Db Id
description: Database ID to use for update
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to use for update
title: Table
description: Table to use for update
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserMemoryCreateSchema'
responses:
'200':
description: Memory updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UserMemorySchema'
example:
memory_id: f9361a69-2997-40c7-ae4e-a5861d434047
memory: User likes coffee.
topics:
- preferences
user_id: '123'
updated_at: '2025-09-01T07:53:17Z'
'400':
description: Invalid request data
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Memory not found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation error in payload
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to update memory
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
/memory_topics:
get:
tags:
- Memory
summary: Get Memory Topics
description: Retrieve all unique topics associated with memories in the system. Useful for filtering and categorizing memories by topic.
operationId: get_memory_topics
security:
- HTTPBearer: []
parameters:
- name: user_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: User ID to filter topics for
title: User Id
description: User ID to filter topics for
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to query topics from
title: Db Id
description: Database ID to query topics from
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to query topics from
title: Table
description: Table to query topics from
responses:
'200':
description: Memory topics retrieved successfully
content:
application/json:
schema:
type: array
items:
type: string
title: Response Get Memory Topics
example:
- preferences
- communication_style
- technical
- industry
- compliance
- code_examples
- requirements
- healthcare
- finance
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
/user_memory_stats:
get:
tags:
- Memory
summary: Get User Memory Statistics
description: Retrieve paginated statistics about memory usage by user. Provides insights into user engagement and memory distribution across users.
operationId: get_user_memory_stats
security:
- HTTPBearer: []
parameters:
- name: limit
in: query
required: false
schema:
anyOf:
- type: integer
minimum: 1
- type: 'null'
description: Number of user statistics to return per page
default: 20
title: Limit
description: Number of user statistics to return per page
- name: page
in: query
required: false
schema:
anyOf:
- type: integer
minimum: 0
- type: 'null'
description: Page number for pagination
default: 1
title: Page
description: Page number for pagination
- name: user_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: User ID to filter statistics for
title: User Id
description: User ID to filter statistics for
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to query statistics from
title: Db Id
description: Database ID to query statistics from
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to query statistics from
title: Table
description: Table to query statistics from
responses:
'200':
description: User memory statistics retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedResponse_UserStatsSchema_'
example:
data:
- user_id: '123'
total_memories: 3
last_memory_updated_at: '2025-09-01T07:53:17Z'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to retrieve user statistics
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
/optimize-memories:
post:
tags:
- Memory
summary: Optimize User Memories
description: Optimize all memories for a given user using the default summarize strategy. This operation combines all memories into a single comprehensive summary, achieving maximum token reduction while preserving all key information. To use a custom model, specify the model parameter in 'provider:model_id' format (e.g., 'openai:gpt-4o-mini', 'anthropic:claude-3-5-sonnet-20241022'). If not specified, uses MemoryManager's default model (gpt-4o). Set apply=false to preview optimization results without saving to database.
operationId: optimize_memories
security:
- HTTPBearer: []
parameters:
- name: db_id
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Database ID to use for optimization
title: Db Id
description: Database ID to use for optimization
- name: table
in: query
required: false
schema:
anyOf:
- type: string
- type: 'null'
description: Table to use for optimization
title: Table
description: Table to use for optimization
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OptimizeMemoriesRequest'
responses:
'200':
description: Memories optimized successfully
content:
application/json:
schema:
$ref: '#/components/schemas/OptimizeMemoriesResponse'
example:
memories:
- memory_id: f9361a69-2997-40c7-ae4e-a5861d434047
memory: User has a 3-year-old golden retriever named Max who loves fetch and walks. Lives in San Francisco's Mission district, works as a product manager in tech. Enjoys hiking Bay Area trails, trying new restaurants (especially Japanese, Thai, Mexican), and learning piano for 1.5 years.
topics:
- pets
- location
- work
- hobbies
- food_preferences
user_id: user2
updated_at: '2025-11-18T10:30:00Z'
memories_before: 4
memories_after: 1
tokens_before: 450
tokens_after: 180
tokens_saved: 270
reduction_percentage: 60
'400':
description: Bad request - User ID is required or invalid model string format
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequestResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/UnauthenticatedResponse'
'404':
description: No memories found for user
content:
application/json:
schema:
$ref: '#/components/schemas/NotFoundResponse'
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationErrorResponse'
'500':
description: Failed to optimize memories
content:
application/json:
schema:
$ref: '#/components/schemas/InternalServerErrorResponse'
components:
schemas:
SortOrder:
type: string
enum:
- asc
- desc
title: SortOrder
PaginationInfo:
properties:
page:
type: integer
minimum: 0
title: Page
description: Current page number (0-indexed)
default: 0
limit:
type: integer
minimum: 1
title: Limit
description: Number of items per page
default: 20
total_pages:
type: integer
minimum: 0
title: Total Pages
description: Total number of pages
default: 0
total_count:
type: integer
minimum: 0
title: Total Count
description: Total count of items
default: 0
search_time_ms:
type: number
minimum: 0
title: Search Time Ms
description: Search execution time in milliseconds
default: 0
type: object
title: PaginationInfo
BadRequestResponse:
properties:
detail:
type: string
title: Detail
description: Error detail message
error_code:
anyOf:
- type: string
- type: 'null'
title: Error Code
description: Error code for categorization
type: object
required:
- detail
title: BadRequestResponse
example:
detail: Bad request
error_code: BAD_REQUEST
ValidationErrorResponse:
properties:
detail:
type: string
title: Detail
description: Error detail message
error_code:
anyOf:
- type: string
- type: 'null'
title: Error Code
description: Error code for categorization
type: object
required:
- detail
title: ValidationErrorResponse
example:
detail: Validation error
error_code: VALIDATION_ERROR
InternalServerErrorResponse:
properties:
detail:
type: string
title: Detail
description: Error detail message
error_code:
anyOf:
- type: string
- type: 'null'
title: Error Code
description: Error code for categorization
type: object
required:
- detail
title: InternalServerErrorResponse
example:
detail: Internal server error
error_code: INTERNAL_SERVER_ERROR
DeleteMemoriesRequest:
properties:
memory_ids:
items:
type: string
type: array
minItems: 1
title: Memory Ids
description: List of memory IDs to delete
user_id:
anyOf:
- type: string
- type: 'null'
title: User Id
description: User ID to filter memories for deletion
type: object
required:
- memory_ids
title: DeleteMemoriesRequest
UserStatsSchema:
properties:
user_id:
type: string
title: User Id
description: User ID
total_memories:
type: integer
minimum: 0
title: Total Memories
description: Total number of memories for this user
last_memory_updated_at:
anyOf:
- type: string
format: date-time
- type: 'null'
title: Last Memory Updated At
description: Timestamp of the most recent memory update
type: object
required:
- user_id
- total_memories
title: UserStatsSchema
description: Schema for user memory statistics
PaginatedResponse_UserMemorySchema_:
properties:
data:
items:
$ref: '#/components/schemas/UserMemorySchema'
type: array
title: Data
description: List of items for the current page
meta:
$ref: '#/components/schemas/PaginationInfo'
description: Pagination metadata
type: object
required:
- data
- meta
title: PaginatedResponse[UserMemorySchema]
PaginatedResponse_UserStatsSchema_:
properties:
data:
items:
$ref: '#/components/schemas/UserStatsSchema'
type: array
title: Data
description: List of items for the current page
meta:
$ref: '#/components/schemas/PaginationInfo'
description: Pagination metadata
type: object
required:
- data
- meta
title: PaginatedResponse[UserStatsSchema]
UnauthenticatedResponse:
properties:
detail:
type: string
title: Detail
description: Error detail message
error_code:
anyOf:
- type: string
- type: 'null'
title: Error Code
description: Error code for categorization
type: object
required:
- detail
title: UnauthenticatedResponse
example:
detail: Unauthenticated access
error_code: UNAUTHENTICATED
UserMemoryCreateSchema:
properties:
memory:
type: string
maxLength: 5000
minLength: 1
title: Memory
description: Memory content text
user_id:
# --- truncated at 32 KB (36 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/agno/refs/heads/main/openapi/agno-memory-api-openapi.yml