Skip to main content
Create a new task in the PhotoFlow system or update an existing task if a taskID is provided.

Endpoint

POST /api/createNewTask

Request Body

taskID
number
The ID of an existing task to update. If provided, the task will be updated instead of creating a new one.
task
string
required
The name or title of the photography order task.
dueAt
string
required
The due date for the task in ISO 8601 format (e.g., "2026-03-15T10:00:00Z").
additional_information
string
required
Additional details or notes about the task.
status
string
required
The current status of the task (e.g., "pending", "in-progress", "completed").
taskColumn
string
The column or category for the task. Only used when updating a task with taskID.

Response

success
string
Returns "Successful!" when the task is created or updated successfully.
error
string
Returns "Invalid!" if the operation fails.

Example: Create New Task

curl -X POST http://localhost:5173/api/createNewTask \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Wedding photoshoot - Johnson family",
    "dueAt": "2026-03-15T10:00:00Z",
    "additional_information": "Outdoor ceremony at Central Park, 2-3 hours",
    "status": "pending"
  }'

Example: Update Existing Task

curl -X POST http://localhost:5173/api/createNewTask \
  -H "Content-Type: application/json" \
  -d '{
    "taskID": 42,
    "task": "Wedding photoshoot - Johnson family (Updated)",
    "dueAt": "2026-03-16T14:00:00Z",
    "additional_information": "Indoor backup location arranged",
    "status": "in-progress",
    "taskColumn": "2"
  }'

Response Example

"Successful!"

Error Response

"Invalid!"

Behavior Notes

The dueAt field is automatically converted to a JavaScript Date object before being stored in the database. Ensure you pass a valid ISO 8601 date string.
When creating a new task (without taskID), the taskColumn field is ignored. It uses the default value from the database schema.
After successfully creating or updating a task, emit a database-change event via Socket.io to notify other clients. See Real-time Updates for details.

Database Schema

The task is stored with the following structure:
model Tasks {
  id                     Int      @id @default(autoincrement())
  created_at             DateTime @default(now())
  dueAt                  DateTime
  task                   String
  additional_information String
  status                 String
  is_finished            Boolean  @default(false)
  taskColumn             String   @default("1")
  amount_of_comments     Int      @default(0)
}

Source Reference

Implementation: src/routes/api/(tasks-clients)/createNewTask/+server.ts:5

Build docs developers (and LLMs) love