---
title: "Update documents with conditional query"
method: PATCH
path: "/collections/{collectionName}/documents"
tags: ["documents"]
---

# Update documents with conditional query

`PATCH /collections/{collectionName}/documents`

The filter_by query parameter is used to filter to specify a condition against which the documents are matched. The request body contains the fields that should be updated for any documents that match the filter condition. This endpoint is only available if the Typesense server is version `0.25.0.rc12` or later.

## Path parameters

- `collectionName` string, required

## Query parameters

- `updateDocumentsParameters` object
  - `filter_by` string

## Request body

- object — Can be any key-value pair

## Response `200`

The response contains a single field, `num_updated`, indicating the number of documents affected.

- object
  - `num_updated` integer, required — The number of documents that have been updated

## Other responses

- `400` — Bad request, see error message for details
- `404` — The collection was not found

---

[API](https://skmtc.dev/typesense/apis/typesense-api.md) · [All operations](https://skmtc.dev/typesense/apis/typesense-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/typesense/typesense-api/revisions/1d9b3b61638e/schema)
