From 8b7885f2b6de151e59750cc1968d9a874322f736 Mon Sep 17 00:00:00 2001 From: Daniel Tenner Date: Tue, 14 Apr 2026 15:14:58 +0200 Subject: [PATCH] Add GET /api/v1/conversations/:id/messages endpoint Convenience endpoint that returns the conversation transcript (same data as the conversation show endpoint's transcript field). Useful for clients that only need messages without the full conversation metadata. Co-Authored-By: Claude Opus 4.6 --- app/controllers/api/v1/messages_controller.rb | 8 +++++ config/routes.rb | 2 +- public/ai/api.md | 32 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) 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 ```