In this guide, we cover "Flowork Engine REST API — Complete Port 5000 Reference" for the Flowork AI Knowledge Base. Category: general. Language: go.
Architecture Overview
Go Engine (main.go) runs GoFiber v2 HTTP server on port 5000. All endpoints accept JSON. CORS is configured for localhost:5000, localhost:5173-5175, floworkos.com, and the Chrome extension. Body limit is 500MB for large file uploads.
Key Patterns
- POST /api/ai-write — Write files to app/node directory. Body: { app_id, output_type, files: { filename: content } }
- POST /api/ai-exec — Execute terminal command in app directory. Body: { app_id, output_type, command }. Timeout: 10s
- GET /api/ai-read/:type/:id — Read all text files from an app/node. Skips binary files (.webp,.png,.exe,.flow)
- POST /api/ai-smart-patch — Line-based smart patching for precise code edits
- GET /api/ai-context/:type/:id — Full project context in one API call
- GET /api/local-apps — List all installed apps with schema metadata
- GET /api/local-nodes — List all installed workflow nodes
- POST /api/upload — Upload .flow/.nflow package files
- POST /api/workflow/save — Create/save workflow definition
- POST /api/workflow/execute/:id — Execute a saved workflow
- POST /api/terminal/start — Start async terminal session (no timeout)
- GET /api/terminal/status/:id — Stream terminal output
- POST /api/git — Git operations (init/status/diff/commit/revert)
Project Structure
├── main.go
Implementation Details
POST /api/ai-write
// Request
POST http://localhost:5000/api/ai-write
{
"app_id": "my-stock-scanner",
"output_type": "app", // or "node"
"files": {
"index.html": "...",
"manifest.json": "{...}",
"systemBridge.js": "..."
}
}
// Response
{ "status": "success", "written_files": ["index.html","manifest.json","systemBridge.js"], "total_files": 3 }
POST /api/ai-exec
// Request
POST http://localhost:5000/api/ai-exec
{ "app_id": "my-app", "output_type": "app", "command": "pip install requests" }
// Response: { "status": "success", "output": "Successfully installed requests-2.31.0", "error": "" }
// Note: 10 second timeout. For long processes use /api/terminal/start instead.
Troubleshooting
- ⚠️ ai-exec timeout is 10 seconds → use terminal/start for long-running processes
- ⚠️ ai-write sanitizes filenames with filepath.Base() → no directory traversal possible
- ⚠️ ai-read skips binary files (.webp,.png,.exe) → returns '[BINARY FILE - SKIPPED]'
- ⚠️ Body limit is 500MB but individual files should stay under 5MB for performance
Summary
This article covers general patterns for Flowork OS. Generated by Flowork AI from verified system architecture.