---
title: "Update One Document"
method: POST
path: "/action/updateOne"
---

# Update One Document

`POST /action/updateOne`

Update a single document in a collection.

## Request body

- UpdateRequestBody
  - `dataSource` string, required — The name of a linked MongoDB Atlas data source. This is commonly `"mongodb-atlas"` though it may be different in your App if you chose a different name when you created the data source.
  - `database` string, required — The name of a database in the specified data source.
  - `collection` string, required — The name of a collection in the specified database.
  - `filter` object, required — A MongoDB query filter that matches documents. For a list of all query operators that the Data API supports, see [Query Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#query-operators).
  - `update` object, required — A MongoDB update expression to apply to matching documents. For a list of all update operators that the Data API supports, see [Update Operators](https://www.mongodb.com/docs/atlas/app-services/mongodb/crud-and-aggregation-apis/#update-operators).
  - `upsert` boolean — When `true`, if the update filter does not match any existing documents, then insert a new document based on the filter and the specified update operation.

## Response `200`

Updated

- object
  - `matchedCount` number, required — The number of documents matched by the query filter.
  - `modifiedCount` number, required — The number of matched documents that were modified.
  - `upsertedId` string — The `_id` value of the upserted document.

## Other responses

- `400` — The request was malformed or incomplete.
- `401` — The authenticated user does not have permission to access this endpoint.

## Changes

- **2023-05-11** `5088bc79b2f0` — 4 breaking
  - the `allOf[subschema #1: UpdateResponseBody]/matchedCount` response's property type/format changed from `number, object`/`` to ``/`` for status `200` (media type: application/json)
  - the `allOf[subschema #1: UpdateResponseBody]/matchedCount` response's property type/format changed from `number, object`/`` to ``/`` for status `200` (media type: application/ejson)
  - the `allOf[subschema #1: UpdateResponseBody]/modifiedCount` response's property type/format changed from `number, object`/`` to ``/`` for status `200` (media type: application/json)
  - the `allOf[subschema #1: UpdateResponseBody]/modifiedCount` response's property type/format changed from `number, object`/`` to ``/`` for status `200` (media type: application/ejson)

[Change history](https://skmtc.dev/mongodb/apis/mongodb-atlas-data-api/changes/action/updateOne/post.md)

---

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