> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.termina.ai/api-reference/user-file/upload/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.termina.ai/_mcp/server. # Upload User File POST https://app.termina.ai/api/v1/user/me/file Content-Type: multipart/form-data Upload a user file directly (multipart). Max 50MB. Creates the DB row and uploads bytes to GCS. Reference: https://docs.termina.ai/api-reference/user-file/upload ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Servers - `https://app.termina.ai` (Production server, default) - `https://app.termina.dev` (Development server) - `http://localhost:8000` (Local development server) ## Request ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `file` (file, required) — The file to upload - `name` (string, required) — Name of the file including extension - `type` (enum, required) — Type/category of the file ## Response ### 201 Successful Response - `name` (string, required) — The human-readable name of the file - `id` (integer, required) - `user_id` (integer, required) - `type` (enum, optional, nullable) — The type of the file - Allowed values: `deck`, `financials`, `raw_data`, `snapshot`, `full`, `mini`, `nano`, `other` - `created_at` (string, optional) - `updated_at` (string, optional, nullable) - `is_archived` (boolean, optional, nullable) - `filesize` (integer, optional, default: 0) — The size of the file in bytes - `location` (string, optional, nullable) ## Errors ### 422 Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### ValidationError - `loc` (list of ValidationErrorLocItems, required) - `msg` (string, required) - `type` (string, required) - `input` (any, optional) - `ctx` (ValidationErrorCtx, optional) ### ValidationErrorLocItems ### ValidationErrorCtx ## Examples **Request** ```json { "file": "", "name": "string", "type": "deck" } ``` **Response** ```json { "name": "string", "id": 1, "user_id": 1, "type": "deck", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "is_archived": true, "filesize": 0, "location": "string" } ``` **SDK Code** ```python import requests url = "https://app.termina.ai/api/v1/user/me/file" files = { "file": "open('string', 'rb')" } payload = { "name": "string", "type": "deck" } headers = {"Authorization": "Bearer "} response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://app.termina.ai/api/v1/user/me/file'; const form = new FormData(); form.append('file', 'string'); form.append('name', 'string'); form.append('type', 'deck'); const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; options.body = form; 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://app.termina.ai/api/v1/user/me/file" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\ndeck\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") 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://app.termina.ai/api/v1/user/me/file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\ndeck\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://app.termina.ai/api/v1/user/me/file") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\ndeck\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://app.termina.ai/api/v1/user/me/file', [ 'multipart' => [ [ 'name' => 'file', 'filename' => 'string', 'contents' => null ], [ 'name' => 'name', 'contents' => 'string' ], [ 'name' => 'type', 'contents' => 'deck' ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://app.termina.ai/api/v1/user/me/file"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"string\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\nstring\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"type\"\r\n\r\ndeck\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let parameters = [ [ "name": "file", "fileName": "string" ], [ "name": "name", "value": "string" ], [ "name": "type", "value": "deck" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://app.termina.ai/api/v1/user/me/file")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ```