---
updatedAt: 2026-05-15T17:46:32.000Z
agentTools:
  projectIndex: https://docs.cast.ai/llms.txt
---

# List sessions.

Lists sessions for the organization.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "servers": [
    {
      "url": "https://api.cast.ai/",
      "description": "US endpoint"
    },
    {
      "url": "https://api.eu.cast.ai/",
      "description": "EU endpoint"
    }
  ],
  "info": {
    "title": "AI Enabler",
    "version": "0.0.1"
  },
  "security": [
    {
      "BearerAuth": []
    },
    {
      "ApiKeyAuth": []
    }
  ],
  "paths": {
    "/ai-optimizer/v1beta/organizations/{organizationId}/sessions": {
      "get": {
        "tags": [
          "SessionsAPI"
        ],
        "summary": "List sessions.",
        "description": "Lists sessions for the organization.",
        "operationId": "SessionsAPI_ListSessions",
        "parameters": [
          {
            "name": "organizationId",
            "in": "path",
            "description": "The ID of the organization.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "creatorId",
            "in": "query",
            "description": "Filter by creator ID.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page.limit",
            "in": "query",
            "description": "Defines the number of items that should be returned",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page.cursor",
            "in": "query",
            "description": "Cursor that defines token indicating where to start the next page.\n Empty value indicates to start from beginning of the dataset.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort.field",
            "in": "query",
            "description": "The field name to order by. Nested fields can be specified by using a dot (e.g. user.name).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort.order",
            "in": "query",
            "description": "The order of returned items. Default is ASC.",
            "schema": {
              "enum": [
                "ASC",
                "asc",
                "DESC",
                "desc"
              ],
              "type": "string",
              "format": "enum"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListSessionsResponse"
                }
              }
            }
          },
          "default": {
            "description": "Default error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "GoogleProtobufAny": {
        "type": "object",
        "properties": {
          "@type": {
            "type": "string",
            "description": "The type of the serialized message."
          }
        },
        "additionalProperties": true,
        "description": "Contains an arbitrary serialized message along with a @type that describes the type of the serialized message."
      },
      "ListSessionsResponse": {
        "required": [
          "items",
          "totalCount"
        ],
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Session"
            },
            "description": "The list of sessions."
          },
          "nextPageCursor": {
            "type": "string",
            "description": "The pagination cursor to retrieve the next page."
          },
          "totalCount": {
            "type": "integer",
            "description": "The total number of items.",
            "format": "int32"
          }
        },
        "description": "Response message for listing sessions."
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": {
            "readOnly": true,
            "type": "string",
            "description": "The ID of the session."
          },
          "organizationId": {
            "readOnly": true,
            "type": "string",
            "description": "The ID of the organization."
          },
          "creatorId": {
            "readOnly": true,
            "type": "string",
            "description": "The ID of the user who created the session."
          },
          "description": {
            "type": "string",
            "description": "The description of the session."
          },
          "status": {
            "readOnly": true,
            "enum": [
              "STATUS_UNSPECIFIED",
              "INITIALIZING",
              "ACTIVE",
              "SUSPENDED",
              "DELETING",
              "UNKNOWN"
            ],
            "type": "string",
            "description": "Status of the session.",
            "format": "enum"
          },
          "createTime": {
            "readOnly": true,
            "type": "string",
            "description": "The time when the session was created.",
            "format": "date-time"
          },
          "uri": {
            "readOnly": true,
            "type": "string",
            "description": "URI for accessing the session via websocket."
          },
          "options": {
            "writeOnly": true,
            "allOf": [
              {
                "$ref": "#/components/schemas/SessionOptions"
              }
            ],
            "description": "Session creation options. Only used during upsert; never returned."
          }
        },
        "description": "Session represents a session environment."
      },
      "SessionOptions": {
        "type": "object",
        "properties": {
          "agentApiKey": {
            "type": "string",
            "description": "API token for the agent running in the session."
          },
          "gitRepository": {
            "type": "string",
            "description": "Git repository URL to clone."
          },
          "gitBranch": {
            "type": "string",
            "description": "Git branch to checkout."
          },
          "gitToken": {
            "type": "string",
            "description": "Git authentication token."
          },
          "gitUsername": {
            "type": "string",
            "description": "Git username for authentication."
          },
          "gitPassword": {
            "type": "string",
            "description": "Git password for authentication."
          },
          "sshKey": {
            "type": "string",
            "description": "SSH private key for Git authentication."
          }
        },
        "description": "Configuration options passed to the session agent on creation."
      },
      "Status": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "description": "The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].",
            "format": "int32"
          },
          "message": {
            "type": "string",
            "description": "A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client."
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GoogleProtobufAny"
            },
            "description": "A list of messages that carry the error details.  There is a common set of message types for APIs to use."
          }
        },
        "description": "The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors)."
      }
    }
  },
  "tags": [
    {
      "name": "SessionsAPI",
      "description": "Provides the API for managing sessions."
    }
  ]
}
```