Overview
Deletes a flow node from the conversation tree. This operation also removes all child nodes recursively, ensuring no orphaned nodes remain.
This is a destructive operation. Deleted nodes cannot be recovered. Make sure to export your flows before performing bulk deletions.
Request
curl "https://your-domain.com/api/delete-flow.php?id=42"
Response
Indicates if the node was deleted successfully
Error description (only present on failure)
Success Response Example
Error Response Examples
{
"success": false,
"error": "ID de nodo requerido"
}
{
"success": false,
"error": "Error al eliminar el nodo"
}
Error Handling
| Status Code | Description |
|---|
| 200 | Node deleted successfully (or node didn’t exist) |
| 400 | Missing or invalid node ID |
| 500 | Internal server error |
Behavior Details
Cascade Deletion
When you delete a node, the system:
- Identifies all child nodes recursively
- Deletes all descendants first (bottom-up)
- Deletes the target node last
- Maintains referential integrity
Example Flow Structure
Node 1 (root)
├── Node 2 (menu)
│ ├── Node 3 (question)
│ │ └── Node 4 (message)
│ └── Node 5 (question)
└── Node 6 (message)
Deletions:
- Delete Node 2: Also deletes Nodes 3, 4, and 5
- Delete Node 3: Also deletes Node 4
- Delete Node 1: Deletes the entire tree (all nodes)
- Delete Node 4: Only deletes Node 4 (no children)
Implementation Details
The endpoint:
- Validates the
id query parameter is present and numeric
- Calls
FlowBuilderService->deleteNode($nodeId)
- The service method recursively deletes all descendants
- Logs the deletion operation
- Returns success response
Source: api/delete-flow.php:11-20
Safety Considerations
No Confirmation: The deletion happens immediately without confirmation. Implement a confirmation dialog in your UI.
No Undo: There is no built-in undo mechanism. Consider implementing:
- Soft deletes (marking nodes as inactive)
- Flow versioning
- Automatic backups before deletions
If the specified node ID doesn’t exist, the endpoint returns success: true (idempotent operation).
Use Cases
Remove Outdated Flow Branch
// Remove an entire conversation branch
const branchRootId = 15;
await fetch(`/api/delete-flow.php?id=${branchRootId}`);
Clear All Flows
// Get all root nodes and delete them
const { nodes } = await fetch('/api/get-flows.php').then(r => r.json());
const rootNodes = nodes.filter(n => n.parent_id === null);
for (const node of rootNodes) {
await fetch(`/api/delete-flow.php?id=${node.id}`);
}
Delete Single Leaf Node
// Remove a single node without children
const leafNodeId = 42;
await fetch(`/api/delete-flow.php?id=${leafNodeId}`);
Best Practices
Export before bulk deletes: Use the flow export feature before major changes
Delete leaf nodes first: When manually cleaning up, delete from bottom to top
Test in simulation: Verify flow changes using the simulate endpoint before deploying
Version control: Keep flow backups in version control as JSON exports