> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.privategpt.dev/api-reference/files/put-file-v-1-files-file-id-put/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.privategpt.dev/_mcp/server. # Put a file at a specific path (object-storage style) PUT /v1/files/{file_id} Content-Type: application/json S3/blob-style put-object: store the raw request body at the given key. The key is relative to the session's uploads mount (`/mnt/user-data/uploads/` inside the sandbox) and may be nested, e.g. `data/2024/report.pdf`; an explicit `uploads/` prefix is accepted and normalized away. Parent directories are created automatically and existing keys are overwritten. The response is the same `FileMetadata` as `POST /v1/files`, so the returned `id` can be used with the other file endpoints. Reference: https://docs.privategpt.dev/api-reference/files/put-file-v-1-files-file-id-put ## Request ### Path parameters - `file_id` (string, required) ### Query parameters - `scope_id` (string, required) — Session / container identifier. - `namespace` (string, optional, default: session) — Namespace for the file. Defaults to 'session'. ### Body (application/json) This endpoint expects a string. - `string` ## Response ### 200 Successful Response - `id` (string, required) — Relative path of the file within the session, e.g. 'uploads/data.csv' or 'outputs/result.png'. Use this value as `file_id` in subsequent requests. - `created_at` (datetime, required) — ISO-8601 timestamp when the file was created or last modified. - `filename` (string, required) — Filename derived from the path. - `mime_type` (string, required) — MIME type detected from the file content. - `size_bytes` (integer, required) — File size in bytes. - `downloadable` (boolean, required) — True for sandbox output files; False for uploaded input files. - `scope` (FileScope, required) — Session scope this file belongs to. - `type` ("file", optional, default: file) — Object type discriminator, always 'file'. - `etag` (string, optional, nullable) — Content checksum (MD5 hex or S3 ETag). Present after stat; None if unavailable. - `namespace` (string, optional, default: session) — Namespace this file belongs to (e.g. 'session', 'skills', or a custom namespace). ## Errors ### 400 Bad Request Error Invalid path key (absolute, `..`, or directory key). - `any` ### 401 Unauthorized Error Unauthorized - `any` ### 404 Not Found Error Namespace not found. - `any` ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) — detail field. ### 503 Service Unavailable Error Files API not configured (session namespace not set). - `any` ## Types ### FileScope Scope that a file belongs to (always a session). - `id` (string, required) — Session / container identifier that owns this file. - `type` (string, optional, default: session) — Namespace the file belongs to (e.g. 'session', 'skills', or a custom namespace). ### ValidationError ValidationError schema. - `loc` (list of ValidationErrorLocItems, required) — loc field. - `msg` (string, required) — msg field. - `type` (string, required) — type field. - `input` (any, optional) — input field. - `ctx` (ValidationErrorCtx, optional) — ctx field. ### ValidationErrorLocItems ### ValidationErrorCtx ctx field. ## Examples **Request** ```json "string" ``` **Response** ```json { "id": "uploads/data.csv", "created_at": "2024-01-15T10:30:00Z", "filename": "data.csv", "mime_type": "text/csv", "size_bytes": 4096, "downloadable": false, "scope": { "id": "session-abc123", "type": "session" }, "type": "file" } ``` **SDK Code** ```python import requests url = "https://api.example.com/v1/files/file_id" querystring = {"scope_id":"scope_id"} payload = "string" headers = {"Content-Type": "application/json"} response = requests.put(url, json=payload, headers=headers, params=querystring) print(response.json()) ``` ```javascript const url = 'https://api.example.com/v1/files/file_id?scope_id=scope_id'; const options = {method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '"string"'}; 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" "strings" "net/http" "io" ) func main() { url := "https://api.example.com/v1/files/file_id?scope_id=scope_id" payload := strings.NewReader("\"string\"") req, _ := http.NewRequest("PUT", url, payload) req.Header.Add("Content-Type", "application/json") 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.example.com/v1/files/file_id?scope_id=scope_id") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Put.new(url) request["Content-Type"] = 'application/json' request.body = "\"string\"" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.put("https://api.example.com/v1/files/file_id?scope_id=scope_id") .header("Content-Type", "application/json") .body("\"string\"") .asString(); ``` ```php request('PUT', 'https://api.example.com/v1/files/file_id?scope_id=scope_id', [ 'body' => '"string"', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.example.com/v1/files/file_id?scope_id=scope_id"); var request = new RestRequest(Method.PUT); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "\"string\"", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = "string" as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1/files/file_id?scope_id=scope_id")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PUT" request.allHTTPHeaderFields = headers request.httpBody = postData as Data 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() ```