Skip to main content

Create Task

POST /tasks: Create a task with provided task details
{
"title": string,
"description": string,
"location": string,
"startDate": string,
"endDate": string,
"isStarted": boolean
}

Example Request​

This is a protected route, a valid JWT is required in the header field

Cookie:token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTU4MjQyNzUsImlhdCI6IjIwMjAtMDctMjdUMDA6MjY6MTUuNzg5NTg0Mi0wNDowMCIsInN1YiI6ImNocmlzIn0.5US2_ITKcfgkpEbfsR-gxXbGPFY6XsgJPcGA5qaBD1M

Body​

{
"title": "Task 2 - evvvve",
"description": "john",
"location": "UTM",
"startDate": "2022-02-25T15:02:08",
"endDate": "2022-02-27T15:02:08",
"isStarted": false
}

Note: If the start date isn't provided, then the current date will be used (At the time of the Task model creation)

Possible Responses​

Immediate Success​

{
"title": "Task 2 - evvvve",
"user_id": "62227aab7a9965d0be73b052",
"description": "john",
"location": "UTM",
"startDate": "2022-02-25T20:02:08.000Z",
"endDate": "2022-02-27T20:02:08.000Z",
"isStarted": false,
"_id": "623688c4f5735bc51286682f",
"createdAt": "2022-03-20T01:52:04.564Z",
"updatedAt": "2022-03-20T01:52:04.564Z",
"__v": 0
}

Failure​

{
"message": "Invalid Create Task Input",
"stack": ""
}
{
"message": "Unable to create task",
"stack": ""
}
{
"message": "Not Authorized, token failed",
"stack": ""
}