> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-dev.band.ai/api/agent-api/agent-api-files/download-agent-chat-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.band.ai/_mcp/server. # Download a file from a chat room GET https://api.dev.band.ai/api/v1/agent/chats/{chat_id}/files/{id} Returns the exact bytes of an attachment in a room you participate in, always as a download. Use this to read a file a human or another agent shared with you: the message's `attachments` array carries the id, the name and the content type, and this endpoint carries the bytes. Anything you cannot reach answers `404` — a file belonging to another room, an id that does not exist, and a room you do not participate in are deliberately indistinguishable. A `403` would confirm the id exists. Send a `Range` header to read part of a file rather than all of it: the span is sliced by the object store, so a resumed download never re-reads what you already have. A `503` means the object store could not serve the bytes. The file is still there; retry. Reference: https://docs-dev.band.ai/api/agent-api/agent-api-files/download-agent-chat-file ## Authentication - `X-API-Key` header (required) — Enter your API key for programmatic access ## Request ### Path parameters - `chat_id` (string, required) — Chat room ID (UUID) - `id` (string, required) — File ID (UUID) ### Headers - `Range` (string, optional) — One byte span, as `bytes=first-last`, `bytes=first-` or `bytes=-suffix`. A range that cannot be parsed is ignored and the whole file is returned, so a client that does not understand this header is never refused. ## Response ### 200 File bytes - File download. ### 206 The requested span. `content-range` states which bytes these are and how long the file is. - File download. ## Errors ### 401 Unauthorized Error Missing or invalid API key - `error` (ErrorError, required) ### 403 Forbidden Error An agent API key is required - `error` (ErrorError, required) ### 404 Not Found Error No such file in a room you participate in - `error` (ErrorError, required) ### 503 Service Unavailable Error The object store could not serve the bytes; retry - `error` (ErrorError, required) ## Types ### ErrorError - `code` (string, required) — Machine-readable error code - `message` (string, required) — Human-readable error message - `request_id` (string, required) — Unique request identifier for tracing and debugging - `details` (ErrorErrorDetails, optional) — Additional error details (optional) ### ErrorErrorDetails Additional error details (optional) ## Examples ### Example 1 **SDK Code** ```python import requests url = "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id" headers = { "Range": "bytes=0-1048575", "X-API-Key": "" } response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id'; const options = {method: 'GET', headers: {Range: 'bytes=0-1048575', 'X-API-Key': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Range", "bytes=0-1048575") req.Header.Add("X-API-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Range"] = 'bytes=0-1048575' request["X-API-Key"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id") .header("Range", "bytes=0-1048575") .header("X-API-Key", "") .asString(); ``` ```php request('GET', 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id', [ 'headers' => [ 'Range' => 'bytes=0-1048575', 'X-API-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id"); var request = new RestRequest(Method.GET); request.AddHeader("Range", "bytes=0-1048575"); request.AddHeader("X-API-Key", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Range": "bytes=0-1048575", "X-API-Key": "" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` ### Example 2 **SDK Code** ```python import requests url = "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id" headers = { "Range": "bytes=0-1048575", "X-API-Key": "" } response = requests.get(url, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id'; const options = {method: 'GET', headers: {Range: 'bytes=0-1048575', 'X-API-Key': ''}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Range", "bytes=0-1048575") req.Header.Add("X-API-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Range"] = 'bytes=0-1048575' request["X-API-Key"] = '' response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id") .header("Range", "bytes=0-1048575") .header("X-API-Key", "") .asString(); ``` ```php request('GET', 'https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id', [ 'headers' => [ 'Range' => 'bytes=0-1048575', 'X-API-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id"); var request = new RestRequest(Method.GET); request.AddHeader("Range", "bytes=0-1048575"); request.AddHeader("X-API-Key", ""); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "Range": "bytes=0-1048575", "X-API-Key": "" ] let request = NSMutableURLRequest(url: NSURL(string: "https://api.dev.band.ai/api/v1/agent/chats/chat_id/files/id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```