Workflow API Documentation

API Endpoints

1. run.php

This script retrieves a specific workflow run by its ID.

Endpoint: /api/run.php?id={id}

Methods:

Parameters:

Response:

2. runs.php

This script retrieves all workflow runs for a specific workflow ID.

Endpoint: /api/runs.php?id={workflow_id}

Methods:

Parameters:

Response:

3. user_workflows.php

This script retrieves all workflows owned by a specific user.

Endpoint: /api/user_workflows.php?id={user_id}

Parameters:

Response:

4. workflow.php

This 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:

Parameters:

Response:

5. token.php

This script handles token creation and retrieval.

Endpoint: /api/token.php

Methods:

Parameters:

Response:

6. save.php

This script updates workflow nodes and edges based on the provided JSON input.

Endpoint: /api/save.php

Methods:

Parameters:

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:

7. start.php

This script starts a workflow using the provided workflow ID and input data.

Endpoint: /api/start.php?id={workflow_id}

Methods:

Parameters:

Response:

8. user_dashboard.php

This script retrieves user dashboard statistics based on different periods.

Endpoint: /api/user_dashboard.php?id={user_id}

Methods:

Parameters:

Response:

Node Structure

Nodes are represented as JSON objects with the following fields:

Usage

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"