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.
POST /tasks/ endpoint accepts a JSON request body that conforms to the Task model and inserts a new document into the MongoDB task collection. On success, the controller re-fetches the newly inserted document by its generated _id, converts it with task_entity(), and returns the full task object — including the MongoDB-assigned id — with an HTTP 200 response. If the insert operation fails, a 400 Bad Request is returned.
POST /tasks/
Request Body
A short, human-readable title for the task (e.g.
"Buy groceries").A detailed description of what the task involves (e.g.
"Milk, eggs, bread").An identifier for the user creating the task. Typically an email address or username (e.g.
"alice@example.com").Whether the task is already completed at creation time. Defaults to
false if omitted.Example Request
Example Request Body
Example Response
Response Fields
MongoDB ObjectId assigned to the new document, serialised as a 24-character hex string. Use this value in subsequent
GET, PUT, or DELETE calls.The task title as provided in the request body.
The task description as provided in the request body.
Reflects the
completed value from the request. Always false when the field is omitted.The user identifier as provided in the request body.
Error Responses
| Status | Detail | Cause |
|---|---|---|
400 Bad Request | "The task can't bee added!" | MongoDB insert_one() did not return a result. |
422 Unprocessable Entity | Validation error details | One or more required fields (title, description, created_by) are missing or have the wrong type. |
500 Internal Server Error | Server error message | Database connection failure or unexpected exception. |