---
title: "Edit chat message"
method: PATCH
path: "/api/experimental/chats/{chat}/messages/{message}"
tags: ["Chats"]
---

# Edit chat message

`PATCH /api/experimental/chats/{chat}/messages/{message}`

Experimental: this endpoint is subject to change.

## Path parameters

- `chat` string, uuid, required
- `message` integer, required

## Request body

- CodersdkEditChatMessageRequest
  - `content` CodersdkChatInputPart[]
    - `content` string — The code content from the diff that was commented on.
    - `end_line` integer
    - `file_id` string, uuid
    - `file_name` string — The following fields are only set when Type is ChatInputPartTypeFileReference.
    - `start_line` integer
    - `text` string
    - `type` 'text' | 'file' | 'file-reference'
  - `model_config_id` string, uuid — 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.
  - `reasoning_effort` string

## Response `200`

OK

- CodersdkEditChatMessageResponse
  - `deleted_message_ids` 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` CodersdkChatMessage
    - `chat_id` string, uuid
    - `content` CodersdkChatMessagePart[]
      - `args` integer[]
      - `args_delta` string
      - `completed_at` string, date-time — CompletedAt is the time a reasoning part finished streaming, so reasoning duration can be computed as completed_at minus created_at. For interrupted reasoning, this is the interruption time. Absent when reasoning timestamp data was not recorded (e.g. messages persisted before this feature was added).
      - `content` string — The code content from the diff that was commented on.
      - `context_file_agent_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `context_file_content` string — ContextFileContent holds the file content sent to the LLM. Internal only: stripped before API responses to keep payloads small. The backend reads it when building the prompt via partsToMessageParts.
      - `context_file_directory` string — ContextFileDirectory is the working directory of the workspace agent. Internal only: same purpose as ContextFileOS.
      - `context_file_os` string — ContextFileOS is the operating system of the workspace agent. Internal only: used during prompt expansion so the LLM knows the OS even on turns where InsertSystem is not called.
      - `context_file_path` string — ContextFilePath is the absolute path of a file loaded into the LLM context (e.g. an AGENTS.md instruction file).
      - `context_file_skill_meta_file` string — ContextFileSkillMetaFile is the basename of the skill meta file (e.g. "SKILL.md") at the time of persistence. Internal only: restored on subsequent turns so the read_skill tool uses the correct filename even when the agent configured a non-default value.
      - `context_file_truncated` boolean — ContextFileTruncated indicates the file exceeded the 64KiB instruction file limit and was truncated.
      - `created_at` string, date-time — CreatedAt is the timestamp this part carries. The semantics depend on the part type: for tool-call and tool-result parts it is the time the call was emitted or the result was produced (tool duration is the result's created_at minus the call's created_at); for reasoning parts it is the time reasoning started streaming.
      - `data` integer[]
      - `end_line` integer
      - `file_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `file_name` string
      - `hook_rewritten` boolean — HookRewritten indicates that a lifecycle hook replaced model-proposed tool input.
      - `is_error` boolean
      - `is_media` boolean
      - `mcp_server_config_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `media_type` string
      - `name` string
      - `parsed_commands` array[] — ParsedCommands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise.
        - string[]
      - `provider_executed` boolean — ProviderExecuted indicates the tool call was executed by the provider (e.g. Anthropic computer use).
      - `provider_metadata` integer[] — ProviderMetadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses.
      - `result` integer[]
      - `result_delta` string
      - `result_reset` boolean
      - `skill_description` string — SkillDescription is the short description from the skill's SKILL.md frontmatter.
      - `skill_dir` string — SkillDir is the absolute path to the skill directory inside the workspace filesystem. Internal only: used by read_skill/read_skill_file tools to locate skill files.
      - `skill_name` string — SkillName is the kebab-case name of a discovered skill from the workspace's .agents/skills/ directory.
      - `source_id` string
      - `start_line` integer
      - `text` string
      - `title` string
      - `tool_call_id` string
      - `tool_name` string
      - `type` 'text' | 'reasoning' | 'tool-call' | 'tool-result' | 'source' | 'file' | 'file-reference' | 'context-file' | 'skill' | 'hook-context' | 'hook-notice'
      - `url` string
    - `created_at` string, date-time
    - `created_by` string, uuid
    - `id` integer
    - `model_config_id` string, uuid
    - `role` 'system' | 'user' | 'assistant' | 'tool'
    - `usage` CodersdkChatMessageUsage
      - `cache_creation_tokens` integer
      - `cache_read_tokens` integer
      - `context_limit` integer
      - `input_tokens` integer
      - `output_tokens` integer
      - `reasoning_tokens` integer
      - `total_tokens` integer
  - `messages` CodersdkChatMessage[] — 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.
    - `chat_id` string, uuid
    - `content` CodersdkChatMessagePart[]
      - `args` integer[]
      - `args_delta` string
      - `completed_at` string, date-time — CompletedAt is the time a reasoning part finished streaming, so reasoning duration can be computed as completed_at minus created_at. For interrupted reasoning, this is the interruption time. Absent when reasoning timestamp data was not recorded (e.g. messages persisted before this feature was added).
      - `content` string — The code content from the diff that was commented on.
      - `context_file_agent_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `context_file_content` string — ContextFileContent holds the file content sent to the LLM. Internal only: stripped before API responses to keep payloads small. The backend reads it when building the prompt via partsToMessageParts.
      - `context_file_directory` string — ContextFileDirectory is the working directory of the workspace agent. Internal only: same purpose as ContextFileOS.
      - `context_file_os` string — ContextFileOS is the operating system of the workspace agent. Internal only: used during prompt expansion so the LLM knows the OS even on turns where InsertSystem is not called.
      - `context_file_path` string — ContextFilePath is the absolute path of a file loaded into the LLM context (e.g. an AGENTS.md instruction file).
      - `context_file_skill_meta_file` string — ContextFileSkillMetaFile is the basename of the skill meta file (e.g. "SKILL.md") at the time of persistence. Internal only: restored on subsequent turns so the read_skill tool uses the correct filename even when the agent configured a non-default value.
      - `context_file_truncated` boolean — ContextFileTruncated indicates the file exceeded the 64KiB instruction file limit and was truncated.
      - `created_at` string, date-time — CreatedAt is the timestamp this part carries. The semantics depend on the part type: for tool-call and tool-result parts it is the time the call was emitted or the result was produced (tool duration is the result's created_at minus the call's created_at); for reasoning parts it is the time reasoning started streaming.
      - `data` integer[]
      - `end_line` integer
      - `file_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `file_name` string
      - `hook_rewritten` boolean — HookRewritten indicates that a lifecycle hook replaced model-proposed tool input.
      - `is_error` boolean
      - `is_media` boolean
      - `mcp_server_config_id` UuidNullUUID
        - `uuid` string
        - `valid` boolean — Valid is true if UUID is not NULL
      - `media_type` string
      - `name` string
      - `parsed_commands` array[] — ParsedCommands holds parsed programs from an execute tool call's shell command, one entry per simple command in source order. Each entry is [program] or [program, arg] where arg is the first non-flag positional argument. Program names are normalized to their base name (e.g. /usr/bin/go becomes go). Only populated when ToolName is "execute" and the command parses successfully; nil otherwise.
        - string[]
      - `provider_executed` boolean — ProviderExecuted indicates the tool call was executed by the provider (e.g. Anthropic computer use).
      - `provider_metadata` integer[] — ProviderMetadata holds provider-specific response metadata (e.g. Anthropic cache control hints) as raw JSON. Internal only: stripped by db2sdk before API responses.
      - `result` integer[]
      - `result_delta` string
      - `result_reset` boolean
      - `skill_description` string — SkillDescription is the short description from the skill's SKILL.md frontmatter.
      - `skill_dir` string — SkillDir is the absolute path to the skill directory inside the workspace filesystem. Internal only: used by read_skill/read_skill_file tools to locate skill files.
      - `skill_name` string — SkillName is the kebab-case name of a discovered skill from the workspace's .agents/skills/ directory.
      - `source_id` string
      - `start_line` integer
      - `text` string
      - `title` string
      - `tool_call_id` string
      - `tool_name` string
      - `type` 'text' | 'reasoning' | 'tool-call' | 'tool-result' | 'source' | 'file' | 'file-reference' | 'context-file' | 'skill' | 'hook-context' | 'hook-notice'
      - `url` string
    - `created_at` string, date-time
    - `created_by` string, uuid
    - `id` integer
    - `model_config_id` string, uuid
    - `role` 'system' | 'user' | 'assistant' | 'tool'
    - `usage` CodersdkChatMessageUsage
      - `cache_creation_tokens` integer
      - `cache_read_tokens` integer
      - `context_limit` integer
      - `input_tokens` integer
      - `output_tokens` integer
      - `reasoning_tokens` integer
      - `total_tokens` integer
  - `warnings` string[]

---

[API](https://skmtc.net/coder/apis/coder-api.md) · [All operations](https://skmtc.net/coder/apis/coder-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/coder/coder-api/versions/56b6e9f08540/schema)
