TrySetGotrysetgo.

API Documentation

Browse all REST API endpoints grouped by feature modules.

List Project Templates

Retrieves a list of all templates (pages) associated with a specific project, ordered by creation date (descending).

GET/api/projects/:projectId/templates

Request Parameters

NameTypeDescription
projectIdstringThe unique identifier of the project.

Success Response – 200

[
  {
    "id": "template_uuid_1",
    "name": "Homepage",
    "layout": [/* ... array of component objects ... */],
    "created_at": "2023-01-01T12:00:00Z",
    "updated_at": "2023-01-01T12:00:00Z"
  },
  /* ... more templates ... */
]

Error Responses

Status: 404
{ "error": "Project with ID {projectId} not found." }
Status: 500
{ "error": "Server error", "details": "..." }

Create New Template

Creates a new template (page) within a specified project.

POST/api/projects/:projectId/templates

Request Parameters

NameTypeDescription
projectIdstringThe unique identifier of the project.

Request Body

{
  "layoutType": "string (optional, e.g., '1', '2', '3')",
  "templateName": "string (optional, defaults if not provided)",
  "initialLayout": "array (optional, array of component objects)"
}

Example

{
  "templateName": "About Us",
  "initialLayout": []
}

Success Response – 201

{
  "id": "new_template_uuid",
  "project_id": "projectId",
  "name": "About Us",
  "layout": [],
  "created_at": "...",
  "updated_at": "..."
}

Error Responses

Status: 400
{ "error": "Invalid 'layoutType'. Must be '1', '2', or '3'." }
Status: 404
{ "error": "Project with ID {projectId} not found." }
Status: 500
{ "error": "Server error", "details": "..." }

Get Template Details

Retrieves the full details of a specific template by its ID.

GET/api/projects/templates/:templateId

Request Parameters

NameTypeDescription
templateIdstringThe unique identifier of the template.

Success Response – 200

{
  "id": "template_uuid",
  "project_id": "project_uuid",
  "name": "Homepage",
  "layout": [/* ... elements ... */],
  "global_styles": {/* ... styles ... */},
  "created_at": "...",
  "updated_at": "..."
}

Error Responses

Status: 404
{ "error": "Template with ID {templateId} not found." }
Status: 500
{ "error": "Server error", "details": "..." }

Update Template Layout

Updates the layout (component structure) and global styles of a specific template.

PUT/api/projects/templates/:templateId/layout

Request Parameters

NameTypeDescription
templateIdstringThe unique identifier of the template.

Request Body

{
  "layout": "array (required, array of component objects)",
  "global_styles": "object (optional)"
}

Example

{
  "layout": [/* ... new elements ... */],
  "global_styles": { "backgroundColor": "#ffffff" }
}

Success Response – 200

{
  "message": "Layout updated successfully.",
  "template": { /* ... updated template object ... */ }
}

Error Responses

Status: 400
{ "error": "Invalid or missing 'layout' array in request body." }
Status: 404
{ "error": "Template with ID {templateId} not found." }
Status: 500
{ "error": "Failed to update layout", "details": "..." }

Delete Template

Deletes a specific template by its ID.

DELETE/api/projects/templates/:templateId

Request Parameters

NameTypeDescription
templateIdstringThe unique identifier of the template.

Success Response – 200

{ "message": "Template deleted successfully." }

Error Responses

Status: 400
{ "message": "Template ID is required." }
Status: 404
{ "message": "Template with ID {templateId} not found." }
Status: 500
{ "message": "An error occurred while deleting the template." }

Create Templates in Batch

Creates multiple templates for a project from provided page data (e.g., imported file structures). If page content is provided, it creates a SourceCodeViewer component. If filePath is provided, it attempts to fetch content from project_files.

POST/api/projects/:projectId/templates/batch

Request Parameters

NameTypeDescription
projectIdstringThe unique identifier of the project.

Request Body

{
  "pages": [
    {
      "templateName": "string (optional, name for the new template)",
      "name": "string (optional, alternative name if templateName is missing)",
      "filePath": "string (optional, path of the source file)",
      "content": "string (optional, direct content for the template)"
    }
    /* ... more page objects ... */
  ]
}

Example

{
  "pages": [
    { "templateName": "Index Page", "filePath": "public/index.html" },
    { "templateName": "About Page Content", "content": "<h1>About Us</h1><p>Content here.</p>" }
  ]
}

Success Response – 201

{
  "message": "{count} templates created successfully.",
  "templates": [ /* ... array of created template objects ... */ ]
}

Error Responses

Status: 400
{ "error": "No pages provided for template creation." }
Status: 404
{ "error": "Project with ID {projectId} not found." }
Status: 500
{ "error": "Server error during batch template creation.", "details": "..." }

Get Project Page Structure

Retrieves a list of files marked as "page" type for a project. Used for UI like import review.

GET/api/projects/:projectId/pages

Request Parameters

NameTypeDescription
projectIdstringThe unique identifier of the project.

Success Response – 200

{
  "pages": [
    { "file_path": "public/index.html", "name": "index.html" },
    { "file_path": "public/about.html", "name": "about.html" }
    /* ... more page objects ... */
  ]
}

Error Responses

Status: 500
{ "error": "Failed to fetch project page structure.", "details": "..." }

List Master Templates

Retrieves a list of all predefined master templates available in the system.

GET/api/master-templates

Success Response – 200

[
  {
    "id": "master_template_uuid_1",
    "name": "Hero Section - Centered",
    "category": "Page Sections",
    "description": "A prominent hero section...",
    "icon": "StarIcon",
    "structure": [/* ... array of component objects ... */]
  },
  /* ... more master templates ... */
]

Error Responses

Status: 500
{ "error": "Server error", "details": "..." }

List All Projects

Retrieves a list of all projects the authenticated user has access to.

GET/api/projects

Success Response – 200

[/* ... project objects ... */]

Error Responses

Status: 500
{ "error": "Server error" }

Create Project

Creates a new project.

POST/api/projects

Request Body

{ "name": "string (required)", "description": "string (optional)" }

Success Response – 201

{ /* ... new project object ... */ }

Error Responses

Status: 500
{ "error": "Server error" }

Get Project Details

Retrieves details for a specific project.

GET/api/projects/:projectId

Request Parameters

NameTypeDescription
projectIdstringProject ID

Success Response – 200

{ /* ... project object ... */ }

Error Responses

Status: 404
{ "error": "Project not found" }
Status: 500
{ "error": "Server error" }

Update Project

Updates details of a specific project.

PUT/api/projects/:projectId

Request Parameters

NameTypeDescription
projectIdstringProject ID

Request Body

{ "name": "string (optional)", "description": "string (optional)" }

Success Response – 200

{ /* ... updated project object ... */ }

Error Responses

Status: 404
{ "error": "Project not found" }
Status: 500
{ "error": "Server error" }

Delete Project

Deletes a specific project and all its associated data.

DELETE/api/projects/:projectId

Request Parameters

NameTypeDescription
projectIdstringProject ID

Success Response – 200

{ "message": "Project deleted successfully" }

Error Responses

Status: 404
{ "error": "Project not found" }
Status: 500
{ "error": "Server error" }

Get Project Settings

Retrieves the site settings for a specific project.

GET/api/projects/:projectSlug/settings

Request Parameters

NameTypeDescription
projectSlugstringProject ID

Success Response – 200

{ /* ... project settings object ... */ }

Error Responses

Status: 500
{ "error": "Server error" }

Update Project Settings

Updates the site settings for a specific project.

PUT/api/projects/:projectSlug/settings

Request Parameters

NameTypeDescription
projectSlugstringProject ID

Request Body

{ /* ... project settings object ... */ }

Success Response – 200

{ /* ... updated project settings object ... */ }

Error Responses

Status: 500
{ "error": "Server error" }

User Registration

Registers a new user.

POST/api/auth/register

Request Body

{ "email": "string", "password": "string", "full_name": "string" }

Success Response – 201

{ "user": { /* user object */ }, "session": { /* session object */ } }

User Login

Logs in an existing user.

POST/api/auth/login

Request Body

{ "email": "string", "password": "string" }

Success Response – 200

{ "user": { /* user object */ }, "session": { /* session object */ } }

User Logout

Logs out the current user.

POST/api/auth/logout

Success Response – 200

{ "message": "Logged out successfully" }

Get Session

Retrieves the current user session if authenticated.

GET/api/auth/session

Success Response – 200

{ "user": { /* user object */ }, "session": { /* session object */ } }

Error Responses

Status: 401
{ "error": "Not authenticated" }