# List sessions for an agent

`GET /agents/{agent_name}/endpoint/sessions`

Returns a paged collection of sessions associated with the specified agent endpoint.

## Parameters

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_name` | `string` | Yes | The name of the agent. |

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | `integer` | No | A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. _Default:_ `20` |
| `order` | `PageOrder` | No | Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` for descending order. _Enum:_ `asc`, `desc` |
| `after` | `string` | No | A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list. |
| `before` | `string` | No | A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list. |
| `api-version` | `string` | Yes | The API version to use for this operation. |

### Header parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Foundry-Features` | `enum` | No | A feature flag opt-in required when using preview operations or modifying persisted preview resources. _Constant:_ `AgentEndpoints=V1Preview` |
| `x-ms-user-isolation-key` | `string` | No | Opaque per-user isolation key used to scope endpoint-scoped data (responses, conversations, sessions) to a specific end user. |

## Responses

### 200 — The request has succeeded.

Content-Type: `application/json`

The response data for a requested list of items.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `data` | `AgentSessionResource[]` | Yes | The requested list of items. |
| `first_id` | `string` | No | The first ID represented in this list. |
| `last_id` | `string` | No | The last ID represented in this list. |
| `has_more` | `boolean` | Yes | A value indicating whether there are additional values available not captured in this list. |

#### `data` — `AgentSessionResource[]`

The requested list of items.

**Array of** `AgentSessionResource`**:**

An agent session providing a long-lived compute sandbox for hosted agent invocations.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `agent_session_id` | `string` | Yes | The session identifier. |
| `version_indicator` | `VersionRefIndicator` | Yes | The version indicator determining which agent version backs this session. |
| `status` | `enum` | Yes | The current status of the session. _Enum:_ `creating`, `active`, `idle`, `updating`, `failed`, `deleting`, `deleted`, `expired` |
| `created_at` | `integer` | Yes | The Unix timestamp (in seconds) when the session was created. _Format:_ `unixtime` |
| `last_accessed_at` | `integer` | Yes | The Unix timestamp (in seconds) when the session was last accessed. _Format:_ `unixtime` |
| `expires_at` | `integer` | Yes | The Unix timestamp (in seconds) when the session expires (rolling, 30 days from last activity). _Format:_ `unixtime` |

##### `version_indicator` — `VersionRefIndicator`

The version indicator determining which agent version backs this session.

**One of the following:**

###### `version_ref` — `version_ref (VersionRefIndicator)`

Version indicator that references a specific agent version by name.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `type` | `enum` | Yes | Discriminator value for version_ref. _Constant:_ `version_ref` |
| `agent_version` | `string` | Yes | The agent version identifier returned by the agent version APIs. |

### 4XX — Client error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |

### 5XX — Server error

Content-Type: `application/json`

Error response for API failures.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `error` | `OpenAI.Error` | Yes |  |

#### `error` — `OpenAI.Error`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | `string \| null` | Yes |  |
| `message` | `string` | Yes |  |
| `param` | `string \| null` | No |  |
| `type` | `string` | No |  |
| `details` | `OpenAI.Error[]` | No |  |
| `additionalInfo` | `object` | No |  |
| `debugInfo` | `object` | No |  |
