Workflows

Initialize the client with your API key

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

  1. You specify a date range to analyze (or use the defaults)
  2. You can optionally filter by workflow status (completed, failed, or in-progress)
  3. The API returns overall metrics and detailed statistics for individual workflows

Query Parameters

start_datestringqueryrequired

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_datestringqueryrequired

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

statusstringqueryrequired

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

metricsobjectrequired

Overall metrics for the requested workflows across the specified time period.

metrics.totalExecutionsintegerrequired

Total number of workflow executions during the period. This counts every time a workflow was triggered, regardless of outcome.

metrics.successRatenumberrequired

Success rate as a percentage (0-100). This shows what percentage of workflow executions completed successfully.

metrics.averageDurationnumberrequired

Average execution duration in milliseconds. This helps you understand how long your workflows typically take to run.

metrics.errorRatenumberrequired

Error rate as a percentage (0-100). This is the percentage of workflow executions that failed.

metrics.totalErrorsintegerrequired

Total number of workflow executions that resulted in an error.

workflowMetricsarrayrequired

Metrics broken down by individual workflows. This array contains detailed statistics for each workflow that ran during the period.

workflowMetrics[].idstringrequired

The unique identifier for the workflow.

workflowMetrics[].namestringrequired

The name of the workflow.

workflowMetrics[].executionsintegerrequired

Number of times this specific workflow was executed during the period.

workflowMetrics[].successRatenumberrequired

Success rate for this specific workflow as a percentage (0-100).

workflowMetrics[].averageDurationnumberrequired

Average execution duration for this specific workflow in milliseconds.

workflowMetrics[].errorsintegerrequired

Number of times this workflow resulted in an error.

workflowMetrics[].mostCommonErrorstringrequired

The most frequently occurring error type for this workflow.

periodobjectrequired

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.

JavaScript

get-workflow-metrics.js

import Worqhat from 'worqhat';// Initialize the client with your API keyconst 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.flows.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(`Workflow: ${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 functiongetWorkflowMetrics();

Example 2: Default Date Range

This example shows how to get workflow metrics without specifying dates (using the default date range).

JavaScript

get-metrics-default-range.js

import Worqhat from 'worqhat';// Initialize the client with your API keyconst 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.flows.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

response.json

{"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

ErrorCauseSolution
"Invalid date format"Date parameters are not in YYYY-MM-DD formatCheck that your dates follow the correct format
"End date before start date"The end_date is earlier than the start_dateMake sure your end_date comes after your start_date
"Invalid status parameter"Status value is not one of the allowed optionsUse only 'completed', 'failed', or 'in_progress'
"Unauthorized"Invalid or missing API keyCheck 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