# AutoPIL ## Documentation - [AutoPIL Documentation](https://autopil-docs.documentationai.com/Home.md): Runtime governance for autonomous AI agents — enforce data-access policy at the retrieval layer and prove every decision with a tamper-evident audit trail. - [Quick start](https://autopil-docs.documentationai.com/getting-started/quickstart.md): Install the AutoPIL Python package, point it at a policy directory, and protect your first retrieval function. - [Installation](https://autopil-docs.documentationai.com/getting-started/installation.md): Install options for the SQLite, Postgres, and OpenTelemetry backends, with a first protected-retrieval example. - [First-start bootstrap](https://autopil-docs.documentationai.com/getting-started/first-start.md): Start the API server, capture the one-time superadmin key, and recover it if you miss it. - [MCP Server](https://autopil-docs.documentationai.com/getting-started/mcp.md): Connect AI assistants to the AutoPIL documentation using the Model Context Protocol (MCP). - [Architecture](https://autopil-docs.documentationai.com/core-concepts/architecture.md): Where AutoPIL sits in the stack — governing retrieval between your data sources and agents. - [Enforcement flow](https://autopil-docs.documentationai.com/core-concepts/enforcement-flow.md): The ten ordered checks every guard.protect() call runs, from agent identity binding to policy evaluation. - [Multi-tenancy](https://autopil-docs.documentationai.com/core-concepts/multi-tenancy.md): How row-level tenant isolation scopes audit events, policies, and keys to each tenant. - [Agent identity](https://autopil-docs.documentationai.com/core-concepts/agent-identity.md): Layered agent identity enforcement — registry approval, role restriction, key binding, and policy-level agent IDs. - [Policy file format](https://autopil-docs.documentationai.com/policy-guide/policy-format.md): Structure of an AutoPIL policy YAML file and how multiple roles are defined. - [Fields reference](https://autopil-docs.documentationai.com/policy-guide/fields-reference.md): Reference for every policy field — its type, whether it is required, and what it controls. - [Evaluation order](https://autopil-docs.documentationai.com/policy-guide/evaluation-order.md): The order policy conditions are checked and where evaluation stops on the first match. - [Sensitivity levels](https://autopil-docs.documentationai.com/policy-guide/sensitivity-levels.md): The four sensitivity levels from low to critical and the data each is intended for. - [Task scoping](https://autopil-docs.documentationai.com/policy-guide/task-scoping.md): Restrict a role to categories of work using task_type with allowed_tasks and denied_tasks. - [Hot reload](https://autopil-docs.documentationai.com/policy-guide/hot-reload.md): Apply edited policy files live — no server restart and no interruption to running agents. - [Agent ID binding in policies](https://autopil-docs.documentationai.com/policy-guide/agent-id-binding.md): Lock a policy to specific registered agent instances with permitted_agent_ids. - [Choosing an integration pattern](https://autopil-docs.documentationai.com/sdks/integration-patterns.md): Choose between the embedded decorator and the REST API for your deployment and identity model. - [Python SDK](https://autopil-docs.documentationai.com/sdks/python-sdk.md): Embed the ContextGuard decorator directly in your Python agent process. - [Connecting to a hosted instance (Render / production)](https://autopil-docs.documentationai.com/sdks/connecting-to-hosted-instance.md): Call the REST API from Python when AutoPIL runs on Render or another remote host. - [Async decorator — protect_async](https://autopil-docs.documentationai.com/sdks/async-protect-async.md): Use protect_async for FastAPI, asyncio, and other async frameworks with contextvars support. - [ASGI Middleware](https://autopil-docs.documentationai.com/sdks/middleware.md): Enforce access policy at the HTTP layer for FastAPI and Starlette with AutoPILMiddleware. - [MCP Server](https://autopil-docs.documentationai.com/sdks/mcp-server.md): Expose AutoPIL context governance as native MCP tools for Claude, GPT, Gemini, and other agents. - [Framework integrations](https://autopil-docs.documentationai.com/sdks/frameworks.md): Native guard subclasses for the five major agent frameworks, each tagged with its own source_type. - [Go SDK](https://autopil-docs.documentationai.com/sdks/go-sdk.md): A dependency-free Go REST client built on net/http and encoding/json, requiring Go 1.21+. - [Java SDK](https://autopil-docs.documentationai.com/sdks/java-sdk.md): A Jackson-based Java REST client on java.net.http.HttpClient, requiring Java 17+. - [Local development](https://autopil-docs.documentationai.com/deployment/local.md): Run the core backend and dashboard from the monorepo in local development, with a server flag reference. - [Docker](https://autopil-docs.documentationai.com/deployment/docker.md): Run AutoPIL with Docker, including the admin-key lookup. - [Postgres](https://autopil-docs.documentationai.com/deployment/postgres.md): Point AutoPIL at Postgres, with automatic schema creation and safe idempotent migrations. - [OpenTelemetry](https://autopil-docs.documentationai.com/deployment/opentelemetry.md): Enable OpenTelemetry traces and metrics; a complete no-op when the OTLP endpoint is unset. - [Alerting (SMTP)](https://autopil-docs.documentationai.com/deployment/alerting.md): Configure SMTP email delivery for alert rules and how missing settings are handled. - [Retention](https://autopil-docs.documentationai.com/deployment/retention.md): Set per-tenant audit and session retention windows from the dashboard in production. - [PII masking](https://autopil-docs.documentationai.com/deployment/pii-masking.md): Mask sensitive fields in audit events before they are written, for privacy-sensitive deployments. ## API Reference - [Authentication](https://autopil-docs.documentationai.com/api-reference/authentication.md): API key authentication for all /v1/ routes via the X-API-Key header, including 401 and 403 behavior. - [Session retention](https://autopil-docs.documentationai.com/api-reference/session-retention.md): How expired and revoked session records are purged independently of audit events. - [PII masking](https://autopil-docs.documentationai.com/api-reference/pii-masking.md): Which audit fields are masked when PII masking is enabled, and how existing events are treated. - [Evaluate a retrieval request](https://autopil-docs.documentationai.com/api-reference/context/evaluate-context.md): Evaluate a retrieval request against policy. Returns ALLOW or DENY with the matched policy name, a human-readable reason, and an event_id for lineage. - [List audit events](https://autopil-docs.documentationai.com/api-reference/audit/list-audit-events.md): List audit events, filterable by role, decision, and source. - [Full audit trail for a session](https://autopil-docs.documentationai.com/api-reference/audit/get-session-audit.md): Return all events for a session, in order. - [Aggregate audit stats](https://autopil-docs.documentationai.com/api-reference/audit/get-audit-stats.md): Aggregate stats — totals, deny rate, top roles, and a by_source_type breakdown distinguishing SDK, API, framework, and REST traffic. - [Verify hash-chain integrity](https://autopil-docs.documentationai.com/api-reference/audit/verify-audit-chain.md): Verify the SHA-256 hash chain integrity for this tenant. - [Retention policy and last purge anchor](https://autopil-docs.documentationai.com/api-reference/audit/get-audit-retention.md): Active retention policy and last purge anchor for this tenant. anchor is null if no purge has run yet. - [Record a downstream action](https://autopil-docs.documentationai.com/api-reference/audit/record-lineage.md): Record a downstream action linked to an audit event (lineage). - [Event and its downstream actions](https://autopil-docs.documentationai.com/api-reference/audit/get-lineage.md): Return the event and all linked downstream actions. - [Log retention](https://autopil-docs.documentationai.com/api-reference/settings/log-retention.md): Configure per-tenant audit and session retention windows and inspect the purge chain anchor. - [Get retention settings](https://autopil-docs.documentationai.com/api-reference/settings/get-retention-settings.md): Return this tenant's current audit and session retention settings. - [Update retention settings](https://autopil-docs.documentationai.com/api-reference/settings/update-retention-settings.md): Update retention settings (admin-scoped key required). Either field is optional — omit one to leave it unchanged. Set to 0 to disable automatic purge for that data type. - [List active policies](https://autopil-docs.documentationai.com/api-reference/policies/list-policies.md): List active policies, filterable by industry, process group, or role. - [Create a policy](https://autopil-docs.documentationai.com/api-reference/policies/create-policy.md): Create a policy - [Update a policy](https://autopil-docs.documentationai.com/api-reference/policies/update-policy.md): Update a policy (saves version history, sets user_modified). - [Soft-delete a policy](https://autopil-docs.documentationai.com/api-reference/policies/delete-policy.md): Soft-delete a policy - [Policy version history](https://autopil-docs.documentationai.com/api-reference/policies/get-policy-history.md): Full version history for a policy. - [Restore a policy](https://autopil-docs.documentationai.com/api-reference/policies/restore-policy.md): Restore a policy to its original YAML definition (clears user_modified). - [Reload policies from disk](https://autopil-docs.documentationai.com/api-reference/policies/reload-policies.md): Reload all policies from disk without restart. - [Alert rule types](https://autopil-docs.documentationai.com/api-reference/alerts/alert-rule-types.md): Define threshold alert rules and review the deliveries they fire. - [Create an alert rule](https://autopil-docs.documentationai.com/api-reference/alerts/create-alert-rule.md): Create an alert rule. Rule types: denial_spike, new_source_access, isolation_violation, high_deny_rate. - [List alert rules](https://autopil-docs.documentationai.com/api-reference/alerts/list-alert-rules.md): List alert rules - [Update an alert rule](https://autopil-docs.documentationai.com/api-reference/alerts/update-alert-rule.md): Update a rule (enable/disable, thresholds). - [Delete an alert rule](https://autopil-docs.documentationai.com/api-reference/alerts/delete-alert-rule.md): Delete an alert rule - [List fired alert deliveries](https://autopil-docs.documentationai.com/api-reference/alerts/list-fired-alerts.md): List fired alert deliveries with trigger details. - [List sessions](https://autopil-docs.documentationai.com/api-reference/sessions/list-sessions.md): List sessions, filterable by role and status. - [Session detail](https://autopil-docs.documentationai.com/api-reference/sessions/get-session.md): Session detail and status. - [Revoke a session](https://autopil-docs.documentationai.com/api-reference/sessions/revoke-session.md): Revoke a session immediately. - [API key scopes](https://autopil-docs.documentationai.com/api-reference/keys/key-scopes.md): Create, list, rotate, revoke, and bind API keys across three permission scopes. - [Key binding](https://autopil-docs.documentationai.com/api-reference/keys/key-binding.md): Bind a key to a registered agent and restrict it to specific roles. - [Create an API key](https://autopil-docs.documentationai.com/api-reference/keys/create-key.md): Create an API key — the plaintext key is returned once; store it immediately. Keys support three scopes: admin, read, evaluate. - [List keys](https://autopil-docs.documentationai.com/api-reference/keys/list-keys.md): List keys for the tenant (no plaintext). - [Revoke a key](https://autopil-docs.documentationai.com/api-reference/keys/revoke-key.md): Revoke a key immediately. - [Rotate a key](https://autopil-docs.documentationai.com/api-reference/keys/rotate-key.md): Rotate a key — creates a replacement with the same scope and expiry, and revokes the original. - [Bind a key to an agent or roles](https://autopil-docs.documentationai.com/api-reference/keys/bind-key.md): Bind a key to a registered agent and/or restrict it to specific roles. Both fields are optional and independent. - [Agent registry](https://autopil-docs.documentationai.com/api-reference/agents/registry-overview.md): Register, approve, and manage agent instances in the authoritative agent registry. - [Register a new agent](https://autopil-docs.documentationai.com/api-reference/agents/register-agent.md): Register a new agent — status starts as draft. - [List agents](https://autopil-docs.documentationai.com/api-reference/agents/list-agents.md): List all registered agents for this tenant. - [Get an agent](https://autopil-docs.documentationai.com/api-reference/agents/get-agent.md): Get a single agent by ID — includes live activity stats. - [Update agent metadata](https://autopil-docs.documentationai.com/api-reference/agents/update-agent.md): Update agent metadata — display name, description, framework, owner. - [Transition agent approval status](https://autopil-docs.documentationai.com/api-reference/agents/update-agent-status.md): Transition approval status: draft → pending_approval → approved → deprecated. - [Registry-wide agent counts](https://autopil-docs.documentationai.com/api-reference/agents/get-agent-stats-summary.md): Registry-wide counts — total, approved, pending, deny rates. - [Tenant enforcement settings](https://autopil-docs.documentationai.com/api-reference/admin/tenant-enforcement.md): Superadmin-only per-tenant enforcement flags, such as requiring an agent_id. - [Superadmin key provisioning](https://autopil-docs.documentationai.com/api-reference/admin/superadmin-provisioning.md): Provision keys for any tenant as a superadmin, without that tenant's credentials. - [Create a tenant](https://autopil-docs.documentationai.com/api-reference/admin/create-tenant.md): Create a tenant. Superadmin key only. - [Update tenant enforcement settings](https://autopil-docs.documentationai.com/api-reference/admin/update-tenant-settings.md): Update per-tenant enforcement flags — superadmin only. - [Provision a key for any tenant](https://autopil-docs.documentationai.com/api-reference/admin/provision-tenant-key.md): Provision a key for any tenant — superadmin only. Accepts the same name, scope, and expires_days fields as POST /v1/keys. - [Liveness probe](https://autopil-docs.documentationai.com/api-reference/health/health.md): Health check. No authentication required.