# Batch update dataset items

PATCH http://localhost:5173/api/v1/private/datasets/items/batch
Content-Type: application/json

Update multiple dataset items

Reference: https://www.comet.com/docs/opik/reference/rest-api/datasets/batch-update-dataset-items

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Batch update dataset items
  version: endpoint_datasets.batchUpdateDatasetItems
paths:
  /v1/private/datasets/items/batch:
    patch:
      operationId: batch-update-dataset-items
      summary: Batch update dataset items
      description: Update multiple dataset items
      tags:
        - - subpackage_datasets
      parameters: []
      responses:
        '204':
          description: No Content
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Datasets_batchUpdateDatasetItems_Response_204
        '400':
          description: Bad Request
          content: {}
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatasetItemBatchUpdate'
components:
  schemas:
    DatasetItemFilterOperator:
      type: string
      enum:
        - value: contains
        - value: not_contains
        - value: starts_with
        - value: ends_with
        - value: '='
        - value: '!='
        - value: '>'
        - value: '>='
        - value: <
        - value: <=
        - value: is_empty
        - value: is_not_empty
    DatasetItemFilter:
      type: object
      properties:
        field:
          type: string
        operator:
          $ref: '#/components/schemas/DatasetItemFilterOperator'
        key:
          type: string
        value:
          type: string
    JsonNode:
      type: object
      properties: {}
    DatasetItemUpdate:
      type: object
      properties:
        input:
          type: string
          description: Dataset item input
        expected_output:
          type: string
          description: Dataset item expected output
        metadata:
          $ref: '#/components/schemas/JsonNode'
        data:
          $ref: '#/components/schemas/JsonNode'
        tags:
          type: array
          items:
            type: string
          description: Tags
    DatasetItemBatchUpdate:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            List of dataset item IDs to update (max 1000). Mutually exclusive
            with 'filters'.
        filters:
          type: array
          items:
            $ref: '#/components/schemas/DatasetItemFilter'
        dataset_id:
          type: string
          format: uuid
          description: >-
            Dataset ID. Required when using 'filters', optional when using
            'ids'.
        update:
          $ref: '#/components/schemas/DatasetItemUpdate'
        merge_tags:
          type: boolean
          description: >-
            If true, merge tags with existing tags instead of replacing them.
            Default: false. When using 'filters', this is automatically set to
            true.
      required:
        - update
    Datasets_batchUpdateDatasetItems_Response_204:
      type: object
      properties: {}

```

## SDK Code Examples

```python
import requests

url = "http://localhost:5173/api/v1/private/datasets/items/batch"

payload = {}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/datasets/items/batch';
const options = {method: 'PATCH', headers: {'Content-Type': 'application/json'}, body: '{}'};

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 := "http://localhost:5173/api/v1/private/datasets/items/batch"

	payload := strings.NewReader("{}")

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

	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("http://localhost:5173/api/v1/private/datasets/items/batch")

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

request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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

```java
HttpResponse<String> response = Unirest.patch("http://localhost:5173/api/v1/private/datasets/items/batch")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'http://localhost:5173/api/v1/private/datasets/items/batch', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
var client = new RestClient("http://localhost:5173/api/v1/private/datasets/items/batch");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/datasets/items/batch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```