TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/fastapi-CRUD-MongoDB/llms.txt
Use this file to discover all available pages before exploring further.
PUT /users/{id} endpoint updates an existing user document identified by its MongoDB ObjectId. The controller calls find_one_and_update with a $set operator, replacing the stored name, age, and email fields with the values provided in the request body. After a successful update, the controller re-fetches the document and returns the latest state. If no document matches the given id, the API returns HTTP 404 Not Found.
PUT /users/{id}
Path Parameters
MongoDB ObjectId (24-character hex string) identifying the user document to update. Example:
64a1b2c3d4e5f6789abcdef0.Request Body
The user’s updated full name.
The user’s updated age.
The user’s updated email address.
PUT replaces all fields via MongoDB’s
$set operator — all three fields (name, age, email) must be provided in every request. Omitting a field will cause a Pydantic validation error since all three are required by the User model.Response Fields
The MongoDB ObjectId serialized as a 24-character hexadecimal string.
The user’s updated full name.
The user’s updated age.
The user’s updated email address.
Example Request
Request Body
Example Response
A successful request returns HTTP200 OK with the full updated user document.
Error Responses
404 Not Found
Returned when no user document exists for the providedid.