> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://humanloop.com/docs/v4/api/datasets/create-datapoint/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/_mcp/server. # Create Datapoint POST https://api.humanloop.com/v4/datasets/{dataset_id}/datapoints Content-Type: application/json Create a new datapoint for a dataset. Here in the v4 API, this has the following behaviour: * Retrieve the current latest version of the dataset. * Construct a new version of the dataset with the new testcases added. * Store that latest version as a committed version with an autogenerated commit message and return the new datapoints Reference: https://humanloop.com/docs/v4/api/datasets/create-datapoint ## Authentication - `X-API-KEY` header (required) — API Key authentication via header ## Request ### Path parameters - `dataset_id` (string, required) — String ID of dataset. Starts with `evts_`. ### Body (application/json) This endpoint expects a Request. - `Request` ## Response ### 201 Successful Response - `list of DatapointResponse` ## Errors ### 422 Datasets Create Datapoint Request Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ## Types ### CreateDatapointsByLogsRequest - `log_ids` (list of string, required) — The IDs of the logs to create datapoints from. ### CreateDatapointRequest - `inputs` (map from string to string, optional) — The inputs to the prompt template for this datapoint. - `messages` (list of ChatMessageWithToolCall, optional) — The chat messages for this datapoint. - `target` (map from string to CreateDatapointRequestTargetValue, optional) — Object with criteria necessary to evaluate this datapoint. ### DatapointResponse - `id` (string, required) - `dataset_id` (string, optional) - `inputs` (map from string to string, optional) - `messages` (list of ChatMessageWithToolCall, optional) - `target` (map from string to DatapointResponseTargetValue, optional) ### ValidationError - `loc` (list of ValidationErrorLocItem, required) - `msg` (string, required) - `type` (string, required) ### ChatMessageWithToolCall - `role` (enum, required) — Role of the message author. - Allowed values: `user`, `assistant`, `system`, `tool`, `developer` - `content` (Content, 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 ChatMessageWithToolCallThinkingItem, optional) — Model's chain-of-thought for providing the response. Present on assistant messages if model supports it. - `tool_call` (FunctionTool, optional, deprecated) — NB: Deprecated in favour of tool_calls. A tool call requested by the assistant. ### CreateDatapointRequestTargetValue ### DatapointResponseTargetValue ### ValidationErrorLocItem ### Content 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. ### ChatMessageWithToolCallThinkingItem - `type`: `thinking` - `signature` (string, required) — Cryptographic signature that verifies the thinking block was generated by Anthropic. - `thinking` (string, required) — Model's chain-of-thought for providing the response. - `type`: `redacted_thinking` - `data` (string, required) — Thinking block Anthropic redacted for safety reasons. User is expected to pass the block back to Anthropic ### FunctionTool A function tool to be called by the model where user owns runtime. - `name` (string, required) - `arguments` (string, optional) ## Examples **Request** ```json { "log_ids": [ "log_ids" ] } ``` **Response** ```json [ { "id": "id", "dataset_id": "dataset_id", "inputs": { "key": "value" }, "messages": [ { "role": "user" } ], "target": { "key": "value" } } ] ``` **SDK Code** ```python import requests url = "https://api.humanloop.com/v4/datasets/dataset_id/datapoints" payload = { "log_ids": ["log_ids"] } headers = { "X-API-KEY": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.humanloop.com/v4/datasets/dataset_id/datapoints'; const options = { method: 'POST', headers: {'X-API-KEY': '', 'Content-Type': 'application/json'}, body: '{"log_ids":["log_ids"]}' }; 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.humanloop.com/v4/datasets/dataset_id/datapoints" payload := strings.NewReader("{\n \"log_ids\": [\n \"log_ids\"\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-API-KEY", "") 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.humanloop.com/v4/datasets/dataset_id/datapoints") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-API-KEY"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"log_ids\": [\n \"log_ids\"\n ]\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/v4/datasets/dataset_id/datapoints") .header("X-API-KEY", "") .header("Content-Type", "application/json") .body("{\n \"log_ids\": [\n \"log_ids\"\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.humanloop.com/v4/datasets/dataset_id/datapoints', [ 'body' => '{ "log_ids": [ "log_ids" ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.humanloop.com/v4/datasets/dataset_id/datapoints"); var request = new RestRequest(Method.POST); request.AddHeader("X-API-KEY", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"log_ids\": [\n \"log_ids\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-API-KEY": "", "Content-Type": "application/json" ] let parameters = ["log_ids": ["log_ids"]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v4/datasets/dataset_id/datapoints")! 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() ```