docs icon indicating copy to clipboard operation
docs copied to clipboard

Improve updating multiple items api reference

Open br41nslug opened this issue 9 months ago • 1 comments

The "Update Multiple Items" section in the API reference is missing 2 supported methods of doing multiple updates.

On this page https://directus.io/docs/api/items#update-multiple-items we are currently documenting the "update many by keys" approach, here you provide a list of keys and one single object to update all keys with.

PATCH /items/:collection
{
  "keys": [1,2,3,4],
  "data": {
    "status": "published"
  }
}

We also support the following approaches:

  1. "update many by query" similar to the one above but instead of providing a list of ID's you provide a query to filter items to be updated with a single object.
PATCH /items/:collection
{
  "query": {
    "filter": { 
      "status": { "_eq": "draft" },
    },
  },
  "data": {
    "status": "published"
  }
}
  1. "batch updating" this approach allows the sending of a list of items to updated based on ID so each individual item can update different properties.
PATCH /items/:collection
[
  {
    "id": 1,
    "status": "published"
  },
  {
    "id": 2,
    "status": "archived"
  },
  {
    "id": 3,
    "title": "something"
  },
]

br41nslug avatar Mar 20 '25 23:03 br41nslug