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

# Embedded inspector authorization

> Agent-scoped diagnostic keys for browser and native inspectors.

# Embedded inspector authorization

Formation authorizes embedded inspectors independently of application chat.
Developers create a read-only key for one agent, then paste it into their web,
native, or command-line inspector. Ordinary app access never grants diagnostics.

## Create a diagnostic key

Open **Diagnostic keys** from the agent page (`/agents/{slug}/diagnostic-keys`).
Name the key (1 to 80 bytes), choose its expiry, and select whether it may read retained content.
Keys default to metadata only and 30 days; the maximum lifetime is 90 days.
Copy the secret immediately: Formation stores only its hash and never shows it again.

Operator API equivalents (existing sign-in and agent authorization required):

| Method/path | Purpose |
| - | - |
| `POST /api/agents/{slug}/diagnostic-keys` | Create: `{ "name": "Development laptop", "expires_in_days": 30, "include_content": false }`; returns metadata plus a one-time `key` |
| `GET /api/agents/{slug}/diagnostic-keys` | List 100 keys per page; pass `next_before` as `?before=…` for older keys; metadata and display prefixes only |
| `DELETE /api/agents/{slug}/diagnostic-keys/{id}` | Revoke your own key; installation owners may revoke any key for an accessible agent |

A key grants **agent-wide diagnostics**, including other conversations for that
agent. It cannot send messages, execute tools, manage keys or change configuration.
Retained-content permission is explicit and does not override redaction/retention.

## Connect a client

1. Paste the `formation_diag_…` key into the inspector. Keep it in memory only.
   Never embed it in a public environment variable or ship it in an app build.
2. Call `GET /api/inspector/v1/access` with `Authorization: Bearer <key>`.
   The response contains `version: 1`, `agent_id`, `agent_slug`,
   `current_display_name`, `include_content`, and `expires_at`. Check the agent
   against the configured connection descriptor before reading evidence.
3. Read the API below directly from Formation. No product-server diagnostic proxy,
   browser approval callback, polling for consent, or shared operator token is needed.
4. **Forget key** clears that client only. Revoke in Formation to stop every client
   using the key. Expiry, revocation, or loss of the creator's current agent access
   stops subsequent reads and stream polls. There is no refresh credential.

The bearer-only surface accepts CORS without cookies. Never put credentials in
URLs, chat context, logs, exports, or browser persistent storage. A command-line
client may obtain its key from a private process environment or secret manager.

## Read API

Replace the operator `/api/agents/{slug}` prefix with
`/api/inspector/v1/agents/{slug}` for these diagnostic operations only:

| Method/path after the agent prefix | Purpose |
| - | - |
| `GET /` (agent prefix itself, no trailing slash) | Current identity and backend build, before any message or run |
| `GET /configuration?include_content=…` | Current agent setup, before or between runs (see below) |
| `GET /diagnostics/conversation?install_id=…&conversation_key=…` | Resolve a known generic application conversation |
| `GET /conversations/{id}/diagnostics?before=…` | Page that conversation's runs |
| `GET /runs/{id}/diagnostics?include_content=false` | Consistent recorded evidence snapshot |
| `GET /runs/{id}/diagnostics/events?after=…` | Bounded durable change references |
| `GET /runs/{id}/diagnostics/stream?after=…` | Live change feed with authorization checked on every poll |

The identity envelope has `version: 1`, `agent_id`, `agent_slug`,
`current_display_name`, and `current_backend_build`. It describes current metadata,
not the historical identity used by an earlier model call. It contains no prompt,
settings or credentials.

Snapshot/event semantics remain those of [live application diagnostics](https://docs.formation.texturehq.com/runtime/application-diagnostics.md).
`include_content=true` requires retained-content key permission. Missing or pruned
bodies remain unavailable. No chat, tool execution, arbitrary operator reads,
configuration writes, prompt-snapshot endpoint, or management API is granted.
Historical tool definitions and instructions are inspected through retained run
inputs. Current setup is read separately through `/configuration`, described below.

## Revocation and failures

Keys bind to a stable agent ID and their creating operator. Every read and stream
poll checks database expiry/revocation and the creator's enabled state, current
role and agent grants. Renaming the same agent preserves its key; replacing the
agent does not transfer access. Key creation and revocation use the existing
attributed mutation audit without recording secrets.

* `401`: missing, malformed, invalid, expired or revoked key. Forget it and paste a valid key.
* `403`: creator lost agent access, or the key does not permit retained content.
* `404`: subject unavailable within this agent, or an unsupported route.
* `503`: authorization storage unavailable; no unprotected fallback.

Do not retry authorization failures in a tight loop. The access response is
read-only and never extends a key's expiry.

## Existing temporary sessions

The earlier `/sessions` and `/session` browser-consent protocol remains compatible
for existing integrations and their original bounded lifetimes. Those credentials
use a separate `formation_inspector_` prefix. They cannot manage diagnostic keys.
New integrations should use developer-entered diagnostic keys instead.

This capability does not change application chat transport or make its signing
secret safe for public clients. See the
[embedded inspector design](https://github.com/TextureHQ/formation/blob/main/docs/design/embedded-inspector-access.md)
(repository).

### Current configuration before the first run

`GET /api/inspector/v1/agents/{slug}/configuration?include_content=true`
reads current agent setup independently of conversations. The existing diagnostic
key (or approved inspector session) authorizes it; requesting prompt text and
schemas requires the same content grant used for recorded evidence.

The version-1 `current_configuration` response includes `captured_at`, agent
identity, the shared assembler's current instruction sections, configured tools
(native tools, stored MCP tools, and web capabilities under source `mesh.web`)
with explicit availability state (`configured`, `disabled`,
`credentials_required`, or `unavailable`), safe memory settings, and scope
limitations. Metadata-only reads omit instruction text, descriptions and
schemas. When `include_content=true`, MCP tool entries carry the provider's
description and include an additive `inspector_presentation` object (`name` and
`group`) inside `definition_json` so clients can display human-readable tool and
connection labels alongside the runtime schema. Current configuration never
proves that a historical call included a section or tool. Participant, retrieved
memories, conversation history and application context remain dynamic; the
application owns its current context capture.

MCP schemas come only from current stored catalogs through the runtime's existing
selection policy. Missing catalogs are reported explicitly. This read does not
connect to providers, refresh credentials, discover tools, retrieve memories,
execute a tool, or start a run. A later call may offer a different tool set.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.