Create a task
Sends a task object to store the details of the new task resource in the service. The new task is for a registered user of the service.
Endpoint
{server_url}/tasks
Parameters
None
Request headers
| Header | Value | Required |
|---|---|---|
content-type | application/json | Yes |
Request body
{
"userId": 1,
"title": "Grocery shopping",
"description": "eggs, bacon, gummy bears",
"dueDate": "2026-02-20T17:00",
"warning": "10"
}
Response body
Returns a task resource
Examples
POST example request
curl -H 'content-type: application/json' \
--url http://localhost:3000/tasks \
-d '{
"userId": 1,
"title": "Grocery shopping",
"description": "eggs, bacon, gummy bears",
"dueDate": "2025-09-20T17:00",
"warning": "10"
}'
POST example response
{
"userId": 1,
"title": "Grocery shopping",
"description": "eggs, bacon, gummy bears",
"dueDate": "2025-09-20T17:00",
"warning": "10",
"id": 3
}
Response status
| HTTP status value | Description |
|---|---|
| 201 | Success: Task resource created successfully |
| 400 | Error: Malformed request not processed. Verify syntax and try again. |
| 500 | Error: Server rejected the data. Verify data and try again. |