Overview
The user_workflows table stores workflow configurations for each user. Each user can have one workflow that contains elements (agents) and their connections.
Table Schema
Unique identifier for the workflow record (auto-generated UUID)
Foreign key reference to the authenticated user
Display name of the workflow (default: “My Workflow”)
Complete workflow data structure containing elements and connections Array of workflow elements (agents) Unique element identifier
Element type (always “agent”)
Reference to the agent configuration
Canvas position with x and y coordinates
Agent metadata including name, description, color, and icon
Array of connections between workflow elements Show connection properties
Unique connection identifier
Additional connection metadata
ISO 8601 timestamp of when the workflow was created
ISO 8601 timestamp of the last workflow update
TypeScript Interface
export interface WorkflowElement {
id : string ;
type : 'agent' ;
agentId : string ;
position : Position ;
data : {
name : string ;
description : string ;
color ?: string ;
icon ?: string ;
};
}
export interface Connection {
id : string ;
sourceId : string ;
targetId : string ;
type : string ;
data ?: any ;
}
export interface Workflow {
id : string ;
name : string ;
elements : WorkflowElement [];
connections : Connection [];
}
export interface Position {
x : number ;
y : number ;
}
CRUD Operations
Save Workflow
Saves or updates the user’s workflow. If a workflow already exists for the user, it will be updated; otherwise, a new workflow is created.
Endpoint: manage-workflows
Request:
{
"action" : "save" ,
"workflowData" : {
"id" : "workflow-1" ,
"name" : "My Workflow" ,
"elements" : [
{
"id" : "element-1" ,
"type" : "agent" ,
"agentId" : "agent-1" ,
"position" : { "x" : 100 , "y" : 100 },
"data" : {
"name" : "Data Processor" ,
"description" : "Processes incoming data" ,
"color" : "#3B82F6" ,
"icon" : "processor"
}
}
],
"connections" : [
{
"id" : "conn-1" ,
"sourceId" : "element-1" ,
"targetId" : "element-2" ,
"type" : "default"
}
]
}
}
Response:
{
"message" : "Workflow saved successfully" ,
"workflow" : {
"id" : "uuid" ,
"user_id" : "user-uuid" ,
"name" : "My Workflow" ,
"data" : { /* workflow data */ },
"created_at" : "2026-03-03T10:00:00Z" ,
"updated_at" : "2026-03-03T10:00:00Z"
}
}
Load Workflow
Retrieves the user’s saved workflow.
Endpoint: manage-workflows
Request:
Response:
{
"success" : true ,
"workflow" : {
"id" : "uuid" ,
"user_id" : "user-uuid" ,
"name" : "My Workflow" ,
"data" : { /* workflow data */ },
"created_at" : "2026-03-03T10:00:00Z" ,
"updated_at" : "2026-03-03T10:00:00Z"
}
}
If no workflow exists:
{
"success" : true ,
"workflow" : null
}
Relationships
user_id → References the authenticated user’s ID
elements[].agentId → References agent configurations in the agent_configs table
connections → Links workflow elements together, stored separately in agent_connections table
Constraints
Each user can have only one workflow record (enforced by checking existing workflows before insert/update)
The user_id field must reference a valid authenticated user
The data field must contain valid JSON with the Workflow interface structure