Skip to content
Skip to Content
Coder Docs

Upload a file to a chat's workspace

POST
/api/v2/chats/{chat}/workspace-files

Streams the request body into the chat workspace's upload directory. The request Content-Type header is recorded as the file's media type. There is no server-imposed size cap; client cancellation aborts the stream and the agent leaves no partial target file behind.

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Path Parameters

chat*string

Chat ID

Formatuuid

Header Parameters

Content-Disposition*string

Filename of the file (attachment; filename=...)

Request Body

Raw file binary data

body*string*/*

Response Body

Created

application/json
  1. response
media_type?string

MediaType is the client-declared content type for display.

name?string

Name is the final basename of the uploaded file.

path?string

Path is the absolute path of the file on the workspace.

size?integer

Size is the number of bytes written to the workspace.

workspace_id?string

WorkspaceID is the workspace whose filesystem received the bytes. Message parts referencing this upload must carry it.

Formatuuid

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

curl -X POST \	"$CODER_URL/api/v2/chats/{chat}/workspace-files" \	-H "Coder-Session-Token: $CODER_SESSION_TOKEN" \	-H "Content-Disposition: {Content-Disposition}" \	-H "Content-Type: */*" \	--data-binary "@{file}"
Example Response
{  "media_type": "string",  "name": "string",  "path": "string",  "size": 0,  "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9"}