# Agent BI HTTP API

Query bounded BI metrics and preview confirmed dashboard actions through the protected HTTP adapter used by the AppPortal MCP CLI.

Source: https://appportal.io/docs/api/agent-bi

AppPortal's CLI hosts MCP locally over stdio. This page describes the protected HTTP BI adapter
called by those tools: [operations and schemas](https://appportal.io/docs/api/reference/agent-bi),
[OpenAPI JSON](https://appportal.io/docs/api/contracts/agent-bi.json). Use [MCP setup](https://appportal.io/docs/api/mcp) for authentication
and agent configuration.

Use your deployment's actual protected HTTP API origin. The configured MCP resource URI is the
OAuth token audience and can include `/mcp`; it is not necessarily the server base for these paths.
The reference uses a reserved example host. Do not append `/mcp` twice or send credentials to the
example origin.

## Keep consent and access separate

Reads require `mcp:overview.read`, current app analytics access, a concrete authorized environment
and the applicable BI and MCP entitlements. Free does not include BI. Scope selectors narrow
existing authority; an organization or app header cannot grant membership or app access.
Dashboard cookies, SDK keys, server keys and other bearer audiences do not authenticate these routes.

Dashboard actions additionally require explicitly approved `mcp:dashboards.write` consent and the
current Admin/AppOwner role, analytics capability and app access. Read-only consent does not acquire
write access when the tool catalog changes. Sharing creates an authenticated read-only bookmark;
the recipient still needs sign-in and existing app analytics access. It grants no membership or
public embedding.

## Query one metric

Read `GET /mcp/bi/catalog` for this adapter's supported measures and definitions:

| Measure | Unit |
| --- | --- |
| `active_users` | Observed active subjects (`users`) |
| `sessions` | Sessions |
| `crashed_sessions` | Sessions ending in a crash |
| `error_reports` | Handled-error and unhandled-crash occurrences |
| `crash_free_sessions_pct` | Percent of sessions without a crash |
| `error_rate` | Reports per session |

Use `GET /mcp/bi/query` with explicit `from` and `to` timestamps containing offsets. The window
is `[from, to)`, at most 90 days. Choose a catalog `measure`, an optional exact app `version`, and
1–20 leading groups (`limit`, default 10). Only `sessions` supports a catalog dimension; previous-period
comparison applies only to ungrouped measures. The comparison window has the same duration and
immediately precedes the current one. Unknown/repeated selectors, arbitrary expressions and
personal-identifier dimensions are rejected.

Read each metric's definition and denominator. Group shares retain the full matching-session
population, with `omittedSessions` and `isTruncated` describing groups outside the returned leading
values. Active subjects are observed identities, not proof of distinct people. The defined empty
population produces 100% crash-free sessions and zero reports per session; a dependency failure
instead returns an unavailable response.

Successful query envelopes contain `status: available`, `captureComplete: false`, the typed result
and content flags. Live aggregates do not promise that all delayed telemetry has arrived or that
multiple stores share an atomic snapshot. Protected group labels can change under sanitization;
they are not necessarily reversible filter values. Metric values and denominators remain intact.

## Read saved dashboards

List summaries with `GET /mcp/bi/dashboards`: 25 items by default, at most 50. Return its opaque
`nextCursor` as `cursor` with the same subject, selection and limit. Lists are live.

Load `GET /mcp/bi/dashboards/{dashboardId}` before querying a widget. Send the resource's opaque
`version`, without ETag quotes, as `dashboardVersion` to the widget query endpoint, together with
explicit `from` and `to`. A missing or stale version returns `409`; reload before querying again.
The saved widget supplies the measure, dimension, version filter, group limit and comparison.
One call executes one widget, with no automatic dashboard-wide fan-out.

## Preview and apply one action

Send a stable `Idempotency-Key` with preview and apply. It is 1–200 UTF-16 code units, without
control characters or surrounding whitespace. Reuse it for the same intent across retries and
reconciliation.

| Action | Original request |
| --- | --- |
| `create` | A complete dashboard; no existing ID or revision |
| `update` | Existing dashboard ID, exact `expectedVersion` and complete replacement dashboard |
| `delete` | Existing ID and revision; no dashboard payload |
| `share` | Existing ID and revision; no dashboard payload |

`POST /mcp/bi/dashboards/preview` returns protected current/proposed values, warnings and a
confirmation token, digest and expiry. It does not save the dashboard. Review the intent, then
send the original request, exact token and `expiresAt` to `POST /mcp/bi/dashboards/apply` with the
same key. Keep the original submitted data; do not reconstruct it from redacted display values.

Confirmation lasts at most ten minutes and binds the actor, connection, selection, payload, action
and resource revision. Current consent and authority are checked again before commit, including
after lock waits. Bodies are limited to 80 KiB and JSON depth 24. Unknown or duplicate fields are
rejected; known field names are case-insensitive. Dashboard definitions retain their bounded widget,
query and size rules.

After an uncertain outcome, preview the same intent and key to reconcile it. A committed intent
returns `already_applied` with its original result and no new confirmation. A key reused for different
content conflicts. Deleting dashboard configuration retains telemetry.

## Generate and schedule reports

Read your connection’s report jobs and schedules with `mcp:reports.read`. To generate a report,
also request `mcp:reports.write` and `mcp:reports.generate`. Preview the request at
`POST /mcp/reports/jobs/preview`, then submit the same body and idempotency key to
`POST /mcp/reports/jobs/apply` with `confirmation.confirmationToken` in the `X-AppPortal-MCP-Confirmation` header.
If your organization requires a human approver, include their approval for that preview.

Use `mcp:reports.export` to download a report that was explicitly generated for offline use.
A schedule created without `mcp:reports.generate` is saved disabled. The preview shows `impact.generationEnabled`. Create a new schedule with that scope to generate recurring reports.
Creating schedules with a delivery channel additionally requires `mcp:reports.delivery.write`.
Schedule creation and changes both use preview and apply. [Report operations](https://appportal.io/docs/api/reference/agent-bi)

## Handle unavailable data and conflicts

`501` marks an unsupported measure/provider and `503` marks an unavailable telemetry dependency;
neither is a successful zero result. A hidden resource or unavailable entitlement returns `404`.
An expired confirmation or stale revision returns `409`; reload or reconcile without overwriting
a newer resource. A management hold can reject mutations with `423` while retaining permitted reads.
For `429`, respect `Retry-After` when supplied and keep retries bounded.
