# Mission Control and health checks

> Every business on one board, a row of steps from its domain to its sales, with health from checks that run every hour.

Mission Control shows every project of the account at once. On top: today's visitors, sales and revenue, new problems, the biggest movers and where visitors come from. Below, a board with each business as a row: its logo and name, then its **steps** left to right, the way a visitor's money travels, each with its number. A problem shows a **red** (failing) or **amber** (warning) dot with the reason under it; a dash means the business doesn't use that step yet. Failing businesses come first, then warnings, then the rest; pinned ones stay on top. Every account has it: console ▸ **Mission Control**. Agents read the same data with `vibiz health`, the `vibiz_health` tool, `GET /v1/health` or `GET /v1/mission-control`.

## The steps

| # | Step | Its checks | Its number |
| --- | --- | --- | --- |
| 1 | **Domain & HTTPS** | Site up, Domain | the address |
| 2 | **Deploy** | Last deploy, Resources | the last deploy and when |
| 3 | **Pages & SEO** | Sitemap & pages | the top 3 pages (7 days) |
| 4 | **Traffic** | Traffic | visitors in 7 days, the change against the 7 before, 30 days of visitors, the top sources |
| 5 | **Experience** | Errors | sessions with errors in 24 h, and the latest session with a problem to watch |
| 6 | **Checkout & payments** | Payments | webhooks and deliveries ("not set up" when the business doesn't sell) |
| 7 | **Sales & revenue** | | revenue and sales in 30 days, sales today |
| 8 | **Limits & spend** | Limits | AI spend today |

A step's colour is its worst check. A step whose checks have nothing to check yet (no analytics, no payments) shows as **not set up**: every row keeps the same shape, so what a business is missing shows as a gap.

## The checks

Every active project is checked about once an hour, in the background, a few at a time. "Check now" (or `vibiz health run`) checks them all again; "Check again" on one business checks just that one. Each check answers `ok`, `warn`, `fail` or `unknown` (nothing to check, like a project with no analytics), and every problem says what is wrong, why, how to fix it and which console page does it. A business's status is its worst check; `unknown` checks never grey out a business whose other checks pass.

| Check | Fails when | Warns when |
| --- | --- | --- |
| **Site up** | the address visitors use (its own domain first, else the free one) answers 5xx, times out after 10 s, doesn't resolve, or has an invalid HTTPS certificate | `/` answers 4xx, or the site ends on `http://` |
| **Last deploy** | the latest production deploy failed (with the build's reason) | a production deploy has been queued or building for over 30 minutes |
| **Resources** | a resource (database, sign-in, email…) failed to set up, with its error (it is set up again on its own about hourly, see below) | |
| **Errors** | a spike: 10 or more sessions with JavaScript errors in 24 h, three times the usual day | 3+ sessions with errors, 5+ with rage clicks or 10+ with dead clicks in 24 h (from session replay) |
| **Traffic** | | pageviews in the last 24 h are over 60 % below the 7-day daily average (once the average is 20 a day or more) |
| **Sitemap & pages** | a page listed in `/sitemap.xml` answers 5xx (up to 20 are checked) | no sitemap, sitemap pages that answer 404, or a home page without a `<title>` or meta description |
| **Payments** | the site's own checkout events show 3 or more failed checkouts in 7 days and none went through; the project sells through thelastapi in production with no webhook URL; or no payment event reached the app in 24 h while some failed | 1 or 2 failed checkouts with none through, or as many failures as successes; the home or pricing page shows a price with a buy button but no checkout was found; some webhook deliveries failed |
| **Limits** | a cap of the project (builds, AI budget, app email) is reached | a cap is at 80 % |
| **Domain** | | a domain of its own is not live yet (DNS, ownership or HTTPS pending) |

**How Payments finds a checkout.** A site may sell through thelastapi payments or through a checkout of its own; either is fine as long as buyers get through:

- It reads the home page, and the pricing page when the sitemap has one (`/pricing`, `/plans`, `/precios`…), for a price shown next to a buy word (`$9`, `€9,99`, `1,99 US$`; Buy, Subscribe, Upgrade, Get access…).
- With a price and no thelastapi payments, it looks for the site's own checkout: in that page, in the site's own scripts, and in the same-site pages linked from the plan cards next to the prices (an `/api/checkout`-style endpoint, or a hosted checkout page). Found: `ok`, "Sells through its own checkout".
- It also reads the site's own analytics events from the last 7 days whose names speak of a checkout, payment, purchase or order: `Checkout Redirect`, `checkout_completed` or `purchase` count as went through; `Checkout Error` or `payment_failed` as failed, in any language or casing. A site with its own checkout should send one of each (`vibiz('event', 'Checkout Redirect')` when a buyer is sent to pay, `vibiz('event', 'Checkout Error')` when it breaks) so the check can tell.
- **No checkout found** (no thelastapi payments, none in the pages or scripts, no checkout events) is a **warning**, not a failure: click buy yourself to see where it goes.
- A missing development (test) webhook is not a problem: the check stays `ok` and its detail says to set one to try the checkout end to end.

**Failed resources come back on their own.** A resource that failed to set up (a quota, a partner outage) is set up again by itself about every hour, for the first 7 days after it was added, on live projects. Adding it again (`vibiz add <type>`, or `POST /v1/projects/:id/resources`) retries it at once.

The checks only read: nothing is deployed, charged or sent. Requests to the site go out as a visitor's would, from `VibizStack-Health/1.0`.

Each check keeps the time it took its current status (`since`), so the console says "failing for 3 h".

## In the console

- **Moving around**: drag (or two fingers on a trackpad) to move in any direction; pinch, Ctrl/⌘ + scroll or the mouse wheel to zoom around the pointer; space + drag or the middle button to move from anywhere. **⌘0** fits everything, **⌘+ / ⌘−** zoom, **⌘1** is 100 %; the zoom shows bottom left. The **minimap** bottom right shows every business, each step a dot of its colour, and the view: click or drag on it to go there.
- **Zoomed out**, each row is a strip of coloured squares, a heat map of the whole account. **Closer**, each step is a card with its name and one number. **Close up**, each card has its chart or list, and the name column the business's headline numbers: visitors (7 days, with the change), sales and revenue (30 days), errors (24 h).
- The step names stay on top and the businesses' names stay on the left while you move, like frozen panes in a spreadsheet. Rows are grouped in sections: **Pinned**, **Failing**, **Warnings**, **Not checked**, **Healthy**, worst first inside each.
- Above the rows, four insight frames: **Today** (visitors, sales, revenue, failing, warnings), **Biggest movers** (the 5 businesses whose visitors changed most, 7 days against the 7 before, among those with 5 or more visitors before), **New problems** (checks that started failing or warning in the last 24 hours) and **Top sources** across every business. Click one to fly to that business.
- Click a step: the inspector opens on that step's checks, each with its detail, how to fix it, since when and the console page that fixes it, then every other check. Click a name: the whole business, with links to its pages, **Check again** and **Pin**. Double-click flies to it. **Esc** closes the inspector.
- **Pin** keeps a business at the top; drag a row by its handle to change its order within its section. Both are saved for the account. **Tidy up** puts every row back worst first (pins stay).
- The toolbar: the find box (press **F**, type a name, **Enter** flies to it), **All / Failing / Warnings**, **Check now**, **Tidy up**, **Fit all** and when it was last checked.
- The URL keeps the exact view, so a link opens the same thing: `?x=&y=&zoom=` (the middle of the view and the zoom), `?status=fail`, `?focus=<project id>` (its inspector open) and `&step=traffic` (that step's checks).
- On a phone it is a list, worst first.

## From an agent

```bash
vibiz health                 # every business, worst first, one line each with its top problem
vibiz health --failing       # only failing ones
vibiz health shop            # one business (id, slug or name): every check, since when, how to fix
vibiz health run             # check every business again now (in the background)
vibiz health run shop        # check one again and show it
```

MCP: `vibiz_health { action: "list" | "project" | "run", project_id?, failing? }`. SDK: `vibiz.health.list()`, `get(projectId)`, `run(projectId)` and `runAll()`; `vibiz.missionControl.get()`, `layout()` and `setLayout({ rows, replace? })`.

## API

`GET /v1/health` lists every active project of the account, worst first. `?status=fail` (or `fail,warn`) and `?q=` filter it.

```json
{
  "object": "list",
  "totals": { "projects": 120, "fail": 3, "warn": 12, "ok": 105, "unknown": 0 },
  "checked_at": "2026-11-12T12:00:00.000Z",
  "data": [
    {
      "object": "project_health",
      "project": { "id": "prj_…", "name": "Shop", "slug": "shop", "url": "https://shop.com" },
      "status": "fail",
      "checked_at": "2026-11-12T12:00:00.000Z",
      "counts": { "fail": 1, "warn": 1 },
      "top": [
        {
          "id": "site",
          "status": "fail",
          "title": "Site up",
          "detail": "https://shop.com answers 502: the app is crashing on its home page.",
          "fix": "Open the app logs or replays for the error, roll back to the last good version from Deployments, then fix and deploy again.",
          "link": "https://thelastapi.dev/projects/prj_…/deployments",
          "since": "2026-11-12T09:00:00.000Z"
        }
      ],
      "metrics": { "visitors_7d": 812, "pageviews_24h": 140, "sales_30d": 9, "revenue_30d_usd_cents": 26100, "errors_24h": 2 },
      "console_url": "https://thelastapi.dev/mission-control?focus=prj_…"
    }
  ],
  "console_url": "https://thelastapi.dev/mission-control"
}
```

`top` holds up to the 3 worst problems (failing, then warnings). A project never checked has `status: "unknown"` and `checked_at: null`.

`GET /v1/projects/:id/health` answers one business with every check (`checks`, worst first), `next_check_at` and `console_url`. A business never checked is checked on that first read.

`POST /v1/projects/:id/health/run` checks one business now and answers the same (5 a minute per business). `POST /v1/health/run` checks every business again in the background and answers `202` with how many were queued (twice per 10 minutes); `GET /v1/health` shows each one as it finishes. Over either limit: `429 rate_limited`, saying when to retry.

### The canvas in one call

`GET /v1/mission-control` answers every active business of the account as a row of steps with its figures, and the account's insights, in one call (`vibiz.missionControl.get()`). Each figure is read for every business at once, so it stays fast with hundreds of businesses; the figures are kept a minute (`metrics_at`), health is read fresh on every call. Only the caller's businesses are ever in it.

```json
{
  "object": "mission_control",
  "metrics_at": "2026-11-12T12:00:00.000Z",
  "checked_at": "2026-11-12T11:58:00.000Z",
  "steps": [{ "id": "domain", "title": "Domain & HTTPS", "checks": ["site", "domain"] }, "…"],
  "days": ["2026-10-14", "…", "2026-11-12"],
  "totals": { "projects": 120, "fail": 3, "warn": 12, "ok": 105, "unknown": 0 },
  "data": [
    {
      "object": "mission_control_project",
      "project": { "id": "prj_…", "name": "Shop", "slug": "shop", "url": "https://shop.com", "live": true },
      "status": "fail",
      "counts": { "fail": 1, "warn": 0 },
      "top": ["…the worst 3 problems, as in GET /v1/health…"],
      "steps": [
        {
          "id": "traffic",
          "title": "Traffic",
          "status": "ok",
          "set_up": true,
          "value": 812,
          "unit": "count",
          "value_label": "visitors 7d",
          "line": "140 pageviews in 24 h (7-day average 120 a day).",
          "checks": [{ "id": "traffic", "status": "ok", "title": "Traffic" }],
          "link": "https://thelastapi.dev/projects/prj_…/analytics?period=7d"
        }
      ],
      "metrics": {
        "pageviews_30d": [12, 30, "…"],
        "visitors_30d": [10, 22, "…"],
        "visitors_today": 40,
        "visitors_7d": 812,
        "visitors_prev_7d": 640,
        "visitors_change_pct": 27,
        "sales_30d": 9,
        "revenue_30d_usd_cents": 26100,
        "sales_today": 1,
        "revenue_today_usd_cents": 2900,
        "errors_24h": 2,
        "ai_spend_today_usd_micro": 1250000,
        "top_sources_7d": [{ "source": "ChatGPT", "visitors": 300 }, { "source": "Google", "visitors": 210 }, { "source": "Direct", "visitors": 150 }],
        "top_pages_7d": [{ "path": "/", "pageviews": 900 }, { "path": "/pricing", "pageviews": 240 }, { "path": "/blog", "pageviews": 80 }],
        "last_deploy": { "id": "dep_…", "status": "ready", "at": "2026-11-12T09:00:00.000Z", "error": null, "console_url": "https://thelastapi.dev/projects/prj_…/deployments/dep_…" },
        "latest_problem_replay": { "id": "rpl_…", "at": "2026-11-12T11:20:00.000Z", "errors": 2, "rage_clicks": 0, "dead_clicks": 1, "console_url": "https://thelastapi.dev/projects/prj_…/replays/rpl_…" }
      },
      "console_url": "https://thelastapi.dev/mission-control?focus=prj_…"
    }
  ],
  "insights": {
    "today": { "visitors": 2400, "sales": 47, "revenue_usd_cents": 230300, "fail": 3, "warn": 12 },
    "movers": [{ "project_id": "prj_…", "name": "Shop", "visitors_7d": 262, "visitors_prev_7d": 141, "change_pct": 86, "direction": "up", "console_url": "…" }],
    "new_problems": [{ "project_id": "prj_…", "name": "Shop", "check": { "id": "site", "status": "fail", "…": "…" }, "console_url": "…" }],
    "top_sources_7d": [{ "source": "ChatGPT", "visitors": 507 }]
  },
  "layout": { "object": "mission_control_layout", "rows": [{ "project_id": "prj_…", "pinned": true, "position": 0 }] },
  "console_url": "https://thelastapi.dev/mission-control"
}
```

Sources are named the way people say them: a referrer such as `chatgpt.com` is **ChatGPT**, `www.google.com` is **Google**, no referrer is **Direct**. `visitors_change_pct` is `null` when there were no visitors in the 7 days before. A step's `unit` is `count`, `usd_cents` or `usd_micro` (millionths of a dollar, for AI spend).

`GET /v1/mission-control/layout` answers the account's pins and order; `PUT /v1/mission-control/layout` with `{ "rows": [{ "project_id": "prj_…", "pinned": true, "position": 0 }], "replace": false }` sets them (`replace: true` drops every row not listed: **Tidy up** sends only the pinned ones). A row neither pinned nor placed goes back to its health group. Each business may be listed once, with a whole `position` from 0; a business of another account (or being deleted) is `404` naming it.
