> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://humanloop.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/docs/_mcp/server.

# Upsert Dataset

POST https://api.humanloop.com/v5/datasets
Content-Type: application/json

Create a Dataset or update it with a new version if it already exists.

Datasets are identified by the `ID` or their `path`. The datapoints determine the versions of the Dataset.

By default, the new Dataset version will be set to the list of Datapoints provided in
the request. You can also create a new version by adding or removing Datapoints from an existing version
by specifying `action` as `add` or `remove` respectively. In this case, you may specify
the `version_id` or `environment` query parameters to identify the existing version to base
the new version on. If neither is provided, the latest created version will be used.

You can provide `version_name` and `version_description` to identify and describe your versions.
Version names must be unique within a Dataset - attempting to create a version with a name
that already exists will result in a 409 Conflict error.

Humanloop also deduplicates Datapoints. If you try to add a Datapoint that already
exists, it will be ignored. If you intentionally want to add a duplicate Datapoint,
you can add a unique identifier to the Datapoint's inputs such as `{_dedupe_id: <unique ID>}`.

Reference: https://humanloop.com/docs/api/datasets/upsert

## Authentication

- `X-API-KEY` header (required) — API Key authentication via header

## Request

### Query parameters

- `version_id` (string, optional) — ID of the specific Dataset version to base the created Version on. Only used when `action` is `"add"` or `"remove"`.
- `environment` (string, optional) — Name of the Environment identifying a deployed Version to base the created Version on. Only used when `action` is `"add"` or `"remove"`.
- `include_datapoints` (boolean, optional, default: false) — If set to `true`, include all Datapoints in the response. Defaults to `false`. Consider using the paginated List Datapoints endpoint instead.

### Body (application/json)

This endpoint expects an object.

- `datapoints` (list of CreateDatapointRequest, required) — The Datapoints to create this Dataset version with. Modify the `action` field to determine how these Datapoints are used.
- `path` (string, optional) — Path of the Dataset, including the name. This locates the Dataset in the Humanloop filesystem and is used as as a unique identifier. For example: `folder/name` or just `name`.
- `id` (string, optional) — ID for an existing Dataset.
- `action` (enum, optional) — The action to take with the provided Datapoints. - If `"set"`, the created version will only contain the Datapoints provided in this request. - If `"add"`, the created version will contain the Datapoints provided in this request in addition to the Datapoints in the target version. - If `"remove"`, the created version will contain the Datapoints in the target version except for the Datapoints provided in this request. If `"add"` or `"remove"`, one of the `version_id` or `environment` query parameters may be provided.
  - Allowed values: `set`, `add`, `remove`
- `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.
- `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.

## 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 Upsert Datasets Post Request Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### CreateDatapointRequest

- `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 CreateDatapointRequestTargetValue, 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.

### 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.

### CreateDatapointRequestTargetValue

### 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

### AddToDataset

**Request**

```json
{
  "datapoints": [
    {
      "inputs": {
        "question": "What is the capital of France?"
      },
      "target": {
        "answer": "Paris"
      }
    },
    {
      "inputs": {
        "question": "Who wrote Hamlet?"
      },
      "target": {
        "answer": "William Shakespeare"
      }
    }
  ],
  "path": "test-questions",
  "action": "set",
  "version_name": "test-questions-v1",
  "version_description": "Add two new questions and answers"
}
```

**Response**

```json
{
  "path": "test-questions",
  "id": "ds_mno345",
  "name": "test-questions",
  "version_id": "dsv_pqr678",
  "created_at": "2024-05-01T12:00:00Z",
  "updated_at": "2024-05-01T12:00:00Z",
  "last_used_at": "2024-05-01T12:00:00Z",
  "datapoints_count": 4,
  "type": "dataset"
}
```

**SDK Code**

```python AddToDataset
import requests

url = "https://api.humanloop.com/v5/datasets"

payload = {
    "datapoints": [
        {
            "inputs": { "question": "What is the capital of France?" },
            "target": { "answer": "Paris" }
        },
        {
            "inputs": { "question": "Who wrote Hamlet?" },
            "target": { "answer": "William Shakespeare" }
        }
    ],
    "path": "test-questions",
    "action": "set",
    "version_name": "test-questions-v1",
    "version_description": "Add two new questions and answers"
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript AddToDataset
import { HumanloopClient } from "humanloop";

const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
await client.datasets.upsert({
    path: "test-questions",
    datapoints: [{
            inputs: {
                "question": "What is the capital of France?"
            },
            target: {
                "answer": "Paris"
            }
        }, {
            inputs: {
                "question": "Who wrote Hamlet?"
            },
            target: {
                "answer": "William Shakespeare"
            }
        }],
    action: "set",
    versionName: "test-questions-v1",
    versionDescription: "Add two new questions and answers"
});

```

```go AddToDataset
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.humanloop.com/v5/datasets"

	payload := strings.NewReader("{\n  \"datapoints\": [\n    {\n      \"inputs\": {\n        \"question\": \"What is the capital of France?\"\n      },\n      \"target\": {\n        \"answer\": \"Paris\"\n      }\n    },\n    {\n      \"inputs\": {\n        \"question\": \"Who wrote Hamlet?\"\n      },\n      \"target\": {\n        \"answer\": \"William Shakespeare\"\n      }\n    }\n  ],\n  \"path\": \"test-questions\",\n  \"action\": \"set\",\n  \"version_name\": \"test-questions-v1\",\n  \"version_description\": \"Add two new questions and answers\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	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 AddToDataset
require 'uri'
require 'net/http'

url = URI("https://api.humanloop.com/v5/datasets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"datapoints\": [\n    {\n      \"inputs\": {\n        \"question\": \"What is the capital of France?\"\n      },\n      \"target\": {\n        \"answer\": \"Paris\"\n      }\n    },\n    {\n      \"inputs\": {\n        \"question\": \"Who wrote Hamlet?\"\n      },\n      \"target\": {\n        \"answer\": \"William Shakespeare\"\n      }\n    }\n  ],\n  \"path\": \"test-questions\",\n  \"action\": \"set\",\n  \"version_name\": \"test-questions-v1\",\n  \"version_description\": \"Add two new questions and answers\"\n}"

response = http.request(request)
puts response.read_body
```

```java AddToDataset
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.humanloop.com/v5/datasets")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"datapoints\": [\n    {\n      \"inputs\": {\n        \"question\": \"What is the capital of France?\"\n      },\n      \"target\": {\n        \"answer\": \"Paris\"\n      }\n    },\n    {\n      \"inputs\": {\n        \"question\": \"Who wrote Hamlet?\"\n      },\n      \"target\": {\n        \"answer\": \"William Shakespeare\"\n      }\n    }\n  ],\n  \"path\": \"test-questions\",\n  \"action\": \"set\",\n  \"version_name\": \"test-questions-v1\",\n  \"version_description\": \"Add two new questions and answers\"\n}")
  .asString();
```

```php AddToDataset
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.humanloop.com/v5/datasets', [
  'body' => '{
  "datapoints": [
    {
      "inputs": {
        "question": "What is the capital of France?"
      },
      "target": {
        "answer": "Paris"
      }
    },
    {
      "inputs": {
        "question": "Who wrote Hamlet?"
      },
      "target": {
        "answer": "William Shakespeare"
      }
    }
  ],
  "path": "test-questions",
  "action": "set",
  "version_name": "test-questions-v1",
  "version_description": "Add two new questions and answers"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp AddToDataset
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v5/datasets");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"datapoints\": [\n    {\n      \"inputs\": {\n        \"question\": \"What is the capital of France?\"\n      },\n      \"target\": {\n        \"answer\": \"Paris\"\n      }\n    },\n    {\n      \"inputs\": {\n        \"question\": \"Who wrote Hamlet?\"\n      },\n      \"target\": {\n        \"answer\": \"William Shakespeare\"\n      }\n    }\n  ],\n  \"path\": \"test-questions\",\n  \"action\": \"set\",\n  \"version_name\": \"test-questions-v1\",\n  \"version_description\": \"Add two new questions and answers\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift AddToDataset
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "datapoints": [
    [
      "inputs": ["question": "What is the capital of France?"],
      "target": ["answer": "Paris"]
    ],
    [
      "inputs": ["question": "Who wrote Hamlet?"],
      "target": ["answer": "William Shakespeare"]
    ]
  ],
  "path": "test-questions",
  "action": "set",
  "version_name": "test-questions-v1",
  "version_description": "Add two new questions and answers"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v5/datasets")! 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()
```

### CreateSupportDataset

**Request**

```json
{
  "datapoints": [
    {
      "messages": [
        {
          "role": "user",
          "content": "How do i manage my organizations API keys?\n"
        }
      ],
      "target": {
        "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \n\n2. Click on \"Organization Settings.\"\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\n\n3. Within the settings or organization settings, select the option labeled \"API Keys\" on the left. Here you will be able to view and manage your API keys.\n\n4. You will see a list of existing API keys. You can perform various actions, such as:\n     - **Generate New API Key:** Click on the \"Generate New Key\" button if you need a new API key.\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \"Revoke\" or \"Delete\" button.\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \"Copy\" button next to the key.\n\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\n\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\n\nWould you need help with anything else?"
      }
    },
    {
      "messages": [
        {
          "role": "user",
          "content": "Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?"
        }
      ],
      "target": {
        "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \n\nWould you need help with anything else?"
      }
    }
  ],
  "path": "datasets/support-queries",
  "version_name": "Initial version",
  "version_description": "Add two new questions and answers"
}
```

**Response**

```json
{
  "path": "test-questions",
  "id": "ds_mno345",
  "name": "test-questions",
  "version_id": "dsv_pqr678",
  "created_at": "2024-05-01T12:00:00Z",
  "updated_at": "2024-05-01T12:00:00Z",
  "last_used_at": "2024-05-01T12:00:00Z",
  "datapoints_count": 4,
  "type": "dataset"
}
```

**SDK Code**

```python CreateSupportDataset
import requests

url = "https://api.humanloop.com/v5/datasets"

payload = {
    "datapoints": [
        {
            "messages": [
                {
                    "role": "user",
                    "content": "How do i manage my organizations API keys?
"
                }
            ],
            "target": { "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard 

2. Click on \"Organization Settings.\"
 If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.

3. Within the settings or organization settings, select the option labeled \"API Keys\" on the left. Here you will be able to view and manage your API keys.

4. You will see a list of existing API keys. You can perform various actions, such as:
     - **Generate New API Key:** Click on the \"Generate New Key\" button if you need a new API key.
     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \"Revoke\" or \"Delete\" button.
     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \"Copy\" button next to the key.

5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.

If you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.

Would you need help with anything else?" }
        },
        {
            "messages": [
                {
                    "role": "user",
                    "content": "Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?"
                }
            ],
            "target": { "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. 
 2. Select the `Monitoring` button on the top right of the Prompt dashboard 
 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. 

Would you need help with anything else?" }
        }
    ],
    "path": "datasets/support-queries",
    "version_name": "Initial version",
    "version_description": "Add two new questions and answers"
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript CreateSupportDataset
import { HumanloopClient } from "humanloop";

const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
await client.datasets.upsert({
    path: "datasets/support-queries",
    datapoints: [{
            messages: [{
                    role: "user",
                    content: "How do i manage my organizations API keys?\n"
                }],
            target: {
                "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \n\n2. Click on \"Organization Settings.\"\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\n\n3. Within the settings or organization settings, select the option labeled \"API Keys\" on the left. Here you will be able to view and manage your API keys.\n\n4. You will see a list of existing API keys. You can perform various actions, such as:\n     - **Generate New API Key:** Click on the \"Generate New Key\" button if you need a new API key.\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \"Revoke\" or \"Delete\" button.\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \"Copy\" button next to the key.\n\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\n\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\n\nWould you need help with anything else?"
            }
        }, {
            messages: [{
                    role: "user",
                    content: "Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?"
                }],
            target: {
                "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \n\nWould you need help with anything else?"
            }
        }],
    versionName: "Initial version",
    versionDescription: "Add two new questions and answers"
});

```

```go CreateSupportDataset
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.humanloop.com/v5/datasets"

	payload := strings.NewReader("{\n  \"datapoints\": [\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"How do i manage my organizations API keys?\\n\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \\n\\n2. Click on \\\"Organization Settings.\\\"\\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\\n\\n3. Within the settings or organization settings, select the option labeled \\\"API Keys\\\" on the left. Here you will be able to view and manage your API keys.\\n\\n4. You will see a list of existing API keys. You can perform various actions, such as:\\n     - **Generate New API Key:** Click on the \\\"Generate New Key\\\" button if you need a new API key.\\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \\\"Revoke\\\" or \\\"Delete\\\" button.\\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \\\"Copy\\\" button next to the key.\\n\\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\\n\\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\\n\\nWould you need help with anything else?\"\n      }\n    },\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \\n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \\n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \\n\\nWould you need help with anything else?\"\n      }\n    }\n  ],\n  \"path\": \"datasets/support-queries\",\n  \"version_name\": \"Initial version\",\n  \"version_description\": \"Add two new questions and answers\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	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 CreateSupportDataset
require 'uri'
require 'net/http'

url = URI("https://api.humanloop.com/v5/datasets")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"datapoints\": [\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"How do i manage my organizations API keys?\\n\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \\n\\n2. Click on \\\"Organization Settings.\\\"\\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\\n\\n3. Within the settings or organization settings, select the option labeled \\\"API Keys\\\" on the left. Here you will be able to view and manage your API keys.\\n\\n4. You will see a list of existing API keys. You can perform various actions, such as:\\n     - **Generate New API Key:** Click on the \\\"Generate New Key\\\" button if you need a new API key.\\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \\\"Revoke\\\" or \\\"Delete\\\" button.\\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \\\"Copy\\\" button next to the key.\\n\\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\\n\\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\\n\\nWould you need help with anything else?\"\n      }\n    },\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \\n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \\n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \\n\\nWould you need help with anything else?\"\n      }\n    }\n  ],\n  \"path\": \"datasets/support-queries\",\n  \"version_name\": \"Initial version\",\n  \"version_description\": \"Add two new questions and answers\"\n}"

response = http.request(request)
puts response.read_body
```

```java CreateSupportDataset
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.humanloop.com/v5/datasets")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"datapoints\": [\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"How do i manage my organizations API keys?\\n\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \\n\\n2. Click on \\\"Organization Settings.\\\"\\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\\n\\n3. Within the settings or organization settings, select the option labeled \\\"API Keys\\\" on the left. Here you will be able to view and manage your API keys.\\n\\n4. You will see a list of existing API keys. You can perform various actions, such as:\\n     - **Generate New API Key:** Click on the \\\"Generate New Key\\\" button if you need a new API key.\\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \\\"Revoke\\\" or \\\"Delete\\\" button.\\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \\\"Copy\\\" button next to the key.\\n\\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\\n\\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\\n\\nWould you need help with anything else?\"\n      }\n    },\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \\n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \\n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \\n\\nWould you need help with anything else?\"\n      }\n    }\n  ],\n  \"path\": \"datasets/support-queries\",\n  \"version_name\": \"Initial version\",\n  \"version_description\": \"Add two new questions and answers\"\n}")
  .asString();
```

```php CreateSupportDataset
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.humanloop.com/v5/datasets', [
  'body' => '{
  "datapoints": [
    {
      "messages": [
        {
          "role": "user",
          "content": "How do i manage my organizations API keys?\\n"
        }
      ],
      "target": {
        "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \\n\\n2. Click on \\"Organization Settings.\\"\\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\\n\\n3. Within the settings or organization settings, select the option labeled \\"API Keys\\" on the left. Here you will be able to view and manage your API keys.\\n\\n4. You will see a list of existing API keys. You can perform various actions, such as:\\n     - **Generate New API Key:** Click on the \\"Generate New Key\\" button if you need a new API key.\\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \\"Revoke\\" or \\"Delete\\" button.\\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \\"Copy\\" button next to the key.\\n\\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\\n\\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\\n\\nWould you need help with anything else?"
      }
    },
    {
      "messages": [
        {
          "role": "user",
          "content": "Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?"
        }
      ],
      "target": {
        "response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \\n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \\n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \\n\\nWould you need help with anything else?"
      }
    }
  ],
  "path": "datasets/support-queries",
  "version_name": "Initial version",
  "version_description": "Add two new questions and answers"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp CreateSupportDataset
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v5/datasets");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"datapoints\": [\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"How do i manage my organizations API keys?\\n\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard \\n\\n2. Click on \\\"Organization Settings.\\\"\\n If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.\\n\\n3. Within the settings or organization settings, select the option labeled \\\"API Keys\\\" on the left. Here you will be able to view and manage your API keys.\\n\\n4. You will see a list of existing API keys. You can perform various actions, such as:\\n     - **Generate New API Key:** Click on the \\\"Generate New Key\\\" button if you need a new API key.\\n     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \\\"Revoke\\\" or \\\"Delete\\\" button.\\n     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \\\"Copy\\\" button next to the key.\\n\\n5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.\\n\\nIf you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.\\n\\nWould you need help with anything else?\"\n      }\n    },\n    {\n      \"messages\": [\n        {\n          \"role\": \"user\",\n          \"content\": \"Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?\"\n        }\n      ],\n      \"target\": {\n        \"response\": \"Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. \\n 2. Select the `Monitoring` button on the top right of the Prompt dashboard \\n 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. \\n\\nWould you need help with anything else?\"\n      }\n    }\n  ],\n  \"path\": \"datasets/support-queries\",\n  \"version_name\": \"Initial version\",\n  \"version_description\": \"Add two new questions and answers\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift CreateSupportDataset
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "datapoints": [
    [
      "messages": [
        [
          "role": "user",
          "content": "How do i manage my organizations API keys?
"
        ]
      ],
      "target": ["response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Log in to the Humanloop Dashboard 

2. Click on \"Organization Settings.\"
 If you do not see this option, you might need to contact your organization admin to gain the necessary permissions.

3. Within the settings or organization settings, select the option labeled \"API Keys\" on the left. Here you will be able to view and manage your API keys.

4. You will see a list of existing API keys. You can perform various actions, such as:
     - **Generate New API Key:** Click on the \"Generate New Key\" button if you need a new API key.
     - **Revoke an API Key:** If you need to disable an existing key, find the key in the list and click the \"Revoke\" or \"Delete\" button.
     - **Copy an API Key:** If you need to use an existing key, you can copy it to your clipboard by clicking the \"Copy\" button next to the key.

5. **Save and Secure API Keys:** Make sure to securely store any new or existing API keys you are using. Treat them like passwords and do not share them publicly.

If you encounter any issues or need further assistance, it might be helpful to engage with an engineer or your IT department to ensure you have the necessary permissions and support.

Would you need help with anything else?"]
    ],
    [
      "messages": [
        [
          "role": "user",
          "content": "Hey, can do I use my code evaluator for monitoring my legal-copilot prompt?"
        ]
      ],
      "target": ["response": "Hey, thanks for your questions. Here are steps for how to achieve: 1. Navigate to your Prompt dashboard. 
 2. Select the `Monitoring` button on the top right of the Prompt dashboard 
 3. Within the model select the Version of the Evaluator you want to turn on for monitoring. 

Would you need help with anything else?"]
    ]
  ],
  "path": "datasets/support-queries",
  "version_name": "Initial version",
  "version_description": "Add two new questions and answers"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v5/datasets")! 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()
```