Skip to main content

POST /api/tasks/{task_id}/complete

Marks a task as completed. This is a convenience endpoint equivalent to calling Update Task with {"status": "completed"}. The completed_at timestamp is automatically set to the current UTC time. Regular users can only complete tasks they own; admin users can complete any task.

Authentication

Authorization: Bearer <access_token>

Path Parameters

task_id
integer
required
The unique ID of the task to mark as completed.

Request Body

No request body is required.

Response

200 OK — Returns the updated task object with status set to completed and completed_at populated.
success
boolean
Always true for successful responses.
message
string
Confirmation message: "Tarea marcada como completada".
data
object
See Get Task for the full task object schema.

Error Responses

StatusDescription
403 ForbiddenThe authenticated user does not own this task and is not an admin.
404 Not FoundNo task with the given task_id exists.

Example

curl -X POST "https://task-forge-gbd6h8gtg8hchve9.chilecentral-01.azurewebsites.net/api/tasks/42/complete" \
  -H "Authorization: Bearer <access_token>"
Example response:
{
  "success": true,
  "message": "Tarea marcada como completada",
  "data": {
    "id": 42,
    "title": "Write API documentation",
    "description": "Cover all endpoints with examples",
    "status": "completed",
    "priority": "high",
    "due_date": "2024-11-30T23:59:59",
    "completed_at": "2024-11-28T16:45:00",
    "is_overdue": false,
    "is_completed": true,
    "created_at": "2024-10-01T09:00:00",
    "updated_at": "2024-11-28T16:45:00",
    "user_id": 7,
    "tags": [
      { "id": 3, "name": "docs" }
    ]
  }
}

Build docs developers (and LLMs) love