> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentscope.io/llms.txt
> Use this file to discover all available pages before exploring further.

# List messages for a session

> Return persisted messages for a session.

Args:
    session_id: The session to query.
    agent_id: Agent the session belongs to.
    offset: Pagination offset.
    limit: Maximum number of messages to return.
    user_id: Injected authenticated user ID.
    storage: Injected storage backend.
    message_bus: Injected message bus.

Returns:
    Messages and running status.



## OpenAPI

````yaml /versions/2.0.2/en/deploy/openapi.json get /sessions/{session_id}/messages
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.1
servers: []
security: []
paths:
  /sessions/{session_id}/messages:
    get:
      tags:
        - sessions
      summary: List messages for a session
      description: |-
        Return persisted messages for a session.

        Args:
            session_id: The session to query.
            agent_id: Agent the session belongs to.
            offset: Pagination offset.
            limit: Maximum number of messages to return.
            user_id: Injected authenticated user ID.
            storage: Injected storage backend.
            message_bus: Injected message bus.

        Returns:
            Messages and running status.
      operationId: list_messages_sessions__session_id__messages_get
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
        - name: agent_id
          in: query
          required: true
          schema:
            type: string
            description: Agent the session belongs to.
            title: Agent Id
          description: Agent the session belongs to.
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            description: Pagination offset.
            default: 0
            title: Offset
          description: Pagination offset.
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 200
            minimum: 1
            description: Max messages.
            default: 50
            title: Limit
          description: Max messages.
        - name: x-user-id
          in: header
          required: true
          schema:
            type: string
            description: >-
              Caller's user ID. Temporary header-based identity; will be
              replaced by JWT auth.
            title: X-User-Id
          description: >-
            Caller's user ID. Temporary header-based identity; will be replaced
            by JWT auth.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ListMessagesResponse'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ListMessagesResponse:
      properties:
        messages:
          items: {}
          type: array
          title: Messages
          description: Messages in chronological order.
        is_running:
          type: boolean
          title: Is Running
          description: Whether the session is currently running.
      type: object
      required:
        - messages
        - is_running
      title: ListMessagesResponse
      description: Response body for listing messages in a session.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````