---
title: "Latest terminal plan run per plan/environment pair for a workspace window"
method: GET
path: "/planRuns/workspace/{workspace_id}/latestByEnvironment"
tags: ["PlanRun"]
---

# Latest terminal plan run per plan/environment pair for a workspace window

`GET /planRuns/workspace/{workspace_id}/latestByEnvironment`

Returns one row per (plan, environment) pair that had a terminal run in the window: the latest such run plus a run/failure tally for that pair over the window. Ad-hoc runs are excluded, matching aggregateWorkspacePlanRuns. A plan with no environment on a run (an empty or null environment_ids array) still gets a row, with environment_id absent.

## Path parameters

- `workspace_id` string, required

## Query parameters

- `environment_id` string
- `application_id` string
- `min_created_time` integer, required
- `max_created_time` integer, required

## Response `200`

Latest plan run per plan/environment pair, with window tallies

- WorkspaceLatestPlanRunsByEnvironment — Latest terminal plan run per (plan, environment) pair for a workspace window, plus a window-scoped run/failure tally for each pair.
  - `rows` WorkspaceLatestPlanRunByEnvironmentRow[], required
    - `plan_id` string, required
    - `plan_name` string — Plan name, resolved from plan_reference at query time. Absent when the plan has since been deleted.
    - `environment_id` string — Absent for runs whose environment_ids array is empty or null (env-less runs).
    - `latest_plan_run_id` string, required — ID of the most recently created run of this plan (in this environment) within the window.
    - `latest_status` string, required — Status of the latest run.
    - `latest_created_time` integer, required — created_time of the latest run (epoch ms).
    - `latest_failed_tests_count` integer, required
    - `latest_total_tests_count` integer, required
    - `latest_application_ids` string[], required — Denormalized application_ids of the latest run.
    - `runs_in_window` integer, required — Count of runs of this plan (in this environment) within the window.
    - `failed_in_window` integer, required — Count of failed runs of this plan (in this environment) within the window.
  - `truncated` boolean, required — True when more (plan, environment) pairs matched the window than rows returned; the result is a prefix, not the full set.

## Other responses

- `400` — Invalid or missing parameter
- `401` — User not authenticated
- `403` — User not authorized
- `default` — Unknown error

## Changes

- **2026-09-30** `598f76d12bd1` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/mabl/apis/mabl-api/changes/planRuns/workspace/:workspace_id/latestByEnvironment/get.md)

---

[API](https://skmtc.dev/mabl/apis/mabl-api.md) · [All operations](https://skmtc.dev/mabl/apis/mabl-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mabl/apis/mabl-api/revisions/24dd8c2933df?raw)
