Tasks - Usage Examples

Last Updated: 2026-02-27

Authentication

# Step 1: Obtain token
curl -s -X POST https://api.djanity.com/auth/login/ \
  -H "Content-Type: application/json" \
  -d '{"username": "[email protected]", "password": "..."}'
# Returns: {"access": "<jwt>", "refresh": "<jwt>"}

# Step 2: All subsequent requests use:
# -H "Authorization: Bearer <token>"

Tasks

List all tasks

curl -s https://api.djanity.com/tasks/ \
  -H "Authorization: Bearer <token>"

Response:

[
  {
    "id": "task-uuid-001",
    "task_id": "task_12345",
    "title": "Restock dairy section",
    "description": "Restock milk, yogurt, and cheese products before 09:00",
    "assigned_to": "employee-uuid-001",
    "assigned_to_name": "Jane Smith",
    "store": "store-uuid-001",
    "store_name": "London Flagship",
    "priority": "high",
    "status": "pending",
    "due_date": "2026-02-28",
    "completed_by": null,
    "completed_by_name": null,
    "completed_at": null,
    "created_at": "2026-02-27T08:00:00Z"
  }
]

Retrieve a task (enhanced)

The retrieve endpoint uses TaskService.get_task_with_details(), which returns nested objects and computed fields.

curl -s https://api.djanity.com/tasks/task_12345/ \
  -H "Authorization: Bearer <token>"

Response:

{
  "id": "task-uuid-001",
  "task_id": "task_12345",
  "title": "Restock dairy section",
  "description": "Restock milk, yogurt, and cheese products before 09:00",
  "priority": "high",
  "status": "pending",
  "due_date": "2026-02-28",
  "completed_at": null,
  "created_at": "2026-02-27T08:00:00Z",
  "assigned_to": {
    "id": "employee-uuid-001",
    "name": "Jane Smith",
    "employee_id": "EMP-001"
  },
  "completed_by": null,
  "store": {
    "id": "store-uuid-001",
    "name": "London Flagship",
    "store_code": "LON001"
  },
  "is_overdue": false,
  "days_since_created": 0
}

Error — task not found:

{"error": "Task not found"}

Create a task

curl -s -X POST https://api.djanity.com/tasks/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Deep clean refrigerators — dairy aisle",
    "description": "Remove all stock, clean shelves and gaskets, restock FIFO",
    "assigned_to": "employee-uuid-001",
    "store": "store-uuid-001",
    "priority": "medium",
    "status": "pending",
    "due_date": "2026-03-01"
  }'

Response (201 Created):

{
  "id": "task-uuid-002",
  "task_id": "task_67890",
  "title": "Deep clean refrigerators — dairy aisle",
  "assigned_to": "employee-uuid-001",
  "assigned_to_name": "Jane Smith",
  "store": "store-uuid-001",
  "store_name": "London Flagship",
  "priority": "medium",
  "status": "pending",
  "due_date": "2026-03-01",
  "completed_by": null,
  "completed_by_name": null,
  "completed_at": null,
  "created_at": "2026-02-27T10:30:00Z"
}

Update task status (partial update)

Mark a task as in progress:

curl -s -X PATCH https://api.djanity.com/tasks/task_12345/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"status": "in_progress"}'

Complete a task:

curl -s -X PATCH https://api.djanity.com/tasks/task_12345/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "completed",
    "completed_by": "employee-uuid-001"
  }'

Reassign a task:

curl -s -X PATCH https://api.djanity.com/tasks/task_12345/ \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"assigned_to": "employee-uuid-002"}'

Delete a task

curl -s -X DELETE https://api.djanity.com/tasks/task_12345/ \
  -H "Authorization: Bearer <token>"

Response: 204 No Content


Was this page helpful?