Skip to content

Update a document and return it

POST
/v1/db/{dbId}/findOneAndUpdate
curl --request POST \
--url https://your-app-domain/v1/db/example/findOneAndUpdate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "collection": "example", "filter": { "additionalProperty": "example" }, "update": { "additionalProperty": "example" }, "upsert": true, "sort": { "additionalProperty": 1 }, "projection": { "additionalProperty": "example" }, "returnDocument": "before", "writeConcern": { "w": "log" } }'
dbId
required
string

The database id (the last part of the connection string).

Media typeapplication/json
object
collection
required

Collection (table) API name

string
>= 1 characters <= 64 characters
filter
required

MongoDB query filter

object
key
additional properties
update
required

A document

object
key
additional properties
upsert
boolean
sort

Sort order, e.g. { “dealValue”: -1 }

object
key
additional properties
Any of:
number
Allowed value: 1
projection

Fields to include or exclude

object
key
additional properties
returnDocument
string
Allowed values: before after
writeConcern

{ w: “drive” } waits until the change is saved to Google Drive

object
w
string
Allowed values: log drive

Success

Media typeapplication/json
object
document
required
One of:

A document: _id, _createdAt, _updatedAt and your fields by API name.

object
_id
string
_createdAt
string format: date-time
_updatedAt
string format: date-time
key
additional properties
any

Example generated

{
"document": {
"_id": "example",
"_createdAt": "2026-04-15T12:00:00Z",
"_updatedAt": "2026-04-15T12:00:00Z"
}
}

Invalid request (BadRequest, ValidationError, BadValue, ImmutableField, InvalidName).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Missing, wrong, revoked or expired connection string, or Google access was removed (Unauthorized).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Read-only connection string (ReadOnlyKey) or a database you can only view (ReadOnly).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Unknown collection (NamespaceNotFound) or action (UnknownAction).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

A unique field already has this value (DuplicateKey).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Request body over 1 MB (PayloadTooLarge).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Too many requests (RateLimited). Wait for Retry-After seconds.

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

The database file is unavailable (DatabaseUnavailable) or Google Drive is busy (DriveUnavailable, retry).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

The owner’s Google Drive is full (DriveFull).

Media typeapplication/json
object
error
required
object
code
required
string
message
required
string
details
object
key
additional properties
any

Example generated

{
"error": {
"code": "example",
"message": "example",
"details": {}
}
}

Made by Faeiz Furqan