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

# Get Job Stats V1

> Quick aggregate snapshot across three rolling windows. Useful for tenant operational dashboards — answers 'how am I doing today / this week / this month' in…

Quick aggregate snapshot across three rolling windows.

Useful for tenant operational dashboards — answers 'how am I doing
today / this week / this month' in one round trip. Computed in
Python over a single query per window so the SQL stays portable
across SQLite + Postgres.

`in_flight` is the live count regardless of window (live jobs don't
have a `created_at` filter applied, since 'in flight' is a current
state, not a historical event).

### Response

`JobStatsResponse`

<ResponseField name="windows" type="JobStatsWindow[]" required>
  Three windows in fixed order: today, last\_7d, last\_30d.

  <Expandable title="JobStatsWindow">
    <ResponseField name="window" type="string" required />

    <ResponseField name="total" type="integer" required>
      Jobs created within the window.
    </ResponseField>

    <ResponseField name="succeeded" type="integer" required />

    <ResponseField name="failed" type="integer" required />

    <ResponseField name="cancelled" type="integer" required />

    <ResponseField name="in_flight" type="integer" required>
      Queued + running + awaiting\_approval, AT THE TIME OF QUERY (not window-bounded).
    </ResponseField>

    <ResponseField name="success_rate" type="number" required>
      succeeded / (succeeded + failed). 0.0 when neither bucket is populated. Excludes cancelled — those are user actions, not agent failures.
    </ResponseField>

    <ResponseField name="avg_duration_seconds" type="number" required>
      Mean wall-clock between created\_at and updated\_at across terminal-status jobs in the window. 0.0 when no terminal rows fell in the window.
    </ResponseField>

    <ResponseField name="total_cost_usd" type="number" required />
  </Expandable>
</ResponseField>

### Status codes

| Code  | Meaning             |
| ----- | ------------------- |
| `200` | Successful Response |

<RequestExample>
  ```bash cURL theme={null}
  curl --request GET \
    --url 'https://api.computer.stateset.app/api/v1/jobs/stats' \
    --header 'X-API-Key: YOUR_API_KEY'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "windows": [
      {
        "window": "today",
        "total": 102,
        "succeeded": 1,
        "failed": 1,
        "cancelled": 1,
        "in_flight": 1,
        "success_rate": 7.5,
        "avg_duration_seconds": 7.5,
        "total_cost_usd": 1.5
      }
    ]
  }
  ```
</ResponseExample>
