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

# Retrieve Messages

> Get all messages associated to the path sessionId



## OpenAPI

````yaml get /{resourceSlug}/session/{sessionId}/messages.json?messageId={messageId}
openapi: 3.0.0
info:
  title: Agentcloud Webapp API Docs
  description: The API docs for Agentcloud's webapp.
  version: 0.2.1
servers:
  - url: https://app.agentcloud.dev
    description: Use our public api endpoints!
  - url: '{custom_url}'
    description: Test the endpoints on your own instance of Agent Cloud!
    variables:
      custom_url:
        default: https://app.agentcloud.dev
security: []
tags: []
paths:
  /{resourceSlug}/session/{sessionId}/messages.json?messageId={messageId}:
    get:
      tags:
        - Sessions
      summary: Retrieve Messages
      description: Get all messages associated to the path sessionId
      operationId: sessionMessagesJson
      parameters:
        - name: resourceSlug
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/ObjectId'
          description: >-
            The resourceSlug is a url parameter of the teamId associated with
            the user. Anywhere the resourceSlug is used can be interpreted as a
            teamId
        - name: sessionId
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/ObjectId'
          description: The sessionId of the session to retrieve
        - name: messageId
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/ObjectId'
          description: >-
            Optional query parameter to declare a messageId to get messages
            generated after. i.e. get all messages generated after message:
            {messageId}. This is useful when attempting to gather messages in a
            stream.
      responses:
        '200':
          description: >-
            JSON object containing array of all associated messages from this
            session, will return an empty array if the request is successful but
            there are no associated agents.
          content:
            messages.json:
              schema:
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/ChatMessage'
        '201':
          description: >-
            Response only when messageId used, JSON object containing array of
            all message objects generated after messageId query if messageId is
            used.
          content:
            messages.json:
              schema:
                properties:
                  messages:
                    type: array
                    items:
                      $ref: '#/components/schemas/ChatMessage'
                    description: Array of all message objects generated after messageId
        '400':
          description: Error in validation, check error message for more information
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
        '403':
          description: >-
            Invalid permissions on the resourceSlug, attempting to access an
            agent outside the permissions of the team
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
        '500':
          description: Internal error
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
components:
  schemas:
    ObjectId:
      description: >-
        Mongodb Object id, unique identifier, length of 24 characters fitting
        the following regex; [a-f0-9]{24}
      type: string
    ChatMessage:
      description: >-
        A message used within a session, can be either an AI generated message
        or a user generated message.
      required:
        - orgId
        - teamId
        - sessionId
        - message
        - ts
        - authorId
        - isFeedback
        - displayType
        - authorName
      properties:
        _id:
          $ref: '#/components/schemas/ObjectId'
        orgId:
          $ref: '#/components/schemas/ObjectId'
          description: >-
            The id of the organisation that the session belongs to (usually the
            teamId of the corresponding app object).
        teamId:
          $ref: '#/components/schemas/ObjectId'
          description: >-
            The id object of the team the session belongs to (usually the teamId
            of the corresponding app object the session stems from).
        sessionId:
          $ref: '#/components/schemas/ObjectId'
          description: The id of the session object the message exists within
        chunkId:
          type: string
          description: >-
            Unique identifier for the chunk associated with this message, leave
            blank.
        message:
          type: object
          description: Can be of any type, the message content
        ts:
          type: integer
          description: UNIX timestamp, equivelant to Date.now() of message creation
        authorId:
          $ref: '#/components/schemas/ObjectId'
          description: >-
            If the message is sent by an agent, this is set to null, if sent by
            a user then it is set to the accountId
        isFeedback:
          type: boolean
          description: >-
            Set by the agent, when set to 'trye' the agent is expecting human
            input
        displayType:
          type: string
          enum:
            - bubble
            - inline
          description: The display type of the message, only used in front end
        authorName:
          type: string
          description: >-
            The name of the message author, if sent by an agent then set to the
            agent's name otherwise set to account name
        tokens:
          type: integer
          description: Tokens used in this message
        chunks:
          type: array
          items:
            properties:
              ts:
                type: integer
                description: Timestamp
              chunk:
                type: string
                description: Chunk content
              tokens:
                type: integer
                description: Tokens used in this chunk
        codeBlocks:
          type: array
          items:
            properties:
              language:
                type: string
                description: The language the code block is written in
              codeBlock:
                type: string
                description: Content of the code block
        completed:
          type: boolean
          description: Wether the message is completed or still generating
    dynamicResponse:
      description: Server response
      properties:
        message:
          type: string
          description: Error message to provide more detail
        code:
          type: integer
          description: the error code

````