List and sort sessions
Filter sessions by owner, namespace, or time, sort results, and follow pagination.
Use session listing to let a user reopen an earlier conversation. The session rows contain IDs and available owner, timestamp, and namespace metadata. They do not contain conversation events or summary text. Retrieve the selected session with memory.conversation(owner=..., session_id=...).transcript() (Python), iris agent-memory sessions show, or GET /iris/data/v1/agent-memory/stores/{storeId}/sessions/{sessionId} to build the agent's conversation context.
Choose a listing operation
| Result you need | REST endpoint | Python | CLI |
|---|---|---|---|
| Every session ID for one owner | GET /iris/data/v1/agent-memory/stores/{storeId}/sessions?ownerId=... |
memory.sessions(owner) |
iris agent-memory sessions list --owner |
| Session rows with filters, sorting, and pagination | GET /iris/data/v1/agent-memory/stores/{storeId}/sessions |
memory.client.list_sessions |
Not available |
The REST operation returns items and an optional nextCursor. It does not return a total count. memory.sessions(owner) follows every page for you and returns only the IDs.
These examples continue from the quickstart. Load the same .env connection values and reuse its user ID. Expand an example to copy a complete program that connects for you.
Each run repeats every write in the program. Session-event writes and memory creates with a new idempotency key add new records, so run cleanup or change the identifiers before rerunning.
To list the quickstart user's session IDs:
for session_id in memory.sessions(OWNER_ID):
print(session_id)
from redis_iris.agent_memory import AgentMemory, models
OWNER_ID = "quickstart-user"
memory = AgentMemory.from_env()
for session_id in memory.sessions(OWNER_ID):
print(session_id)
from datetime import datetime, timedelta, timezone
end = datetime.now(timezone.utc)
start = end - timedelta(days=7)
activity = memory.client.list_sessions(
owner_id=OWNER_ID, updated_at_gte=start, updated_at_lt=end, limit=20,
)
for item in activity.items:
print(item.session_id, item.updated_at)
cursor = None
while True:
page = memory.client.list_sessions(
owner_id=OWNER_ID,
sort_by=models.SessionListSortBy.UPDATED_AT,
sort_order=models.SessionListSortOrder.DESC,
limit=20,
cursor=cursor,
)
for session in page.items:
print(session.session_id, session.updated_at, session.namespace_id)
cursor = page.next_cursor
if not cursor:
break
const owned = await memory.listSessions(undefined, undefined, OWNER_ID);
for (const session of owned.items) console.log(session.sessionId);
import { AgentMemory } from "@redis-iris/agent-memory";
const memory = new AgentMemory({
serverURL: process.env.IRIS_AGENT_MEMORY_URL!,
storeId: process.env.IRIS_AGENT_MEMORY_STORE_ID!,
apiKey: process.env.IRIS_AGENT_MEMORY_API_KEY!,
});
const OWNER_ID = "quickstart-user";
const owned = await memory.listSessions(undefined, undefined, OWNER_ID);
for (const session of owned.items) console.log(session.sessionId);
const end = new Date();
const start = new Date(end.getTime() - 7 * 24 * 60 * 60 * 1_000);
const activity = await memory.listSessions(
20, undefined, OWNER_ID, undefined, undefined, undefined,
undefined, undefined, // sortBy, sortOrder
undefined, undefined, undefined, undefined, // creation time bounds
undefined, start, end, // updatedAtGt, updatedAtGte, updatedAtLt
);
for (const session of activity.items) console.log(session.sessionId, session.updatedAt);
let cursor: string | undefined;
do {
const page = await memory.listSessions(
20, cursor, OWNER_ID, undefined, undefined, undefined, "updatedAt", "DESC",
);
for (const session of page.items) console.log(session.sessionId, session.updatedAt, session.namespaceId);
cursor = page.nextCursor;
} while (cursor);
curl --fail-with-body --silent --show-error --get \
"$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" | jq -r '.items[].sessionId'
set -euo pipefail
MEMORY_API="${IRIS_AGENT_MEMORY_URL%/}/iris/data/v1/agent-memory/stores/$IRIS_AGENT_MEMORY_STORE_ID"
AUTH="Authorization: Bearer $IRIS_AGENT_MEMORY_API_KEY"
OWNER_ID=quickstart-user
curl --fail-with-body --silent --show-error --get \
"$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" | jq -r '.items[].sessionId'
END=$(date -u +%s)
START=$((END - 7 * 24 * 60 * 60))
curl --fail-with-body --silent --show-error --get "$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" --data-urlencode 'limit=20' \
--data-urlencode "updatedAtGte=$(jq -nr --argjson time "$START" '$time | todateiso8601')" \
--data-urlencode "updatedAtLt=$(jq -nr --argjson time "$END" '$time | todateiso8601')" |
jq '.items[] | {sessionId, updatedAt}'
CURSOR=''
while :; do
PAGE=$(curl --fail-with-body --silent --show-error --get \
"$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" \
--data-urlencode 'sortBy=updatedAt' --data-urlencode 'sortOrder=DESC' \
--data-urlencode 'limit=20' ${CURSOR:+--data-urlencode "cursor=$CURSOR"})
jq -c '.items[] | {sessionId, updatedAt, namespaceId}' <<< "$PAGE"
CURSOR=$(jq -r '.nextCursor // empty' <<< "$PAGE")
[ -n "$CURSOR" ] || break
done
set -euo pipefail
iris agent-memory sessions list --owner quickstart-user
set -euo pipefail
iris agent-memory sessions list --owner quickstart-user
For a user's personal conversations, set ownerId to the user's authenticated ID. The session owner is the first event's actorId. Add namespaceId to require an exact namespace ID as well. It does not include descendants, deprecated namespace labels, or sessions without a namespace resource. Owner and namespace matching is case-sensitive.
A request without filters must set includeAll=true. Do not combine includeAll=true with any filter. Authorize store-wide or shared namespace listing in your application before making the request. A filter selects records; it does not establish the caller's right to access them.
Filter by creation time or last update
Use an RFC 3339 timestamp such as 2026-11-01T00:00:00Z in any of these query parameters.
| Time bound | Creation time | Last update |
|---|---|---|
| After | createdAtGt |
updatedAtGt |
| At or after | createdAtGte |
updatedAtGte |
| Before | createdAtLt |
updatedAtLt |
| At or before | createdAtLte |
updatedAtLte |
For an activity window, combine updatedAtGte and updatedAtLt. Use one lower bound and one upper bound per timestamp. You can combine time bounds with ownerId and namespaceId. A time filter excludes sessions whose matching timestamp is unknown.
This example lists one user’s sessions updated in the past seven days.
from datetime import datetime, timedelta, timezone
end = datetime.now(timezone.utc)
start = end - timedelta(days=7)
activity = memory.client.list_sessions(
owner_id=OWNER_ID, updated_at_gte=start, updated_at_lt=end, limit=20,
)
for item in activity.items:
print(item.session_id, item.updated_at)
const end = new Date();
const start = new Date(end.getTime() - 7 * 24 * 60 * 60 * 1_000);
const activity = await memory.listSessions(
20, undefined, OWNER_ID, undefined, undefined, undefined,
undefined, undefined, // sortBy, sortOrder
undefined, undefined, undefined, undefined, // creation time bounds
undefined, start, end, // updatedAtGt, updatedAtGte, updatedAtLt
);
for (const session of activity.items) console.log(session.sessionId, session.updatedAt);
END=$(date -u +%s)
START=$((END - 7 * 24 * 60 * 60))
curl --fail-with-body --silent --show-error --get "$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" --data-urlencode 'limit=20' \
--data-urlencode "updatedAtGte=$(jq -nr --argjson time "$START" '$time | todateiso8601')" \
--data-urlencode "updatedAtLt=$(jq -nr --argjson time "$END" '$time | todateiso8601')" |
jq '.items[] | {sessionId, updatedAt}'
Sort and paginate session rows
The default is sortBy=updatedAt and sortOrder=DESC, so recent activity appears first. sortBy accepts sessionId, createdAt, or updatedAt. sortOrder accepts ASC or DESC. When omitted, it is ascending for sessionId and descending for timestamps. limit accepts 1–200 and defaults to 100.
To list session rows for one owner, with the most recently updated sessions first, follow every page:
cursor = None
while True:
page = memory.client.list_sessions(
owner_id=OWNER_ID,
sort_by=models.SessionListSortBy.UPDATED_AT,
sort_order=models.SessionListSortOrder.DESC,
limit=20,
cursor=cursor,
)
for session in page.items:
print(session.session_id, session.updated_at, session.namespace_id)
cursor = page.next_cursor
if not cursor:
break
let cursor: string | undefined;
do {
const page = await memory.listSessions(
20, cursor, OWNER_ID, undefined, undefined, undefined, "updatedAt", "DESC",
);
for (const session of page.items) console.log(session.sessionId, session.updatedAt, session.namespaceId);
cursor = page.nextCursor;
} while (cursor);
CURSOR=''
while :; do
PAGE=$(curl --fail-with-body --silent --show-error --get \
"$MEMORY_API/sessions" -H "$AUTH" \
--data-urlencode "ownerId=$OWNER_ID" \
--data-urlencode 'sortBy=updatedAt' --data-urlencode 'sortOrder=DESC' \
--data-urlencode 'limit=20' ${CURSOR:+--data-urlencode "cursor=$CURSOR"})
jq -c '.items[] | {sessionId, updatedAt, namespaceId}' <<< "$PAGE"
CURSOR=$(jq -r '.nextCursor // empty' <<< "$PAGE")
[ -n "$CURSOR" ] || break
done
Pass each returned nextCursor as cursor. Keep all filters, including time bounds, and sort options unchanged. Stop when the cursor is absent. The cursor is opaque, so URL-encode it in REST requests. Changing a filter or sort requires a new request without the old cursor.
List rows and single-session reads both return createdAt and updatedAt when known. Older session rows can omit ownerId and unknown timestamps. Adding events, removing events, and writing a summary advance updatedAt. To see whether a summary is available, check the single-session response.