---
title: "Update Data Items By Key"
method: PATCH
path: "/collections/{collectionId}/itemsByKey"
tags: ["Data Item"]
---

# Update Data Items By Key

`PATCH /collections/{collectionId}/itemsByKey`

## Request

- Base URL: `https://data.lucid.app`
- URL: `https://data.lucid.app/collections/{collectionId}/itemsByKey`
- Auth: OAuth 2
  - Authorization code: `https://lucid.app/oauth2/authorize`
  - Token URL: `https://api.lucid.co/oauth2/token` scopes: `data-service.admin`

Find any data items whose fields match specified values and update those items using a patch. If the value of a field in a patch is null, that value will be deleted from the item. If the provided field name does not exist in the collection schema, that value is ignored. Attempts to update the Collection field will be ignored as a data item cannot be moved to a different collection.

## Path parameters

- `collectionId` integer, required

## Request body

- object
  - `patches` object[], required: Define what items from the collection you are changing and how to change them. The order of strings in fieldValues must match that of either keySchemaFields or of the actual primary keys from the real schema if keySchemaFields is not defined.
    - `fieldValues` string[]: Specifies the actual value that the fields need to have to be found
    - `patch` object: List of field names with the new value that the field should be set to. Changes will be applied to any matching items and if the value is null, that field will be deleted from the matching data items.
  - `keySchemaFields` string[]: Fields used to search for items in the collection. If it is not provided, primary keys from the schema are used.

## Response `200`

OK with message indicating the number of items updated.

- object
  - `message` string: Message indicating the number of items updated

---

[API](https://skmtc.dev/lucid/apis/lucid-data-api.md) - [All operations](https://skmtc.dev/lucid/apis/lucid-data-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lucid/apis/lucid-data-api/revisions/c14ed29dbeab?raw)
