リファレンスHTTP APISessions

Count the sessions a list would return, per status

GET
/v1/sessions/counts

Counts, for each status, the sessions GET /v1/sessions would list with that status and the same relation and q when read to its last page; total is their sum. A session the caller cannot read is never counted. It changes nothing.

Scope: sessions:read (API key or cookie session).

Authorization

headerAuthorizationBearer <token>

For servers and scripts: an API key sent as an HTTP bearer token, Bearer <key>. It holds exactly the scopes it was issued with; a key issued before scopes existed holds none. It never needs the CSRF header, and it cannot manage agents, members, teams or API keys. Issue one in the web console under Settings → API keys; each operation names the scope it needs.

Scope: sessions:read

Query Parameters

relation?string

Narrows the sessions the caller can read, never widens them; omitted, all. started: the caller started it (for an API key, the key or the person who created it). shared: someone else's session shared with the caller by name or through a team the caller is a member of; sessions every workspace member sees appear only under all. administered: a session of an agent the caller administers, directly or through a team.

Value in"all""started""shared""administered"
q?string

Matches a session whose title contains it, ignoring case, or whose id starts with it.

Length1 <= length <= 200

Response Body

The number of sessions per status.

application/json
  1. response
counts*

For each status, how many items GET /v1/sessions would list with that status and the same relation and q, read to the last page.

total*integer
Range0 <= value <= 9007199254740991
Example Request
curl -X GET 'https://example.com/v1/sessions/counts'
Example Response
{  "counts": {    "queued": 0,    "running": 2,    "needs_input": 1,    "idle": 5,    "failed": 1,    "stopped": 3  },  "total": 12}