> ## Documentation Index
> Fetch the complete documentation index at: https://docs.empirical.run/llms.txt
> Use this file to discover all available pages before exploring further.

# Last passing run per environment

> Returns the most recent passing run for a test case, grouped by environment.



## OpenAPI

````yaml /api-reference/openapi.generated.json post /api/v2/analytics/test-case-last-pass-per-env
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Analytics (Deprecated)
    description: >-
      Legacy analytics endpoints retained for backwards compatibility; prefer
      the v2 equivalents.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Telemetry
    description: Product telemetry derived from analytics events, scoped to a project.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
paths:
  /api/v2/analytics/test-case-last-pass-per-env:
    post:
      tags:
        - Analytics
      summary: Last passing run per environment
      description: >-
        Returns the most recent passing run for a test case, grouped by
        environment.
      operationId: getTestCaseLastPassPerEnv
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LastPassPerEnvRequest'
      responses:
        '200':
          description: Last passing run per environment.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LastPassPerEnvResponse'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Analytics backend error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsErrorResponse'
components:
  schemas:
    LastPassPerEnvRequest:
      type: object
      properties:
        test_case_id:
          type: string
          minLength: 1
          description: Test case ID to look up.
        project_id:
          type: integer
          minimum: 1
          description: Project ID (ignored; the project comes from auth scope).
        days:
          type: integer
          minimum: 1
          description: Look-back window in days (default 30).
        before:
          type: string
          description: >-
            Anchor the lookup to this point in time (ISO 8601); returns the last
            pass as of then.
      required:
        - test_case_id
      additionalProperties: false
    LastPassPerEnvResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/LastPassPerEnvEntry'
          description: Response payload.
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        data:
          nullable: true
          description: Always null for error responses.
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message.
          required:
            - message
          description: Error details.
      required:
        - data
        - error
    AnalyticsErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
    LastPassPerEnvEntry:
      type: object
      properties:
        environment_id:
          type: string
          description: Environment ID the test last passed in.
        test_run_id:
          type: string
          description: ID of the test run in which it last passed.
        executed_at:
          type: number
          description: Epoch timestamp (ms) of the last passing run.
      required:
        - environment_id
        - test_run_id
        - executed_at
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````