Skip to content
Select themeSelect language

`GET /api/workflows/stats?project_id=<uuid>` — the #358 header-card stats for the caller's workspace, optionally narrowed to one project (Active runs, Workflows, Success 24h %, Failed 24h, Avg duration).

GET
/api/workflows/stats
curl --request GET \
--url https://example.com/api/workflows/stats
project_id
string format: uuid
Media typeapplication/json

The five header stat cards of the #358 workflows list board, aggregated over the caller’s workspace (optionally narrowed to one project) — Active runs, Workflows, Success 24h %, Failed 24h and Avg duration.

Serde casing: snake_case, matching WorkflowSummary and the zod schema.

object
active_runs
required

Count of workflow runs currently in flight (queued/pending/starting/running/waiting).

integer format: int64
active_workflows
required

Distinct workflows with an in-flight run — backs the “over N workflows” sub-caption (always ≤ active_runs).

integer format: int64
avg_duration_secs

Mean wall-clock duration in seconds of completed workflow runs in the last 24h; None when none completed (or none had both timestamps).

number | null format: double
completed_24h
required

Count of workflow runs that completed in the last 24h — the success numerator; completed_24h + failed_24h is the exact denominator behind success_rate_24h, so the “X / Y runs” sub-caption uses these two and matches the headline percent.

integer format: int64
duration_sample_24h
required

Count of completed runs (with both timestamps) in the last 24h — the EXACT sample behind the median/avg, so the “median over N runs” caption’s N matches the duration set (not all terminal runs).

integer format: int64
failed_24h
required

Count of workflow runs that failed in the last 24h.

integer format: int64
failed_workflows
required

Distinct workflows with a failed run in the last 24h — the “N workflows affected” sub-caption (always ≤ failed_24h).

integer format: int64
median_duration_secs

Median (p50) wall-clock duration in seconds over the same set as avg_duration_secs — the robust central value the card shows; None when none qualify.

number | null format: double
success_rate_24h
required

Share (0.0–1.0) of DECIDED workflow runs in the last 24h that completedcompleted / (completed + failed), i.e. cancelled/skipped are excluded from the denominator; 0.0 when nothing decided in the window.

number format: double
total_workflows
required

Count of workflow definitions in scope.

integer format: int64
Examplegenerated
{
"active_runs": 1,
"active_workflows": 1,
"avg_duration_secs": 1,
"completed_24h": 1,
"duration_sample_24h": 1,
"failed_24h": 1,
"failed_workflows": 1,
"median_duration_secs": 1,
"success_rate_24h": 1,
"total_workflows": 1
}

Structured client error

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Authentication required

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Permission denied

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}

Structured server error

Media typeapplication/json

The canonical JSON body of every error response — the single source of truth the frontend binds to. Every AppError serializes as this exact shape, and the generated OpenAPI component ApiErrorBody (with its ErrorCode enum) is what the frontend error schema is generated from, so there is no hand-written error schema on either end.

object
code
required

Machine-readable, stable error code.

string
Allowed values: not_found unauthorized forbidden bad_request unprocessable precondition_failed conflict method_not_allowed rate_limited quota_exceeded database_error docker_error vault_error internal_error
details
One of:
null
error
required

Human-readable message (the server’s English text; the client may localize by code).

string
Example
{
"code": "not_found"
}