Endpoint
Retrieves a single task by its UUID. Returns the complete task object with all properties.
Path Parameters
The unique identifier (UUID) of the task to retrieve.Example: 550e8400-e29b-41d4-a716-446655440000
Response
Unique identifier (UUID v4) of the task.
The task title (3-25 characters).
Optional task description (max 25 characters).
Completion status of the task.
UUID of the assigned category or "uncategorized".
ISO 8601 timestamp of task creation.
ISO 8601 timestamp of last update.
ISO 8601 timestamp when task was completed, or null if incomplete.
Status Codes
- 200 OK - Task found and returned successfully
- 404 Not Found - No task exists with the provided ID
Examples
curl http://localhost:3000/api/tasks/550e8400-e29b-41d4-a716-446655440000
Response Examples
{
"_id": "550e8400-e29b-41d4-a716-446655440000",
"title": "Write API documentation",
"description": "Create comprehensive docs",
"completed": true,
"categoryId": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
"createdAt": "2026-03-11T10:00:00.000Z",
"updatedAt": "2026-03-11T16:00:00.000Z",
"finishedAt": "2026-03-11T16:00:00.000Z"
}
Usage Notes
The task ID must be a valid UUID v4 format. Invalid formats will result in the task not being found (404 response).
This endpoint is useful for:
- Displaying task details in a detail view
- Verifying task existence before performing operations
- Refreshing task data after updates
Common Use Cases
Check if Task Exists
async function taskExists(taskId) {
const response = await fetch(`http://localhost:3000/api/tasks/${taskId}`);
return response.status === 200;
}
if (await taskExists('550e8400-e29b-41d4-a716-446655440000')) {
console.log('Task exists!');
}
Get Task with Category Details
async function getTaskWithCategory(taskId) {
const taskResponse = await fetch(`http://localhost:3000/api/tasks/${taskId}`);
if (!taskResponse.ok) {
return null;
}
const task = await taskResponse.json();
// If task has a category, fetch category details
if (task.categoryId && task.categoryId !== 'uncategorized') {
const categoryResponse = await fetch(
`http://localhost:3000/api/taskCategories/${task.categoryId}`
);
if (categoryResponse.ok) {
task.category = await categoryResponse.json();
}
}
return task;
}
Display Task Status
async function displayTaskStatus(taskId) {
const response = await fetch(`http://localhost:3000/api/tasks/${taskId}`);
if (response.status === 404) {
console.log('Task not found');
return;
}
const task = await response.json();
console.log(`Task: ${task.title}`);
console.log(`Status: ${task.completed ? '✓ Completed' : '○ Pending'}`);
if (task.finishedAt) {
const finishedDate = new Date(task.finishedAt);
console.log(`Finished: ${finishedDate.toLocaleString()}`);
}
}