Skip to main content

Project Management

POST /api/user/project

Create a new project for the authenticated user.

Authentication

Requires a valid NextAuth session.

Request Body

string
required
The ID of the user creating the project
string
required
The name of the project (e.g., “Untitled Project”)

Response (200)

Example Request


GET /api/user/project

Get all projects for the authenticated user.

Authentication

Requires a valid NextAuth session.

Query Parameters

string
required
The ID of the user whose projects to retrieve

Response (200)

Error Responses

400 - Missing User ID
401 - Unauthorized

Example Request


Canvas Management

POST /api/user/project/canvas

Save or update the canvas state for a project. Uses upsert operation.

Authentication

Requires a valid NextAuth session.

Request Body

string
Canvas ID (if updating existing canvas). Generated automatically if not provided.
string
required
The ID of the project this canvas belongs to
array
required
Array of node objects representing the canvas nodes
array
required
Array of edge objects representing connections between nodes

Response (200)

Returns the saved canvas object:

Example Request


GET /api/user/project/canvas

Load the canvas state for a project.

Authentication

Requires a valid NextAuth session.

Query Parameters

string
required
The ID of the project whose canvas to retrieve

Response (200)

Returns null if no canvas exists for the project.

Error Responses

400 - Missing Project ID
401 - Unauthorized

Example Request


Database Schema

Projects Collection

Container: projects Partition Key: userId

Canvas Collection

Container: canvas Partition Key: projectId

Auto-Save Behavior

The canvas automatically saves every second (with debounce) when changes are made:
This ensures that:
  • Changes are saved automatically
  • API calls are throttled to prevent excessive requests
  • Users don’t lose work on accidental page closure