Flow Management
Endpoints for creating, managing, and executing automation flows.
Flow Listing
GET /api/flows
Gets all automation flows.
Query Parameters:
projectId: Filter by project IDlabelId: Filter by label IDlimit: Maximum number of flows to return (default: 50)offset: Number of flows to skip (default: 0)
Response:
{
"flows": [
{
"id": "flow-123",
"name": "Login Flow",
"description": "Automated login process",
"projectId": "project-456",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T01:00:00.000Z",
"stepCount": 5,
"executionCount": 25,
"lastExecutedAt": "2024-01-01T02:00:00.000Z"
}
],
"total": 1,
"limit": 50,
"offset": 0
}
GET /api/flows/:flowId
Gets a specific automation flow.
Parameters:
flowId: Flow identifier
Response:
{
"id": "flow-123",
"name": "Login Flow",
"description": "Automated login process",
"sequence": [
{
"action": "launch_app",
"packageName": "com.example.app"
},
{
"action": "type",
"text": "username",
"targetElement": "username field"
}
],
"settings": {
"timeBeforeSubflows": 0,
"timeAfterSubflows": 0,
"betweenFlowsDelaySeconds": 1
},
"projectId": "project-456",
"labels": ["login", "authentication"],
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T01:00:00.000Z"
}
GET /api/flows/:flowId/execution-history
Gets execution history for a specific flow.
Parameters:
flowId: Flow identifier
Query Parameters:
limit: Maximum executions to return (default: 20)offset: Number of executions to skip (default: 0)
Response:
{
"flowId": "flow-123",
"executions": [
{
"id": "exec-456",
"startedAt": "2024-01-01T02:00:00.000Z",
"completedAt": "2024-01-01T02:00:15.000Z",
"status": "success",
"deviceId": "device-789",
"duration": 15000,
"result": {
"stepsExecuted": 5,
"errors": []
}
}
],
"total": 25,
"limit": 20,
"offset": 0
}
GET /api/flows/:flowId/cache
Gets coordinate cache for a specific flow.
Parameters:
flowId: Flow identifier
Response:
{
"flowId": "flow-123",
"cache": {
"device-789": {
"elements": {
"login_button": {
"x": 540,
"y": 1200,
"confidence": 0.95,
"lastUpdated": "2024-01-01T02:00:00.000Z"
}
},
"lastAccessed": "2024-01-01T02:00:00.000Z"
}
}
}
GET /api/flows/:flowId/cache/setup-hooks
Gets setup hook cache for a flow.
Parameters:
flowId: Flow identifier
GET /api/flows/:flowId/cache/teardown-hooks
Gets teardown hook cache for a flow.
Parameters:
flowId: Flow identifier
GET /api/flows/export
Exports flows in various formats.
Query Parameters:
format: Export format (json, yaml, csv)projectId: Export flows from specific projectincludeCache: Include coordinate cache in export
Response: File download with exported flows.
GET /api/flows/stats
Gets flow statistics.
Response:
{
"totalFlows": 150,
"totalExecutions": 2500,
"successRate": 0.94,
"averageExecutionTime": 12500,
"mostUsedFlows": [
{
"flowId": "flow-123",
"name": "Login Flow",
"executionCount": 150
}
],
"recentActivity": [
{
"flowId": "flow-456",
"executedAt": "2024-01-01T02:00:00.000Z",
"status": "success"
}
]
}
Flow Creation and Modification
POST /api/flows
Creates a new automation flow.
Request Body:
{
"name": "New Login Flow",
"description": "Automated login for testing",
"sequence": [
{
"action": "launch_app",
"packageName": "com.example.app"
},
{
"action": "wait",
"duration": 2000
}
],
"projectId": "project-123",
"labels": ["login", "authentication"]
}
Response:
{
"success": true,
"flow": {
"id": "flow-789",
"name": "New Login Flow",
"createdAt": "2024-01-01T00:00:00.000Z"
}
}
PUT /api/flows/:flowId
Updates an existing flow.
Parameters:
flowId: Flow identifier
Request Body:
{
"name": "Updated Login Flow",
"description": "Updated automated login process",
"sequence": [
{
"action": "launch_app",
"packageName": "com.example.app"
}
]
}
Response:
{
"success": true,
"flow": {
"id": "flow-789",
"name": "Updated Login Flow",
"updatedAt": "2024-01-01T01:00:00.000Z"
}
}
PUT /api/flows/:flowId/cache
Updates flow coordinate cache.
Parameters:
flowId: Flow identifier
Request Body:
{
"deviceId": "device-123",
"elements": {
"login_button": {
"x": 540,
"y": 1200,
"confidence": 0.95
}
}
}
PUT /api/flows/:flowId/cache/setup-hooks
Updates setup hook cache.
PUT /api/flows/:flowId/cache/teardown-hooks
Updates teardown hook cache.
PUT /api/flows/:flowId/parsed-command
Updates parsed command for a flow.
Flow Execution
POST /api/flows/execute/:flowId
Executes a specific automation flow.
Parameters:
flowId: Flow identifier
Request Body:
{
"deviceId": "device-123",
"variables": {
"username": "testuser",
"password": "testpass"
},
"options": {
"timeout": 60000,
"continueOnError": false
}
}
Response:
{
"success": true,
"executionId": "exec-456",
"status": "running",
"startedAt": "2024-01-01T02:00:00.000Z"
}
POST /api/flows/execute-batch
Executes multiple flows in batch.
Request Body:
{
"flowIds": ["flow-123", "flow-456"],
"deviceId": "device-789",
"options": {
"parallel": false,
"delayBetweenFlows": 5000
}
}
Response:
{
"success": true,
"batchId": "batch-789",
"executions": [
{
"flowId": "flow-123",
"executionId": "exec-456",
"status": "queued"
}
]
}
POST /api/flows/duplicate/:flowId
Duplicates an existing flow.
Parameters:
flowId: Flow identifier
Request Body:
{
"name": "Login Flow Copy",
"includeCache": true
}
Response:
{
"success": true,
"originalFlowId": "flow-123",
"newFlowId": "flow-789",
"name": "Login Flow Copy"
}
POST /api/flows/reorder
Reorders flows (for UI organization).
Request Body:
{
"flowIds": ["flow-456", "flow-123", "flow-789"]
}
POST /api/import/flows
Imports flows from exported data.
Request Body:
{
"flows": [
{
"name": "Imported Flow",
"sequence": [...]
}
],
"projectId": "project-123"
}
Flow Deletion
DELETE /api/flows/:flowId
Deletes a flow.
Parameters:
flowId: Flow identifier
Response:
{
"success": true,
"message": "Flow deleted successfully"
}
DELETE /api/flows/:flowId/cache
Clears coordinate cache for a flow.
Parameters:
flowId: Flow identifier
DELETE /api/flows/:flowId/cache/setup-hooks
Clears setup hook cache.
DELETE /api/flows/:flowId/cache/teardown-hooks
Clears teardown hook cache.