Retrieve metrics and analytics for your workflows, including execution counts, success rates, and performance data. This endpoint helps you understand how your workflows are performing over time.
GET https://api.worqhat.com/flows/metrics
What Does This Endpoint Do?
This endpoint provides performance statistics about your workflows. Think of it like a fitness tracker for your automation - it tells you how many workflows ran, how successful they were, and how long they took to complete.
When to Use Workflow Metrics
You’ll find this endpoint useful when you need to:
- Monitor workflow health: Track success rates and identify failing workflows
- Optimize performance: Find workflows that are taking too long to execute
- Generate reports: Create dashboards showing workflow activity over time
- Troubleshoot issues: Identify patterns in workflow failures
- Capacity planning: Understand workflow usage to plan for scaling
How It Works
- You specify a date range to analyze (or use the defaults)
- You can optionally filter by workflow status (completed, failed, or in-progress)
- The API returns overall metrics and detailed statistics for individual workflows
Query Parameters
Start date for filtering in YYYY-MM-DD format. If not provided, defaults to the first day of the current month.Example: 2025-07-01
End date for filtering in YYYY-MM-DD format. If not provided, defaults to the last day of the current month.Example: 2025-07-24
Filter by workflow status. Must be one of: ‘completed’, ‘failed’, or ‘in_progress’. If not provided, returns metrics for workflows in all statuses.Example: completed
Response Fields Explained
Overall metrics for the requested workflows across the specified time period.
Total number of workflow executions during the period. This counts every time a workflow was triggered, regardless of outcome.
Success rate as a percentage (0-100). This shows what percentage of workflow executions completed successfully.
Average execution duration in milliseconds. This helps you understand how long your workflows typically take to run.
Error rate as a percentage (0-100). This is the percentage of workflow executions that failed.
Total number of workflow executions that resulted in an error.
Metrics broken down by individual workflows. This array contains detailed statistics for each workflow that ran during the period.
The unique identifier for the workflow.
The name of the workflow.
workflowMetrics[].executions
Number of times this specific workflow was executed during the period.
workflowMetrics[].successRate
Success rate for this specific workflow as a percentage (0-100).
workflowMetrics[].averageDuration
Average execution duration for this specific workflow in milliseconds.
Number of times this workflow resulted in an error.
workflowMetrics[].mostCommonError
The most frequently occurring error type for this workflow.
The time period that the metrics cover.
Code Examples
Example 1: Basic Metrics Query
This example shows how to get workflow metrics for a specific date range and status.
import Worqhat from 'worqhat';
// Initialize the client with your API key
const client = new Worqhat({
apiKey: process.env.WORQHAT_API_KEY, // Always use environment variables for API keys
});
async function getWorkflowMetrics() {
try {
// Call the getMetrics method
const response = await client.workflows.getMetrics({
start_date: '2025-07-01', // Start date in YYYY-MM-DD format
end_date: '2025-07-24', // End date in YYYY-MM-DD format
status: 'completed' // Only include completed workflows
});
// Handle the successful response
console.log(`Total Executions: ${response.metrics.totalExecutions}`);
console.log(`Success Rate: ${response.metrics.successRate}%`);
console.log(`Average Duration: ${response.metrics.averageDuration}ms`);
// Log metrics for individual workflows
response.workflowMetrics.forEach(workflow => {
console.log(`\nWorkflow: ${workflow.name} (${workflow.id})`);
console.log(` Executions: ${workflow.executions}`);
console.log(` Success Rate: ${workflow.successRate}%`);
console.log(` Most Common Error: ${workflow.mostCommonError || 'None'}`);
});
return response;
} catch (error) {
// Handle any errors
console.error('Error getting workflow metrics:', error.message);
}
}
// Call the function
getWorkflowMetrics();
Example 2: Default Date Range
This example shows how to get workflow metrics without specifying dates (using the default date range).
import Worqhat from 'worqhat';
// Initialize the client with your API key
const client = new Worqhat({
apiKey: process.env.WORQHAT_API_KEY,
});
async function getAllWorkflowMetrics() {
try {
// Call the getMetrics method without date parameters
// This will use the default date range (current month)
const response = await client.workflows.getMetrics();
// Handle the successful response
console.log(`Period: ${response.period.startDate} to ${response.period.endDate}`);
console.log(`Total Executions: ${response.metrics.totalExecutions}`);
console.log(`Success Rate: ${response.metrics.successRate}%`);
console.log(`Error Rate: ${response.metrics.errorRate}%`);
return response;
} catch (error) {
console.error('Error getting workflow metrics:', error.message);
}
}
getAllWorkflowMetrics();
Example Response
{
"metrics": {
"totalExecutions": 1256,
"successRate": 94.5,
"averageDuration": 1250.75,
"errorRate": 5.5,
"totalErrors": 69
},
"workflowMetrics": [
{
"id": "flow_12345",
"name": "Document Processing",
"executions": 532,
"successRate": 96.8,
"averageDuration": 980.25,
"errors": 17,
"mostCommonError": "document_parse_failure"
},
{
"id": "flow_67890",
"name": "Customer Onboarding",
"executions": 724,
"successRate": 92.8,
"averageDuration": 1450.5,
"errors": 52,
"mostCommonError": "validation_error"
}
],
"period": {
"startDate": "2025-07-01T00:00:00Z",
"endDate": "2025-08-01T00:00:00Z"
}
}
Common Errors and How to Fix Them
Error | Cause | Solution |
---|
”Invalid date format” | Date parameters are not in YYYY-MM-DD format | Check that your dates follow the correct format |
”End date before start date” | The end_date is earlier than the start_date | Make sure your end_date comes after your start_date |
”Invalid status parameter” | Status value is not one of the allowed options | Use only ‘completed’, ‘failed’, or ‘in_progress‘ |
“Unauthorized” | Invalid or missing API key | Check that you’re using a valid API key |
Tips for Using Workflow Metrics
- Use the default date range (current month) when you want a quick overview of recent performance
- Filter by status to focus on specific types of workflow executions (e.g., only failed ones)
- Look for workflows with low success rates to identify areas for improvement
- Monitor average durations to spot performance degradation over time
- Use the metrics to identify your most frequently used workflows