Create chat
CoderSessionTokenCoder-Session-Token<token>Create chat request
application/json- body
client_type?codersdk.ChatClientType"ui""api"content?array<>Content is the initial user message. It is optional: when empty, the chat is created idle with no initial user message and generation starts with the first message POSTed to /chats/{chat}/messages.
inline_mcp_servers?array<>InlineMCPServers declares MCP servers by value on this chat, next to the org-configured servers selected by MCPServerIDs. Experimental.
labels?mcp_server_ids?array<>model_config_id?stringuuidorganization_id?stringuuidowner_id?stringOwnerID makes another user the chat owner. It defaults to the caller. The chat runs with the owner's credentials, so setting it requires site-wide authority over that user.
uuidplan_mode?"plan""plan"project_id?stringuuidreasoning_effort?stringsystem_prompt?stringtitle?stringTitle, when set, is stored as the user title and automatic title generation does not run. It is trimmed and must then be non-empty and at most 200 Unicode code points (MaxChatTitleRunes), else the request fails with 400. When omitted, the title is derived from the first prompt and may later be replaced by a generated title.
unsafe_dynamic_tools?array<>UnsafeDynamicTools declares client-executed tools that the LLM can invoke. This API is highly experimental and highly subject to change.
workspace_id?stringuuidCreated
application/json- response
agent_id?stringuuidarchived?booleanbuild_id?stringuuidchildren?array<>Children holds child (subagent) chats nested under this root chat. Always initialized to an empty slice so the JSON field is present as []. Child chats cannot create their own subagents, so nesting depth is capped at 1 and this slice is always empty for child chats.
client_type?codersdk.ChatClientType"ui""api"context?Context reports the chat's pinned workspace-context state and whether it has drifted from the agent's latest pushed snapshot. Nil when the chat has no pinned context yet.
created_at?stringdate-timediff_status?DiffStatus is the primary pull request. It is the ref with the most recent git report.
diff_statuses?array<>DiffStatuses lists every ref the chat tracks. The order is stable and follows the first report of each ref. DiffStatus marks the primary.
files?array<>has_unread?booleanHasUnread is true when assistant messages exist beyond the owner's read cursor, which updates on stream connect and disconnect and via UpdateChatRequest.Read.
id?stringuuidinline_mcp_servers?array<>InlineMCPServers lists the inline MCP servers declared on the chat, without headers. Only the single-chat GET sets it. Experimental.
labels?last_error?last_model_config_id?stringuuidlast_reasoning_effort?stringlast_turn_summary?stringmcp_server_ids?array<>organization_id?stringuuidowner_id?stringuuidowner_name?stringowner_username?stringparent_chat_id?stringuuidpin_order?integerplan_mode?"plan""plan"project_id?stringuuidqueued_for_capacity?booleanQueuedForCapacity reports that the chat is waiting for a concurrent agent slot. Single-chat reads derive it; list responses leave it false.
root_chat_id?stringuuidshared?booleanShared is true when this chat's root chat has explicit user or group ACL entries.
status?codersdk.ChatStatus"waiting""running""error""requires_action""interrupting"summary?stringSummary is the persisted whole-chat summary, generated in the background. It is nil until the first summary has been produced.
title?stringtitle_source?stringTitleSource is where Title came from. A title write applies only when the current source ranks the same as or lower than the incoming one, in the order fallback, generated, user.
"fallback""generated""user"title_updated_at?stringTitleUpdatedAt orders title changes. Title writes do not change UpdatedAt.
date-timeupdated_at?stringdate-timewarnings?array<string>workspace_id?stringuuidThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/chats" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "client_type": "ui", "content": [ { "content": "string", "end_line": 0, "file_id": "8a0cfb4f-ddc9-436d-91bb-75133c583767", "file_name": "string", "skill_name": "string", "skill_source": "personal", "start_line": 0, "text": "string", "type": "text", "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" } ], "inline_mcp_servers": [ { "allow_in_subagents": true, "forward_coder_headers": true, "headers": { "property1": "string", "property2": "string" }, "slug": "string", "tool_allow_list": [ "string" ], "tool_deny_list": [ "string" ], "url": "string" } ]}'{ "agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978", "archived": true, "build_id": "bfb1f3fa-bf7b-43a5-9e0b-26cc050e44cb", "children": [ {} ], "client_type": "ui", "context": { "dirty": true, "dirty_since": "2019-08-24T14:15:22Z", "error": "string", "resources": [ { "error": "string", "kind": "instruction_file", "size_bytes": 0, "skill_description": "string", "skill_name": "string", "source": "string", "source_path": "string", "status": "ok", "tools": [ { "description": "string", "name": "string" } ] } ] }, "created_at": "2019-08-24T14:15:22Z", "diff_status": { "additions": 0, "approved": true, "author_avatar_url": "string", "author_login": "string", "base_branch": "string", "changed_files": 0, "changes_requested": true, "chat_id": "efc9fe20-a1e5-4a8c-9c48-f1b30c1e4f86", "commits": 0, "deletions": 0, "git_branch": "string", "head_branch": "string", "pr_number": 0, "pull_request_draft": true, "pull_request_state": "string", "pull_request_title": "string", "refreshed_at": "2019-08-24T14:15:22Z", "remote_origin": "string", "reviewer_count": 0, "stale_at": "2019-08-24T14:15:22Z", "url": "string" }, "diff_statuses": [ { "additions": 0, "approved": true, "author_avatar_url": "string", "author_login": "string", "base_branch": "string", "changed_files": 0, "changes_requested": true, "chat_id": "efc9fe20-a1e5-4a8c-9c48-f1b30c1e4f86", "commits": 0, "deletions": 0, "git_branch": "string", "head_branch": "string", "pr_number": 0, "pull_request_draft": true, "pull_request_state": "string", "pull_request_title": "string", "refreshed_at": "2019-08-24T14:15:22Z", "remote_origin": "string", "reviewer_count": 0, "stale_at": "2019-08-24T14:15:22Z", "url": "string" } ], "files": [ { "created_at": "2019-08-24T14:15:22Z", "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "mime_type": "string", "name": "string", "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "size_bytes": 0 } ], "has_unread": true, "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "inline_mcp_servers": [ { "allow_in_subagents": true, "created_at": "2019-08-24T14:15:22Z", "forward_coder_headers": true, "has_custom_headers": true, "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "slug": "string", "tool_allow_list": [ "string" ], "tool_deny_list": [ "string" ], "updated_at": "2019-08-24T14:15:22Z", "url": "string" } ], "labels": { "property1": "string", "property2": "string" }, "last_error": { "detail": "string", "kind": "generic", "message": "string", "provider": "string", "retryable": true, "status_code": 0 }, "last_model_config_id": "30ebb95f-c255-4759-9429-89aa4ec1554c", "last_reasoning_effort": "string", "last_turn_summary": "string", "mcp_server_ids": [ "6645753c-0a13-4667-8dd3-d80a8e4fd76f" ], "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05", "owner_name": "string", "owner_username": "string", "parent_chat_id": "c3609ee6-3b11-4a93-b9ae-e4fabcc99359", "pin_order": 0, "plan_mode": "plan", "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", "queued_for_capacity": true, "root_chat_id": "2898031c-fdce-4e3e-8c53-4481dd42fcd7", "shared": true, "status": "waiting", "summary": "string", "title": "string", "title_source": "fallback", "title_updated_at": "2019-08-24T14:15:22Z", "updated_at": "2019-08-24T14:15:22Z", "warnings": [ "string" ], "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9"}