List chat messages
GET
CoderSessionTokenheader
Coder-Session-Token<token>chat*stringChat ID
Format
uuidbefore_id?integerReturn messages with id < before_id
after_id?integerReturn messages with id > after_id
limit?integerPage size, 1 to 200. Defaults to 50.
OK
application/json- response
has_more?booleanmessages?array<>queued_messages?array<>turn_start_id?integerTurnStartID is the ID of the user prompt that starts the turn containing the page's oldest message. Omitted for after_id-only polls and when no prompt is at or before that message.
The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X GET \ "$CODER_URL/api/v2/chats/{chat}/messages" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN"const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/chats/{chat}/messages`;const response = await fetch(url, { method: "GET", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, },});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/chats/{chat}/messages"token = os.environ["CODER_SESSION_TOKEN"]response = requests.get( url, headers={ "Coder-Session-Token": token, },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os")func main() { url := os.Getenv("CODER_URL") + "/api/v2/chats/{chat}/messages" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response200
{ "has_more": true, "messages": [ { "chat_id": "efc9fe20-a1e5-4a8c-9c48-f1b30c1e4f86", "content": [ { "args": [ 0 ], "args_delta": "string", "completed_at": "2019-08-24T14:15:22Z", "content": "string", "context_file_agent_id": "2e577c68-2ec9-4c84-a77a-5b3e1d7eae09", "context_file_content": "string", "context_file_directory": "string", "context_file_os": "string", "context_file_path": "string", "context_file_skill_meta_file": "string", "context_file_truncated": true, "created_at": "2019-08-24T14:15:22Z", "data": [ 0 ], "end_line": 0, "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "file_name": "string", "hook_rewritten": true, "is_error": true, "is_media": true, "mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e", "media_type": "string", "name": "string", "narration": true, "parsed_commands": [ [ "string" ] ], "provider_executed": true, "provider_metadata": [ 0 ], "reasoning_delta": "string", "result": [ 0 ], "result_delta": "string", "result_reset": true, "skill_description": "string", "skill_dir": "string", "skill_name": "string", "skill_source": "personal", "source_id": "string", "start_line": 0, "text": "string", "title": "string", "tool_call_id": "string", "tool_name": "string", "type": "text", "url": "string", "workspace_file_media_type": "string", "workspace_file_name": "string", "workspace_file_path": "string", "workspace_file_size": 0, "workspace_file_workspace_id": "74c05446-1c56-4543-82a9-03f2bf73b2ab" } ], "created_at": "2019-08-24T14:15:22Z", "created_by": "ee824cad-d7a6-4f48-87dc-e8461a9201c4", "id": 0, "model_config_id": "f5fb4d91-62ca-4377-9ee6-5d43ba00d205", "queued_message_id": 0, "role": "system", "usage": { "cache_creation_tokens": 0, "cache_read_tokens": 0, "context_limit": 0, "input_tokens": 0, "output_tokens": 0, "reasoning_tokens": 0, "total_tokens": 0 } } ], "queued_messages": [ { "chat_id": "efc9fe20-a1e5-4a8c-9c48-f1b30c1e4f86", "content": [ { "args": [ 0 ], "args_delta": "string", "completed_at": "2019-08-24T14:15:22Z", "content": "string", "context_file_agent_id": "2e577c68-2ec9-4c84-a77a-5b3e1d7eae09", "context_file_content": "string", "context_file_directory": "string", "context_file_os": "string", "context_file_path": "string", "context_file_skill_meta_file": "string", "context_file_truncated": true, "created_at": "2019-08-24T14:15:22Z", "data": [ 0 ], "end_line": 0, "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "file_name": "string", "hook_rewritten": true, "is_error": true, "is_media": true, "mcp_server_config_id": "a9f436ed-69e7-459c-8308-a67ff5387e3e", "media_type": "string", "name": "string", "narration": true, "parsed_commands": [ [ "string" ] ], "provider_executed": true, "provider_metadata": [ 0 ], "reasoning_delta": "string", "result": [ 0 ], "result_delta": "string", "result_reset": true, "skill_description": "string", "skill_dir": "string", "skill_name": "string", "skill_source": "personal", "source_id": "string", "start_line": 0, "text": "string", "title": "string", "tool_call_id": "string", "tool_name": "string", "type": "text", "url": "string", "workspace_file_media_type": "string", "workspace_file_name": "string", "workspace_file_path": "string", "workspace_file_size": 0, "workspace_file_workspace_id": "74c05446-1c56-4543-82a9-03f2bf73b2ab" } ], "created_at": "2019-08-24T14:15:22Z", "id": 0, "model_config_id": "f5fb4d91-62ca-4377-9ee6-5d43ba00d205" } ], "turn_start_id": 0}