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

# Get conversation messages

> Retrieve messages for a specific conversation, including tool calls made by the assistant.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/ai/analytics.yml get /ai/conversations/{conversation_id}/messages
openapi: 3.1.0
info:
  title: Telnyx AI Analytics API
  version: 2.0.0
  description: API for AI conversations, insights, embeddings, and clusters.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /ai/conversations/{conversation_id}/messages:
    get:
      tags:
        - Conversations
      summary: Get conversation messages
      description: >-
        Retrieve messages for a specific conversation, including tool calls made
        by the assistant.
      operationId: get_conversations_public__conversation_id__messages_get
      parameters:
        - name: conversation_id
          in: path
          required: true
          schema:
            type: string
        - name: page[size]
          in: query
          description: The number of messages to return per page.
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 1
            default: 20
        - name: page[number]
          in: query
          description: The page number to retrieve.
          required: false
          schema:
            type: integer
            minimum: 1
            default: 1
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationMessageListData'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Telnyx from 'telnyx';


            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });


            // Automatically fetches more pages as needed.

            for await (const messageListResponse of
            client.ai.conversations.messages.list('conversation_id')) {
              console.log(messageListResponse.role);
            }
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            page = client.ai.conversations.messages.list(
                conversation_id="conversation_id",
            )
            page = page.data[0]
            print(page.role)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tpage, err := client.AI.Conversations.Messages.List(\n\t\tcontext.TODO(),\n\t\t\"conversation_id\",\n\t\ttelnyx.AIConversationMessageListParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", page)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.ai.conversations.messages.MessageListPage;

            import
            com.telnyx.sdk.models.ai.conversations.messages.MessageListParams;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    MessageListPage page = client.ai().conversations().messages().list("conversation_id");
                }
            }
        - lang: Ruby
          source: |-
            require "telnyx"

            telnyx = Telnyx::Client.new(api_key: "My API Key")

            page = telnyx.ai.conversations.messages.list("conversation_id")

            puts(page)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $page = $client->ai->conversations->messages->list(
                'conversation_id', pageNumber: 1, pageSize: 1
              );

              var_dump($page);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx ai:conversations:messages list \
              --api-key 'My API Key' \
              --conversation-id conversation_id
components:
  schemas:
    ConversationMessageListData:
      properties:
        data:
          items:
            $ref: '#/components/schemas/ConversationMessage'
          type: array
          title: Data
        meta:
          $ref: '#/components/schemas/Meta'
      type: object
      required:
        - data
        - meta
      title: ConversationMessageListData
    HTTPValidationError:
      title: HTTPValidationError
      type: object
      properties:
        detail:
          title: Detail
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
    ConversationMessage:
      type: object
      required:
        - role
        - text
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
            - tool
          description: The role of the message sender.
        text:
          type: string
          description: The message content. Can be null for tool calls.
        tool_calls:
          type: array
          description: Optional tool calls made by the assistant.
          items:
            type: object
            properties:
              id:
                type: string
                description: Unique identifier for the tool call.
              type:
                type: string
                enum:
                  - function
                description: Type of the tool call.
              function:
                type: object
                properties:
                  name:
                    type: string
                    description: Name of the function to call.
                  arguments:
                    type: string
                    description: JSON-formatted arguments to pass to the function.
                required:
                  - name
                  - arguments
            required:
              - id
              - type
              - function
        created_at:
          type: string
          description: >-
            The datetime the message was created on the conversation. This does
            not necesarily correspond to the time the message was sent. The best
            field to use to determine the time the end user experienced the
            message is `sent_at`.
          format: date-time
          example: '2025-04-15T13:07:28.764Z'
        sent_at:
          type: string
          description: The datetime the message was sent to the end user.
          format: date-time
          example: '2025-04-15T13:07:28.764Z'
    Meta:
      properties:
        total_pages:
          type: integer
        total_results:
          type: integer
        page_number:
          type: integer
        page_size:
          type: integer
      type: object
      required:
        - total_pages
        - total_results
        - page_number
        - page_size
      title: Meta
    ValidationError:
      title: ValidationError
      required:
        - loc
        - msg
        - type
      type: object
      properties:
        loc:
          title: Location
          type: array
          items:
            anyOf:
              - type: string
              - type: integer
        msg:
          title: Message
          type: string
        type:
          title: Error Type
          type: string
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````