Skip to content
Skip to Content
Coder Docs

Edit chat message

PATCH
/api/v2/chats/{chat}/messages/{message}

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

chat*string

Chat ID

Formatuuid
message*integer

Message ID

Request Body

Edit chat message request

application/json
  1. body
content?array<>
mcp_server_ids?array<>

MCPServerIDs, when set, replaces the chat's MCP server selection before the replacement turn runs. When nil the current selection is preserved.

model_config_id?string

ModelConfigID, when set, overrides the model used for the replacement user message and the assistant turn that follows. When nil the original message's model is preserved.

Formatuuid
reasoning_effort?string

Response Body

OK

application/json
  1. response
deleted_message_ids?array<integer>

DeletedMessageIDs holds the IDs of previously visible messages the edit removed, including stale hook notices from the edited turn. Clients should drop them from local caches.

message?
messages?array<>

Messages holds every user-visible message inserted by the edit, in insertion order. Hook-generated suffix messages may follow Message, so clients must upsert the full batch.

warnings?array<string>

The samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.

curl -X PATCH \	"$CODER_URL/api/v2/chats/{chat}/messages/{message}" \	-H "Coder-Session-Token: $CODER_SESSION_TOKEN" \	-H "Content-Type: application/json" \	-d '{  "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"    }  ],  "mcp_server_ids": [    "6645753c-0a13-4667-8dd3-d80a8e4fd76f"  ],  "model_config_id": "f5fb4d91-62ca-4377-9ee6-5d43ba00d205"}'
Example Response200
{  "deleted_message_ids": [    0  ],  "message": {    "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    }  },  "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      }    }  ],  "warnings": [    "string"  ]}