> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://humanloop.com/docs/v5/api/datasets/upload-csv/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/_mcp/server. # Upload CSV POST https://api.humanloop.com/v5/datasets/{id}/datapoints/csv Content-Type: multipart/form-data Add Datapoints from a CSV file to a Dataset. This will create a new version of the Dataset with the Datapoints from the CSV file. If either `version_id` or `environment` is provided, the new version will be based on the specified version, with the Datapoints from the CSV file added to the existing Datapoints in the version. If neither `version_id` nor `environment` is provided, the new version will be based on the version of the Dataset that is deployed to the default Environment. You can optionally provide a name and description for the new version using `version_name` and `version_description` parameters. Reference: https://humanloop.com/docs/api/datasets/upload-csv ## Authentication - `X-API-KEY` header (required) — API Key authentication via header ## Request ### Path parameters - `id` (string, required) — Unique identifier for the Dataset ### Query parameters - `version_id` (string, optional) — ID of the specific Dataset version to base the created Version on. - `environment` (string, optional) — Name of the Environment identifying a deployed Version to base the created Version on. ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `file` (file, required) — A CSV file containing Datapoints to be added to the Dataset. - `version_name` (string, optional) — Name for the new Dataset version. - `version_description` (string, optional) — Description for the new Dataset version. ## Response ### 200 Successful Response - `path` (string, required) — Path of the Dataset, including the name, which is used as a unique identifier. - `id` (string, required) — Unique identifier for the Dataset. Starts with `ds_`. - `name` (string, required) — Name of the Dataset, which is used as a unique identifier. - `version_id` (string, required) — Unique identifier for the specific Dataset Version. If no query params provided, the default deployed Dataset Version is returned. Starts with `dsv_`. - `created_at` (datetime, required) - `updated_at` (datetime, required) - `last_used_at` (datetime, required) - `datapoints_count` (integer, required) — The number of Datapoints in this Dataset version. - `directory_id` (string, optional) — ID of the directory that the file is in on Humanloop. - `description` (string, optional) — Description of the Dataset. - `schema` (map from string to any, optional) — The JSON schema for the File. - `readme` (string, optional) — Long description of the file. - `tags` (list of string, optional) — List of tags associated with the file. - `type` ("dataset", optional) - `environments` (list of EnvironmentResponse, optional) — The list of environments the Dataset Version is deployed to. - `created_by` (any, optional) — The user who created the Dataset. - `version_name` (string, optional) — Unique name for the Dataset version. Version names must be unique for a given Dataset. - `version_description` (string, optional) — Description of the version, e.g., the changes made in this version. - `datapoints` (list of DatapointResponse, optional) — The list of Datapoints in this Dataset version. Only provided if explicitly requested. - `attributes` (map from string to any, optional) — Additional fields to describe the Dataset. Helpful to separate Dataset versions from each other with details on how they were created or used. ## Errors ### 422 Upload CSV Datasets ID Datapoints CSV Post Request Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### EnvironmentResponse - `id` (string, required) - `created_at` (datetime, required) - `name` (string, required) - `tag` (enum, required) — An enumeration. - Allowed values: `default`, `other` ### DatapointResponse - `id` (string, required) — Unique identifier for the Datapoint. Starts with `dp_`. - `inputs` (map from string to string, optional) — The inputs to the prompt template. - `messages` (list of ChatMessage, optional) — List of chat messages to provide to the model. - `target` (map from string to DatapointResponseTargetValue, optional) — Object with criteria necessary to evaluate generations with this Datapoint. This is passed in as an argument to Evaluators when used in an Evaluation. ### ValidationError - `loc` (list of ValidationErrorLocItem, required) - `msg` (string, required) - `type` (string, required) ### ChatMessage - `role` (enum, required) — Role of the message author. - Allowed values: `user`, `assistant`, `system`, `tool`, `developer` - `content` (ChatMessageContent, optional) — The content of the message. - `name` (string, optional) — Optional name of the message author. - `tool_call_id` (string, optional) — Tool call that this message is responding to. - `tool_calls` (list of ToolCall, optional) — A list of tool calls requested by the assistant. - `thinking` (list of ChatMessageThinkingItem, optional) — Model's chain-of-thought for providing the response. Present on assistant messages if model supports it. ### DatapointResponseTargetValue ### ValidationErrorLocItem ### ChatMessageContent The content of the message. ### ToolCall A tool call to be made. - `id` (string, required) - `type` ("function", required) — The type of tool to call. - `function` (FunctionTool, required) — A function tool to be called by the model where user owns runtime. ### ChatMessageThinkingItem ### FunctionTool A function tool to be called by the model where user owns runtime. - `name` (string, required) - `arguments` (string, optional) ### AnthropicThinkingContent - `type` ("thinking", required) - `thinking` (string, required) — Model's chain-of-thought for providing the response. - `signature` (string, required) — Cryptographic signature that verifies the thinking block was generated by Anthropic. ### AnthropicRedactedThinkingContent - `type` ("redacted_thinking", required) - `data` (string, required) — Thinking block Anthropic redacted for safety reasons. User is expected to pass the block back to Anthropic ## Examples **Request** ```json { "file": ">" } ``` **Response** ```json { "path": "path", "id": "id", "name": "name", "version_id": "version_id", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "last_used_at": "2024-01-15T09:30:00Z", "datapoints_count": 1, "directory_id": "directory_id", "description": "description", "schema": { "key": "value" }, "readme": "readme", "tags": [ "tags" ], "type": "dataset", "environments": [ { "id": "id", "created_at": "2024-01-15T09:30:00Z", "name": "name", "tag": "default" } ], "created_by": { "id": "id", "email_address": "email_address", "full_name": "full_name" }, "version_name": "version_name", "version_description": "version_description", "datapoints": [ { "id": "id", "inputs": { "key": "value" }, "messages": [ { "role": "user" } ], "target": { "key": "value" } } ], "attributes": { "key": "value" } } ``` **SDK Code** ```python import requests url = "https://api.humanloop.com/v5/datasets/id/datapoints/csv" files = { "file": "open('', 'rb')" } payload = { "version_name": , "version_description": } headers = {"X-API-KEY": ""} response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` ```typescript import { HumanloopClient } from "humanloop"; import * as fs from "fs"; const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" }); await client.datasets.uploadCsv(fs.createReadStream("/path/to/your/file"), "id", {}); ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.humanloop.com/v5/datasets/id/datapoints/csv" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_description\"\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.humanloop.com/v5/datasets/id/datapoints/csv") 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=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_description\"\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.humanloop.com/v5/datasets/id/datapoints/csv") .header("X-API-KEY", "") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_description\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.humanloop.com/v5/datasets/id/datapoints/csv', [ 'multipart' => [ [ 'name' => 'file', 'filename' => '', 'contents' => null ] ] 'headers' => [ 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.humanloop.com/v5/datasets/id/datapoints/csv"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"version_description\"\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": "" ], [ "name": "version_name", "value": ], [ "name": "version_description", "value": ] ] 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.humanloop.com/v5/datasets/id/datapoints/csv")! 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() ```