> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.coperniq.io/api-reference/files/upload-request-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.coperniq.io/_mcp/server. # Create Opportunity File (stream) POST https://api.coperniq.io/v1/opportunities/{opportunity_id}/files/upload Content-Type: multipart/form-data Upload a file to an opportunity using multipart/form-data **Note:** The `/requests` path is an alias for `/opportunities` and will continue to work until users are individually notified and migrated. **File size limit:** Files uploaded through this endpoint are currently capped at **6 MB**. For larger files, upload the file to your own storage using a pre-signed URL and create the file record with **`POST /opportunities/{opportunity_id}/files`**, passing the file's URL instead of streaming the bytes. Reference: https://docs.coperniq.io/api-reference/files/upload-request-file ## Authentication - `x-api-key` header (required) — API Key authentication via header ## Request ### Path parameters - `opportunity_id` (string, required) ### Query parameters - `name` (string, optional) — Optional file name to store - `content_type` (string, optional) — Optional MIME type to associate with the file - `phase_instance_id` (integer, optional) — Optional phase instance id to associate with the file ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `file` (file, required) ## Response ### 200 Successful response - `id` (integer, required) — File identifier - `name` (string, required) — File name - `downloadUrl` (string, required) — URL to download the file - `metaData` (FileUploadResponseMetaData, required) ## Errors ### 400 Bad Request Error Invalid request - `message` (string, optional) - `code` (enum, optional) - Allowed values: `INTERNAL_SERVER_ERROR` - `field` (string, optional) — Field that caused the validation error (if applicable) ### 404 Not Found Error Resource not found - `message` (string, optional) - `code` (enum, optional) - Allowed values: `INTERNAL_SERVER_ERROR` ### 500 Internal Server Error Internal server error - `message` (string, optional) - `code` (enum, optional) - Allowed values: `INTERNAL_SERVER_ERROR` ## Types ### FileUploadResponseMetaData - `acl` (string, required) — Access control level - `size` (integer, required) — File size in bytes - `userId` (integer, required) — User who uploaded the file - `mimeType` (string, required) — MIME type of the file - `extention` (string, required) — File extension - `originalName` (string, required) — Original file name - `generatedName` (string, required) — Generated unique file name - `gps` (FileUploadResponseMetaDataGps, optional) — GPS coordinates if applicable - `thumbnailUrl` (string, optional) — URL to the thumbnail version - `thumbnailName` (string, optional) — Generated thumbnail file name - `requestFileName` (string, optional) — Original request file name ### FileUploadResponseMetaDataGps GPS coordinates if applicable ## Examples **Request** ```json { "file": "" } ``` **Response** ```json { "id": 1, "name": "string", "downloadUrl": "string", "metaData": { "acl": "string", "size": 1, "userId": 1, "mimeType": "string", "extention": "string", "originalName": "string", "generatedName": "string", "gps": {}, "thumbnailUrl": "string", "thumbnailName": "string", "requestFileName": "string" } } ``` **SDK Code** ```python import requests url = "https://api.coperniq.io/v1/opportunities/opportunity_id/files/upload" files = { "file": "open('string', 'rb')" } headers = {"x-api-key": ""} response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.coperniq.io/v1/opportunities/opportunity_id/files/upload'; const form = new FormData(); form.append('file', 'string'); const options = {method: 'POST', headers: {'x-api-key': ''}}; 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://api.coperniq.io/v1/opportunities/opportunity_id/files/upload" 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\n") req, _ := http.NewRequest("POST", url, payload) 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.coperniq.io/v1/opportunities/opportunity_id/files/upload") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-api-key"] = '' 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\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://api.coperniq.io/v1/opportunities/opportunity_id/files/upload") .header("x-api-key", "") .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\n") .asString(); ``` ```php request('POST', 'https://api.coperniq.io/v1/opportunities/opportunity_id/files/upload', [ 'multipart' => [ [ 'name' => 'file', 'filename' => 'string', 'contents' => null ] ] 'headers' => [ 'x-api-key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.coperniq.io/v1/opportunities/opportunity_id/files/upload"); var request = new RestRequest(Method.POST); request.AddHeader("x-api-key", ""); 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\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["x-api-key": ""] let parameters = [ [ "name": "file", "fileName": "string" ] ] 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://api.coperniq.io/v1/opportunities/opportunity_id/files/upload")! 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() ``` > Official Coperniq API documentation. Build integrations for solar and construction project management — projects, opportunities, work orders, invoices, webhooks, and more.