`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).
const url = 'https://example.com/api/workflows/stats';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url https://example.com/api/workflows/statsGET /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).
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Responses
Section titled “Responses”OK
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
Count of workflow runs currently in flight
(queued/pending/starting/running/waiting).
Distinct workflows with an in-flight run — backs the “over N workflows”
sub-caption (always ≤ active_runs).
Mean wall-clock duration in seconds of completed workflow runs in the
last 24h; None when none completed (or none had both timestamps).
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.
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).
Count of workflow runs that failed in the last 24h.
Distinct workflows with a failed run in the last 24h — the “N workflows
affected” sub-caption (always ≤ failed_24h).
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.
Share (0.0–1.0) of DECIDED workflow runs in the last 24h that
completed — completed / (completed + failed), i.e. cancelled/skipped
are excluded from the denominator; 0.0 when nothing decided in the window.
Count of workflow definitions in scope.
Example generated
{ "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
The canonical JSON body of every error response. Every AppError serializes as
this exact shape; code is the generated stable machine-readable vocabulary.
object
Present only on an MCP budget refusal (429) — the refusing layer + retry hint.
object
The refusing layer.
The layer’s budget.
Seconds until a retry can pass, or null when it never will for this session.
Calls already counted in the layer.
Machine-readable, stable error code.
Present only on a quota-exceeded 403 — the inline upgrade-CTA payload.
object
The entitlement feature key that was hit, e.g. apps.max_count.
The plan’s limit for this key.
Where to send the user to upgrade.
Current usage (count or bytes, per the key).
Human-readable message (the server’s English text; the client may localize
by code).
Present on a launch refusal (400/403/409) — the structured facts only the refusing class can fill: occupancy, exhausted budget, or required labels.
object
Weighted workspace slots already held by starting/running agent runs.
The budget cap that refused.
Effective spend of the refusing budget scope (spend + in-flight reservations).
The workspace’s configured agent-concurrency cap.
The provider whose budget cap refused; absent for the workspace-wide cap.
Runner labels a fail-policy placement required and no runner offered.
Example
{ "code": "not_found"}Authentication required
The canonical JSON body of every error response. Every AppError serializes as
this exact shape; code is the generated stable machine-readable vocabulary.
object
Present only on an MCP budget refusal (429) — the refusing layer + retry hint.
object
The refusing layer.
The layer’s budget.
Seconds until a retry can pass, or null when it never will for this session.
Calls already counted in the layer.
Machine-readable, stable error code.
Present only on a quota-exceeded 403 — the inline upgrade-CTA payload.
object
The entitlement feature key that was hit, e.g. apps.max_count.
The plan’s limit for this key.
Where to send the user to upgrade.
Current usage (count or bytes, per the key).
Human-readable message (the server’s English text; the client may localize
by code).
Present on a launch refusal (400/403/409) — the structured facts only the refusing class can fill: occupancy, exhausted budget, or required labels.
object
Weighted workspace slots already held by starting/running agent runs.
The budget cap that refused.
Effective spend of the refusing budget scope (spend + in-flight reservations).
The workspace’s configured agent-concurrency cap.
The provider whose budget cap refused; absent for the workspace-wide cap.
Runner labels a fail-policy placement required and no runner offered.
Example
{ "code": "not_found"}Permission denied
The canonical JSON body of every error response. Every AppError serializes as
this exact shape; code is the generated stable machine-readable vocabulary.
object
Present only on an MCP budget refusal (429) — the refusing layer + retry hint.
object
The refusing layer.
The layer’s budget.
Seconds until a retry can pass, or null when it never will for this session.
Calls already counted in the layer.
Machine-readable, stable error code.
Present only on a quota-exceeded 403 — the inline upgrade-CTA payload.
object
The entitlement feature key that was hit, e.g. apps.max_count.
The plan’s limit for this key.
Where to send the user to upgrade.
Current usage (count or bytes, per the key).
Human-readable message (the server’s English text; the client may localize
by code).
Present on a launch refusal (400/403/409) — the structured facts only the refusing class can fill: occupancy, exhausted budget, or required labels.
object
Weighted workspace slots already held by starting/running agent runs.
The budget cap that refused.
Effective spend of the refusing budget scope (spend + in-flight reservations).
The workspace’s configured agent-concurrency cap.
The provider whose budget cap refused; absent for the workspace-wide cap.
Runner labels a fail-policy placement required and no runner offered.
Example
{ "code": "not_found"}Structured server error
The canonical JSON body of every error response. Every AppError serializes as
this exact shape; code is the generated stable machine-readable vocabulary.
object
Present only on an MCP budget refusal (429) — the refusing layer + retry hint.
object
The refusing layer.
The layer’s budget.
Seconds until a retry can pass, or null when it never will for this session.
Calls already counted in the layer.
Machine-readable, stable error code.
Present only on a quota-exceeded 403 — the inline upgrade-CTA payload.
object
The entitlement feature key that was hit, e.g. apps.max_count.
The plan’s limit for this key.
Where to send the user to upgrade.
Current usage (count or bytes, per the key).
Human-readable message (the server’s English text; the client may localize
by code).
Present on a launch refusal (400/403/409) — the structured facts only the refusing class can fill: occupancy, exhausted budget, or required labels.
object
Weighted workspace slots already held by starting/running agent runs.
The budget cap that refused.
Effective spend of the refusing budget scope (spend + in-flight reservations).
The workspace’s configured agent-concurrency cap.
The provider whose budget cap refused; absent for the workspace-wide cap.
Runner labels a fail-policy placement required and no runner offered.
Example
{ "code": "not_found"}