## Update a dataset item

`client.DatasetItems.Update(ctx, datasetItemID, body) (*DatasetItem, error)`

**patch** `/v5/dataset-items/{dataset_item_id}`

Update the data payload and optional file associations of a dataset item.

The request replaces the item's data in full and, if provided, its file associations; there is no
partial-field merge. Data keys may not collide with reserved dataset- or evaluation-item field
names, and any referenced files must exist and be a supported media format. Items that are
archived or soft-deleted cannot be updated. The update is applied as a new dataset version rather
than overwriting the previous record, so prior versions remain retrievable.

### Parameters

- `datasetItemID string`

- `body DatasetItemUpdateParams`

  - `Data param.Field[map[string, any]]`

    Updated dataset item data

  - `Files param.Field[map[string, string]]`

    Files to be associated to the dataset

### Returns

- `type DatasetItem struct{…}`

  - `ID string`

    The unique identifier of the entity.

  - `ContentHash string`

  - `CreatedAt Time`

    The date and time when the entity was created in ISO format.

  - `CreatedBy Identity`

    The identity that created the entity.

    - `ID string`

    - `Type IdentityType`

      - `const IdentityTypeUser IdentityType = "user"`

      - `const IdentityTypeServiceAccount IdentityType = "service_account"`

    - `Object IdentityObject`

      - `const IdentityObjectIdentity IdentityObject = "identity"`

  - `Data map[string, any]`

  - `UpdatedAt Time`

    The date and time when the entity was last updated in ISO format.

  - `ArchivedAt Time`

    The date and time when the entity was archived in ISO format.

  - `DatasetID string`

  - `Files map[string, string]`

  - `Object DatasetItemObject`

    - `const DatasetItemObjectDatasetItem DatasetItemObject = "dataset.item"`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  datasetItem, err := client.DatasetItems.Update(
    context.TODO(),
    "dataset_item_id",
    sgpdev.DatasetItemUpdateParams{
      Data: map[string]any{
      "foo": "bar",
      },
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", datasetItem.ID)
}
```

#### Response

```json
{
  "id": "id",
  "content_hash": "content_hash",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by": {
    "id": "id",
    "type": "user",
    "object": "identity"
  },
  "data": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "dataset_id": "dataset_id",
  "files": {
    "foo": "string"
  },
  "object": "dataset.item"
}
```
