Upload chat file
POST
CoderSessionTokenheader
Coder-Session-Token<token>organization*stringOrganization ID
Format
uuidContent-Disposition*stringAttachment disposition carrying the file name
Raw file binary data
body*stringCreated
application/json- response
id?stringFormat
uuidThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/chats/files?organization={organization}" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Disposition: {Content-Disposition}" \ -H "Content-Type: application/json" \ -d '"string"'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/chats/files?organization={organization}`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Disposition": "{Content-Disposition}", "Content-Type": "application/json", }, body: JSON.stringify("string"),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/chats/files?organization={organization}"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, "Content-Disposition": "{Content-Disposition}", }, json="string",)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`"string"`) url := os.Getenv("CODER_URL") + "/api/v2/chats/files?organization={organization}" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) req.Header.Set("Content-Disposition", "{Content-Disposition}") req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response
{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"}