run.phpThis script retrieves a specific workflow run by its ID.
Endpoint: /api/run.php?id={id}
Methods:
GET: Retrieve a specific workflow run.Parameters:
id (integer): The ID of the workflow run to fetch.Response:
200: JSON object containing the workflow run details.400: Missing id parameter.404: Workflow run not found.500: Internal server error.runs.phpThis script retrieves all workflow runs for a specific workflow ID.
Endpoint: /api/runs.php?id={workflow_id}
Methods:
GET: Retrieve all workflow runs for a specific workflow ID.Parameters:
id (integer): The ID of the workflow to fetch runs for.Response:
200: JSON array containing workflow runs.400: Missing id parameter.404: No workflow runs found.500: Internal server error.user_workflows.phpThis script retrieves all workflows owned by a specific user.
Endpoint: /api/user_workflows.php?id={user_id}
Parameters:
id (string): The ID of the user to fetch workflows for.Response:
200: JSON array containing user workflows. Example:
[
{
"id": 1,
"name": "Sample",
"description": "Calculation and If Flow",
"created_by": "sampleuserid",
"input": "{}",
"created_at": "2025-05-31 09:39:43",
"modified_at": "2025-06-28 06:31:12"
}
]
400: Missing id parameter.404: No workflows found.500: Internal server error.workflow.phpThis script retrieves detailed information about a specific workflow, including its nodes and edges, allows creating new workflows, and updating existing workflows.
Endpoint: /api/workflow.php
Methods:
GET: Retrieve detailed information about a specific workflow, including its nodes and edges.POST: Create a new workflow.PUT: Update an existing workflow.Parameters:
GET: id (integer): The ID of the workflow to fetch.POST: JSON object with name (string) and description (string).PUT: JSON object with id (integer) and fields to update.Response:
200: JSON object containing workflow details, nodes, and edges (GET), or success message (PUT).201: Workflow created successfully (POST).400: Missing or invalid parameters.404: Workflow not found (GET).500: Internal server error.token.phpThis script handles token creation and retrieval.
Endpoint: /api/token.php
Methods:
POST: Create a new token.GET: Retrieve token details.Parameters:
POST: JSON object with user_id (string), workflow_id (string), and optionally run_id (string).GET: token (string): The token to fetch details for.Response:
200: JSON object containing token details (GET) or the generated token (POST).400: Missing or invalid parameters.404: Token not found (GET).500: Internal server error.save.phpThis script updates workflow nodes and edges based on the provided JSON input.
Endpoint: /api/save.php
Methods:
POST: Update workflow nodes and edges.Parameters:
id (integer): The ID of the workflow to update.nodes (array): Array of node objects, each containing id, type, name, config, and display.edges (array): Array of edge objects, each containing id, from_node_id, to_node_id, and if_condition.Example Request:
POST https://localhost/hackathon/workflow/api/save.php HTTP/1.1
Content-Type: application/json
{
"id": 2,
"nodes": [
{
"id": "X001",
"name": "Start Node",
"type": "start",
"config": "{}",
"display": "{}"
},
{
"id": "X002",
"name": "End Node",
"type": "end",
"config": "{}",
"display": "{}"
}
],
"edges": [
{
"id": "E001",
"from_node_id": "X001",
"to_node_id": "X002",
"if_condition": null
}
]
}
Response:
200: Workflow nodes and edges updated successfully.400: Missing or invalid parameters.500: Internal server error.start.phpThis script starts a workflow using the provided workflow ID and input data.
Endpoint: /api/start.php?id={workflow_id}
Methods:
POST: Start a workflow with the given ID and input data.Parameters:
id (integer): The ID of the workflow to start.data (JSON object): Input data for the workflow.Response:
200: JSON object containing the workflow data.400: Missing or invalid parameters.404: Workflow not found.500: Internal server error.user_dashboard.phpThis script retrieves user dashboard statistics based on different periods.
Endpoint: /api/user_dashboard.php?id={user_id}
Methods:
GET: Retrieve user dashboard statistics.Parameters:
id (string): The ID of the user to fetch dashboard statistics for.Response:
200: JSON array containing dashboard statistics for different periods.400: Missing id parameter.404: No data found for the specified user ID.500: Internal server error.Nodes are represented as JSON objects with the following fields:
id: Unique identifier for the node.type: Type of the node (e.g., start, end, api, etc.).name: Name of the node.config: JSON object containing configuration details for the node.display: JSON object containing UI display properties for the node.To use these scripts, make HTTP GET requests to the specified endpoints with the required parameters.
Example using curl:
curl "http://localhost/hackathon/workflow/api/run.php?id=1"
curl "http://aiworkflow.cairns.co.za/api/run.php?id=1"