> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/RafaeltiMoreira/mais-habito-api/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete task

> Permanently delete a task owned by the authenticated user.

## Path parameters

<ParamField path="taskId" type="number" required>
  ID of the task to delete.
</ParamField>

## Response

**204 No Content** — The task was deleted. The response body is empty.

All task completion records associated with this task are also deleted automatically via the database `ON DELETE CASCADE` constraint.

## Errors

| Status | Condition                                        |
| ------ | ------------------------------------------------ |
| `400`  | The task exists but belongs to a different user. |
| `404`  | No task found with the given `taskId`.           |
| `401`  | Missing or invalid authentication token.         |

<RequestExample>
  ```bash cURL theme={null}
  curl --request DELETE \
    --url http://localhost:3000/api/tasks/42 \
    --header 'Authorization: Bearer <token>'
  ```
</RequestExample>

<ResponseExample>
  ```text 204 theme={null}
  (empty body)
  ```

  ```json 404 theme={null}
  {
    "error": "Task not found"
  }
  ```

  ```json 400 theme={null}
  {
    "error": "You don't have permission to delete this task"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "User not authenticated"
  }
  ```
</ResponseExample>
