Files
coder/docs/reference/api/chats.md
T
Mathias Fredriksson a104d608a3 feat: add file/image attachment support to chat input (#22604)
This change adds support for image attachments to chat via add button
and clipboard paste. Files are stored in a new `chat_files` table and
referenced by ID in message content. File data is resolved from storage
at LLM dispatch time, keeping the message content column small.

Upload validates MIME types via content type or content sniffing against
an allowlist (png, jpeg, gif, webp). The retrieval endpoint serves files
with immutable caching headers. On the frontend, uploads start eagerly
on attach with a background fetch to pre-warm the browser HTTP cache so
the timeline renders instantly after send.
2026-03-06 21:05:26 +02:00

5.9 KiB
Generated

Chats

Upload a chat file

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/chats/files?organization=497f6eca-6276-4993-bfeb-53cbbbba6f08 \
  -H 'Accept: application/json' \
  -H 'Content-Type: string' \
  -H 'Coder-Session-Token: API_KEY'

POST /chats/files

Parameters

Name In Type Required Description
Content-Type header string true Content-Type must be an image type (image/png, image/jpeg, image/gif, image/webp)
organization query string(uuid) true Organization ID

Example responses

201 Response

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.UploadChatFileResponse
400 Bad Request Bad Request codersdk.Response
401 Unauthorized Unauthorized codersdk.Response
413 Payload Too Large Request Entity Too Large codersdk.Response
500 Internal Server Error Internal Server Error codersdk.Response

To perform this operation, you must be authenticated. Learn more.

Get a chat file

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/chats/files/{file} \
  -H 'Accept: */*' \
  -H 'Coder-Session-Token: API_KEY'

GET /chats/files/{file}

Parameters

Name In Type Required Description
file path string(uuid) true File ID

Example responses

400 Response

Responses

Status Meaning Description Schema
200 OK OK
400 Bad Request Bad Request codersdk.Response
401 Unauthorized Unauthorized codersdk.Response
404 Not Found Not Found codersdk.Response
500 Internal Server Error Internal Server Error codersdk.Response

To perform this operation, you must be authenticated. Learn more.

Archive a chat

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/chats/{chat}/archive

POST /chats/{chat}/archive

Responses

Status Meaning Description Schema
204 No Content No Content

Watch git changes for a chat

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/chats/{chat}/git/watch \
  -H 'Coder-Session-Token: API_KEY'

GET /chats/{chat}/git/watch

Parameters

Name In Type Required Description
chat path string(uuid) true Chat ID

Responses

Status Meaning Description Schema
101 Switching Protocols Switching Protocols

To perform this operation, you must be authenticated. Learn more.

Unarchive a chat

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/chats/{chat}/unarchive

POST /chats/{chat}/unarchive

Responses

Status Meaning Description Schema
204 No Content No Content