Skip to main content

PUT /api/tasks/{task_id}

Also accepts PATCH /api/tasks/{task_id}. Updates one or more fields on an existing task. Regular users can only update tasks they own; admin users can update any task. All request body fields are optional — only the fields present in the request body will be modified. When status is updated to completed, the completed_at timestamp is automatically set to the current UTC time. If status is changed away from completed, completed_at is cleared. Providing a tags array replaces all existing tag associations on the task.

Authentication

Authorization: Bearer <access_token>

Path Parameters

task_id
integer
required
The unique ID of the task to update.

Request Body

title
string
New task title. Must be between 1 and 200 characters.
description
string
New task description. Maximum 5000 characters. Pass null or an empty string to clear the description.
status
string
New task status. Allowed values: pending, in_progress, completed, cancelled.
priority
string
New task priority. Allowed values: low, medium, high, urgent.
due_date
string
New due date in ISO 8601 format, e.g. "2024-12-31T23:59:59". Pass null or an empty string to clear the due date.
tags
array of integers
Replaces all existing tag associations. Pass an empty array [] to remove all tags.

Response

200 OK — Returns the updated task object.
success
boolean
Always true for successful responses.
message
string
Confirmation message.
data
object
The updated task object. See Get Task for the full schema.

Error Responses

StatusDescription
400 Bad RequestA field failed validation (e.g. title too long, invalid enum value, unparseable date).
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 PATCH "https://task-forge-gbd6h8gtg8hchve9.chilecentral-01.azurewebsites.net/api/tasks/42" \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "in_progress",
    "priority": "urgent",
    "due_date": "2024-11-15T17:00:00"
  }'
Example response:
{
  "success": true,
  "message": "Tarea actualizada con exito",
  "data": {
    "id": 42,
    "title": "Write API documentation",
    "description": "Cover all endpoints with examples",
    "status": "in_progress",
    "priority": "urgent",
    "due_date": "2024-11-15T17:00:00",
    "completed_at": null,
    "is_overdue": false,
    "is_completed": false,
    "created_at": "2024-10-01T09:00:00",
    "updated_at": "2024-10-20T11:30:00",
    "user_id": 7,
    "tags": [
      { "id": 3, "name": "docs" }
    ]
  }
}

Build docs developers (and LLMs) love