Summarize agent sessions
GET
/agents/{id}/sessions/stats
const url = 'https://api.somebodyai.co/api/v1/agents/507f1f77bcf86cd799439011/sessions/stats?from=2026-07-13T00%3A00%3A00.000Z&to=2026-07-20T00%3A00%3A00.000Z&tz=UTC';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.somebodyai.co/api/v1/agents/507f1f77bcf86cd799439011/sessions/stats?from=2026-07-13T00%3A00%3A00.000Z&to=2026-07-20T00%3A00%3A00.000Z&tz=UTC' \ --header 'Authorization: Bearer <token>'Returns the count, total and average duration, average turns, roleplay grade totals and a per-day series for the agent's sessions in the same range the list endpoint takes.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”id
required
Agent ObjectId
string
Agent ObjectId
Query Parameters
Section titled “Query Parameters”from
ISO lower bound on session time
string format: date-time
ISO lower bound on session time
to
ISO upper bound on session time, exclusive
string format: date-time
ISO upper bound on session time, exclusive
tz
IANA time zone the daily series is bucketed in
string
IANA time zone the daily series is bucketed in
Responses
Section titled “Responses”Session statistics
Media typeapplication/json
object
count
required
integer
totalDurationMs
required
number
avgDurationMs
required
number
avgTurns
required
number
graded
required
Graded roleplay sessions; passed and failed count only those with a pass result
object
count
required
integer
avgScorePercent
required
Null when no session was graded
number | null
passed
required
integer
failed
required
integer
daily
required
Days with at least one session, oldest first, in tz
Array<object>
object
date
required
string
count
required
integer
totalDurationMs
required
number
Example
{ "count": 42, "totalDurationMs": 8400000, "avgDurationMs": 200000, "avgTurns": 11.5, "graded": { "count": 24, "avgScorePercent": 72.5, "passed": 17, "failed": 7 }, "daily": [ { "date": "2026-07-13" } ]}Bad request - validation failed
Media typeapplication/json
object
error
required
string
details
Array<string>
Example
{ "error": "Resource not found", "details": [ "Field is required" ]}Unauthorized - missing or invalid auth
Media typeapplication/json
object
error
required
string
details
Array<string>
Example
{ "error": "Resource not found", "details": [ "Field is required" ]}Resource not found
Media typeapplication/json
object
error
required
string
details
Array<string>
Example
{ "error": "Resource not found", "details": [ "Field is required" ]}