feat: add get_archive_by_id endpoint [LET-4405] (#5640)

add get_archive_by_id

Co-authored-by: Ari Webb <ari@letta.com>
This commit is contained in:
Ari Webb
2025-10-22 11:56:13 -07:00
committed by Caren Thomas
parent 12185c8601
commit 4083f335f4
2 changed files with 61 additions and 0 deletions

View File

@@ -200,6 +200,51 @@
}
},
"/v1/archives/{archive_id}": {
"get": {
"tags": ["archives"],
"summary": "Get Archive By Id",
"description": "Get a single archive by its ID.",
"operationId": "get_archive_by_id",
"parameters": [
{
"name": "archive_id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"minLength": 44,
"maxLength": 44,
"pattern": "^archive-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
"description": "The ID of the archive in the format 'archive-<uuid4>'",
"examples": ["archive-123e4567-e89b-42d3-8456-426614174000"],
"title": "Archive Id"
},
"description": "The ID of the archive in the format 'archive-<uuid4>'"
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Archive"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
},
"patch": {
"tags": ["archives"],
"summary": "Modify Archive",

View File

@@ -83,6 +83,22 @@ async def list_archives(
return archives
@router.get("/{archive_id}", response_model=PydanticArchive, operation_id="get_archive_by_id")
async def get_archive_by_id(
archive_id: ArchiveId,
server: "SyncServer" = Depends(get_letta_server),
headers: HeaderParams = Depends(get_headers),
):
"""
Get a single archive by its ID.
"""
actor = await server.user_manager.get_actor_or_default_async(actor_id=headers.actor_id)
return await server.archive_manager.get_archive_by_id_async(
archive_id=archive_id,
actor=actor,
)
@router.patch("/{archive_id}", response_model=PydanticArchive, operation_id="modify_archive")
async def modify_archive(
archive_id: ArchiveId,