diff --git a/app/controllers/api/v1/messages_controller.rb b/app/controllers/api/v1/messages_controller.rb index 4368b054..286a8ee9 100644 --- a/app/controllers/api/v1/messages_controller.rb +++ b/app/controllers/api/v1/messages_controller.rb @@ -2,6 +2,14 @@ module Api module V1 class MessagesController < BaseController + def index + chat = current_api_account.chats.find(params[:conversation_id]) + + render json: { + messages: chat.transcript_for_api + } + end + def create chat = current_api_account.chats.find(params[:conversation_id]) diff --git a/config/routes.rb b/config/routes.rb index 072b86f8..4a6911dd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -101,7 +101,7 @@ namespace :v1 do resources :key_requests, only: [ :create, :show ] resources :conversations, only: [ :index, :show, :create ] do - resources :messages, only: :create + resources :messages, only: [ :index, :create ] resource :agent_trigger, only: :create resources :participants, only: :create end diff --git a/public/ai/api.md b/public/ai/api.md index 445b1d13..469addbe 100644 --- a/public/ai/api.md +++ b/public/ai/api.md @@ -219,6 +219,38 @@ Creates a new conversation. Include `agent_ids` to create a group chat with agen --- +### List Messages in Conversation + +``` +GET /api/v1/conversations/:id/messages +``` + +Returns the message transcript for a conversation. This is a convenience endpoint that returns the same transcript data as the conversation show endpoint. + +**Response:** +```json +{ + "messages": [ + { + "role": "user", + "content": "Let's plan the Q1 roadmap", + "author": "Daniel", + "timestamp": "2026-01-15T09:00:00Z" + }, + { + "role": "assistant", + "content": "I'd be happy to help...", + "author": "Research Assistant", + "timestamp": "2026-01-15T09:00:15Z" + } + ] +} +``` + +Note: Like the conversation show endpoint, this excludes images, thinking traces, and tool calls. + +--- + ### Post Message to Conversation ```