diff --git a/apps/deploy.mdx b/apps/deploy.mdx
index e574db30..8203ac9e 100644
--- a/apps/deploy.mdx
+++ b/apps/deploy.mdx
@@ -45,6 +45,22 @@ kernel deploy github \
- The CLI automatically downloads and extracts the GitHub source code and uploads your app for deployment.
- For private repositories, provide a `--github-token` or set the `GITHUB_TOKEN` environment variable.
+## Use a scoped API key
+
+
+Scoped deployments aren’t generally available yet. Until they’re enabled, the API returns `403` if you deploy with a scoped key or supply `runtime_policy`, even with an unrestricted key. Existing deployments are unchanged.
+
+
+To deploy with a [policy-scoped API key](/info/api-keys#scope-a-key-to-specific-resources), grant these actions on the deployment's project or organization container:
+
+- `deployments:create` to deploy the app.
+- `deployments:delete` to replace older deployments of the same app and version.
+- `invocations:write` so the runtime can report invocation results and attach browsers.
+
+By default, each invocation's key gets only project-wide `invocations:write` so the runtime can report results. Each run gets a fresh key valid for 65 minutes. The deployment's policy doesn't expire with your deploying key. This minimum permission applies to the whole project, not just this deployment's invocations. To invoke the app with a scoped key, grant `invocations:create` and cover the runtime policy. See the [app policy example](/info/api-key-policy-examples) and [deployment key lifecycle](/info/api-keys#deployment-api-keys).
+
+To give your app additional permissions, send an explicit `runtime_policy` JSON field in the `POST /deployments` multipart request. Include an unconditional `invocations:write` grant on `projects/{project_id}/*` for callbacks, plus the permissions your app uses. A supplied policy missing that minimum is rejected; permissions aren't silently added. Your deploying key must cover the requested permissions, and `api_keys:issue_beyond_expiry` isn't allowed.
+
## Environment variables
You can set environment variables for your app using the `--env` flag. For example:
@@ -71,7 +87,7 @@ kernel deploy my_app.py --env-file .env
Kernel injects a few environment variables into every deployment and its invocations. These names are **reserved** — if you set them via `--env` or `--env-file`, Kernel overrides your value, so setting them has no effect:
-- `KERNEL_API_KEY` — a per-deployment API key Kernel mints at deploy time (see [Deployment API keys](/info/api-keys#deployment-api-keys)). The SDKs read it from the environment by default, so your app authenticates with this key automatically.
+- `KERNEL_API_KEY` — the runtime key Kernel supplies to your app (see [Deployment API keys](/info/api-keys#deployment-api-keys)). The SDKs read it from the environment by default, so your app authenticates with this key automatically.
- `ENTRYPOINT_RELPATH` — set by the platform to locate your entrypoint.
#### Using a different key for your app's calls
diff --git a/browsers/telemetry/export.mdx b/browsers/telemetry/export.mdx
index c6737889..8c309b67 100644
--- a/browsers/telemetry/export.mdx
+++ b/browsers/telemetry/export.mdx
@@ -12,7 +12,7 @@ Events are exported as OTLP **logs**. Kernel appends `/v1/logs` to your endpoint
## How export works
-You create a **destination** - an OTLP/HTTP endpoint plus the headers your backend expects - and select it when you create a browser. Destinations belong to your organization, so a browser in any project can export to them.
+You create a **destination** - an OTLP/HTTP endpoint plus the headers your backend expects - and select it when you create a browser. Unrestricted keys can select destinations across the organization. With a policy-scoped key, create and select the destination in the project where the browser runs.
Kernel's relay forwards the session's events to the destination and attaches your headers at export time. Headers are encrypted at rest and never reach the browser VM, so a session can export to your backend without ever holding your ingestion key.
@@ -62,6 +62,8 @@ You can also manage destinations in the dashboard under **Telemetry Destinations
Creating, updating, and deleting a destination requires organization-scoped authentication, such as an organization-wide API key or the dashboard; a project-scoped API key gets a `403`. Project-scoped keys can still list and retrieve destinations, and select one when creating a browser.
+For a key with a policy, grant `telemetry_destinations:read` to inspect a destination and `telemetry_destinations:use` to select it for export. Management uses the separate `create`, `write`, and `delete` actions. See the [telemetry policy example](/info/api-key-policy-examples) and [permission reference](/info/api-key-permissions#telemetry-destinations).
+
Header values are write-only. API, SDK, and CLI responses show each header name with an empty value, and the dashboard shows only header names: to change a stored value there, enter a replacement, or leave the field blank to keep the current value.
An organization can have up to 50 destinations. Names must match `^[a-zA-Z0-9._-]{1,255}$`, must be unique within the organization, and can't look like a Kernel ID. A destination can have up to 32 headers, with names and values totaling at most 8,192 bytes.
diff --git a/docs.json b/docs.json
index f3cf3561..0f814137 100644
--- a/docs.json
+++ b/docs.json
@@ -310,6 +310,7 @@
},
"info/api-keys",
"info/api-key-permissions",
+ "info/api-key-policy-examples",
"info/audit-logs",
"info/network-access"
]
diff --git a/info/api-key-permissions.mdx b/info/api-key-permissions.mdx
index 6ef92716..1cc847ab 100644
--- a/info/api-key-permissions.mdx
+++ b/info/api-key-permissions.mdx
@@ -3,11 +3,11 @@ title: "Scoping Permissions"
description: "Actions and resources you can grant in a policy for an API key, a federation rule, or a service account API key"
---
-A **policy** limits what a credential can do. It's a list of allow statements, each pairing one action with one resource, and everything it doesn't list is denied. This page lists everything you can grant in a policy.
+A **policy** limits what a credential can do. It's a list of allow statements, each pairing one action with one resource, and everything it doesn't list is denied. Start with a [policy example](/info/api-key-policy-examples) or use the action tables below to build your own.
## Where policies apply
-Three kinds of credential carry a policy, and all three use the same format:
+API keys and workload identity rules use the same statement format:
| Credential | Policy | Boundary |
| --- | --- | --- |
@@ -21,13 +21,30 @@ For a CI job, cloud service, or Kubernetes pod, put the policy on a federation r
## Resources
-| Resource | Matches |
+| Selector | Matches |
| --- | --- |
-| `organizations/{org_id}/*` | Everything in the organization. |
-| `projects/{project_id}/*` | Everything in the project. |
-| `projects/{project_id}/{kind}/{id}` | One object. `kind` is `browsers`, `profiles`, `vaults`, or `proxies`. |
+| `organizations/{org_id}` | The organization itself, for organization actions. |
+| `projects/{project_id}` | The project itself, for project actions. |
+| `organizations/{org_id}/*` | Resources throughout the organization, for the statement's action. |
+| `projects/{project_id}/*` | Resources in one project, for the statement's action. |
+| `projects/{project_id}/{kind}/{id}` | One project-owned resource. |
+| `{kind}/{id}` | One resource. For a project-owned resource, the request's project determines its scope. Use this form for organization-owned resources. |
-Resources must be inside the credential's boundary: the organization, or the one project for a project-scoped key, a federation rule, or a service account API key. Kernel checks that every object ID exists when you create or update the key or rule.
+Choose `kind` from the following resource types:
+
+| Scope | Resource kinds |
+| --- | --- |
+| Project | `browsers`, `profiles`, `vaults`, `proxies`, `extensions`, `telemetry_destinations`, `browser_pools`, `tasks`, `deployments`, `invocations`, `credentials`, `auth_connections` |
+| Organization | `credential_providers`, `vault_provider_configs`, `audit_log_export_destinations` |
+| Matches the target key | `api_keys`: a project key belongs to its project; a key without a project belongs to the organization, not the default project. |
+
+Kernel checks that each object ID exists within the credential's boundary when you create or update a key or rule. Existing project-owned resources without a project are treated as belonging to the default project.
+
+Creation actions need a container selector ending in `/*`, rather than an existing object's ID. Project creation and creation of organization-owned resources need `organizations/{org_id}/*`. Audit log access also uses an organization container. Configuration registry actions use a project or organization container rather than individual analysis IDs.
+
+
+A policy narrows your key's access; it doesn't change its organization or project boundary. Use an organization-scoped key for organization administration, credential providers, wallet provider configurations, audit logs, and telemetry destination management. A project-scoped key can rename its own project, but project creation, deletion, status changes, and limit changes require an organization-scoped credential.
+
## Conditions
@@ -52,11 +69,22 @@ How conditions evaluate:
## Actions
+### Organizations and projects
+
+| Action | Allows |
+| --- | --- |
+| `organizations:read` | Read organization entitlements and limits. |
+| `organizations:write` | Set the organization's default per-project limits. |
+| `projects:create` | Create projects. Grant on the organization container. |
+| `projects:read` | List projects and read project metadata and limits. |
+| `projects:write` | Rename projects and set their limits. |
+| `projects:delete` | Archive or restore projects, and delete empty projects. A project update that changes `status` along with other fields also needs `projects:write`. |
+
### Browsers
| Action | Allows |
| --- | --- |
-| `browsers:create` | Create browsers. Grant it on a project or organization. |
+| `browsers:create` | Create browsers. |
| `browsers:use` | List, inspect, connect to, and control browsers. |
| `browsers:write` | Update browser configuration. |
| `browsers:delete` | Delete browsers. |
@@ -65,9 +93,9 @@ How conditions evaluate:
| Action | Allows |
| --- | --- |
-| `profiles:create` | Create profiles. Grant it on a project or organization. |
+| `profiles:create` | Create profiles. |
| `profiles:read` | List profiles and view their metadata. |
-| `profiles:use` | Attach profiles to browsers and download them. |
+| `profiles:use` | Attach profiles to browsers and download their archives. |
| `profiles:write` | Rename profiles and save browser state into them. |
| `profiles:delete` | Delete profiles. |
@@ -75,7 +103,7 @@ How conditions evaluate:
| Action | Allows |
| --- | --- |
-| `vaults:create` | Create vaults. Grant it on a project or organization. |
+| `vaults:create` | Create vaults. |
| `vaults:read` | List vaults and view vault and item metadata. |
| `vaults:use` | Link vaults to browsers, fill credentials, and run vault item operations. |
| `vaults:write` | Create, update, and delete vault items. |
@@ -85,31 +113,183 @@ How conditions evaluate:
| Action | Allows |
| --- | --- |
-| `proxies:create` | Create proxies. Grant it on a project or organization. |
+| `proxies:create` | Create and validate proxies. |
| `proxies:read` | List proxies and view their configuration, without credentials. |
| `proxies:use` | Select saved proxies for browsers and run health checks. |
| `proxies:write` | Rename proxies. |
| `proxies:delete` | Delete proxies. |
+### Extensions
+
+| Action | Allows |
+| --- | --- |
+| `extensions:create` | Upload saved extensions and import them from the Chrome Web Store. |
+| `extensions:read` | List extensions and read their metadata. |
+| `extensions:use` | Attach saved extensions to browsers and download their archives. |
+| `extensions:delete` | Delete extensions. |
+
+### Telemetry destinations
+
+| Action | Allows |
+| --- | --- |
+| `telemetry_destinations:create` | Create OTLP export destinations. |
+| `telemetry_destinations:read` | List destinations and read configuration and health, with header values redacted. |
+| `telemetry_destinations:use` | Select a destination for browser or auth connection telemetry export. |
+| `telemetry_destinations:write` | Update destinations, including endpoints and headers. A changed endpoint receives the stored headers. |
+| `telemetry_destinations:delete` | Delete destinations. |
+
+Scoped keys resolve destinations within the request's project. Reading and selecting a destination are separate permissions. Creating, updating, and deleting destinations also requires an organization-scoped credential.
+
+### Browser pools
+
+| Action | Allows |
+| --- | --- |
+| `browser_pools:create` | Create browser pools. |
+| `browser_pools:read` | List pools and read their configuration and browser counts. |
+| `browser_pools:use` | Acquire and release pooled browsers. |
+| `browser_pools:write` | Update pool configuration and flush idle browsers. |
+| `browser_pools:delete` | Delete pools and their browsers. |
+
+### Tasks and reports
+
+| Action | Allows |
+| --- | --- |
+| `tasks:create` | Create tasks. Grant on the project or organization container. |
+| `tasks:read` | List and read tasks, linked browser IDs, and reports; find report types for a task. |
+| `tasks:write` | Link browsers and submit reports. Also requires `tasks:read` on the task. |
+
+Reports use their parent task's permissions; they don't have separate policy selectors or actions. Linking a browser, including through a report, requires `browsers:use` on that browser, but not permissions on its attachments: linking doesn't control it. Reading a linked browser ID doesn't grant browser access. Retrieving a report type or version by name requires no additional policy action.
+
+### Apps, deployments, and invocations
+
+| Action | Allows |
+| --- | --- |
+| `deployments:create` | Deploy apps, together with `deployments:delete` and `invocations:write`. |
+| `deployments:read` | List apps and deployments, and read deployment details, events, and logs. |
+| `deployments:delete` | Stop and delete deployments, including versions replaced by a new deployment. |
+| `invocations:create` | Run app actions, subject to the runtime-key requirements below. |
+| `invocations:read` | List invocations and read payloads, outputs, events, and logs. |
+| `invocations:write` | Update invocation status and output, and attach new browsers to invocations. |
+
+Apps are authorized through their deployments. An invocation belongs to its deployment's project. See [Deployment API keys](/info/api-keys#deployment-api-keys) for runtime permissions and expiry.
+
+
+Deploying with a scoped credential or supplying `runtime_policy` requires scoped deployments to be enabled. Otherwise, `POST /deployments` returns `403`. Machine OAuth clients and [service accounts](/info/workload-identity/service-accounts#what-a-service-account-cant-do) can’t deploy or invoke apps, even with these actions.
+
+
+### Credentials and auth connections
+
+| Action | Allows |
+| --- | --- |
+| `credentials:create` | Create stored credentials. |
+| `credentials:read` | List credentials and read metadata and field names, without secret values. |
+| `credentials:use` | Generate TOTP codes and use credentials through auth connections or vault items. |
+| `credentials:write` | Update credential values and save login values into credentials. |
+| `credentials:delete` | Delete credentials. |
+| `auth_connections:create` | Create managed auth connections. |
+| `auth_connections:read` | Read connection configuration, state, events, and timelines. |
+| `auth_connections:use` | Start logins, submit login input, and obtain hosted login and live view URLs. |
+| `auth_connections:write` | Update connection configuration. |
+| `auth_connections:delete` | Delete connections. |
+
+A read grant returns connection metadata. To receive hosted login or live view URLs, you also need `auth_connections:use` and the referenced-resource permissions needed to run that login.
+
+### Credential providers and wallet provider configurations
+
+| Action | Allows |
+| --- | --- |
+| `credential_providers:create` | Create organization credential providers. |
+| `credential_providers:read` | List providers and read their metadata, without tokens. |
+| `credential_providers:use` | Test providers, list their items, and use them for auth connection logins. |
+| `credential_providers:write` | Update providers, including their tokens. |
+| `credential_providers:delete` | Delete providers. |
+| `vault_provider_configs:create` | Create organization wallet provider configurations. |
+| `vault_provider_configs:read` | List provider configurations and read their settings, without secrets. |
+| `vault_provider_configs:use` | Bind vault wallets to provider configurations. |
+| `vault_provider_configs:write` | Update provider configurations, including their secrets. |
+| `vault_provider_configs:delete` | Delete provider configurations. |
+
+### API keys
+
+| Action | Allows |
+| --- | --- |
+| `api_keys:create` | Issue keys in the authorized container. A scoped issuer must grant a subset of its own policy. |
+| `api_keys:issue_beyond_expiry` | Allow a scoped key's finite expiry to exceed the caller's, up to 3650 days. Grant it on the new key's container for creation, or the existing key for rotation. Scoped callers cannot pass this permission to another key. |
+| `api_keys:read` | List keys and read metadata and policies, without plaintext keys. |
+| `api_keys:write` | Rename keys. |
+| `api_keys:set_policy` | Replace a key’s entire policy without rotating its secret. A scoped caller must cover both the existing and replacement policies and can’t convert an unrestricted key. Renaming the key in the same request also requires `api_keys:write`. |
+| `api_keys:rotate` | Replace keys whose policies the caller covers, returning the new plaintext key. |
+| `api_keys:delete` | Revoke keys. |
+
+A new key with a policy must expire no later than the credential that creates it unless that credential holds `api_keys:issue_beyond_expiry` on the target container. The same limit applies when a caller with a policy rotates a key, checked on the existing key. Rotation by a caller without a policy keeps its existing replacement-lifetime behavior. Excessive expiry requests return `400`; Kernel never silently shortens them. Other permission checks still apply. See [Delegating access](/info/api-keys#delegate-a-narrower-key).
+
+Native OAuth tokens can’t manage API keys. This applies to human sign-ins (including requests for identity scopes only), machine tokens, and exchanged tokens. OAuth rejects requests for `api_keys:` permissions. Use a personal API key with the required permissions instead.
+
+### Audit logs and export destinations
+
+| Action | Allows |
+| --- | --- |
+| `audit_logs:read` | Read and export organization audit logs. |
+| `audit_log_export_destinations:create` | Create paused export destinations. |
+| `audit_log_export_destinations:read` | List destinations and read configuration and delivery status. |
+| `audit_log_export_destinations:use` | Write a test object to a destination. |
+| `audit_log_export_destinations:write` | Reconfigure, pause, or activate destinations. Also requires `audit_logs:read`. |
+| `audit_log_export_destinations:delete` | Delete destinations. |
+
+### Configuration registry
+
+| Action | Allows |
+| --- | --- |
+| `config_registry:read` | Look up recommended browser configurations and read analyses. |
+| `config_registry:create` | Start or resolve configuration analyses. Also requires `config_registry:read`. |
+| `config_registry:write` | Cancel configuration analyses. |
+
## Operations that need more than one action
+### Browsers and pools
+
| Operation | Requires |
| --- | --- |
-| Create a browser | `browsers:create` and `browsers:use` on the project or organization, because the response includes connection URLs. Add `profiles:use` on its profile, `profiles:write` if it saves profile changes, `vaults:use` on each linked vault, and `proxies:use` on a saved proxy. |
-| Any operation on an existing browser | The browser action, plus `profiles:use` on its attached profile and `vaults:use` on every linked vault. If the browser saves profile changes, `profiles:write` on that profile too. |
-| Update a browser | `browsers:write` and `browsers:use`, plus `use` on any profile, vault, or proxy the update adds. |
-| Fill from a vault | `vaults:use` on the vault and `browsers:use` on the browser. |
-| Add or remove a card in a Kernel wallet (`add_payment_method`, `remove_payment_method`) | `vaults:use` and `vaults:write` on the vault. Without `vaults:write`, the wallet doesn't list either operation in `available_operations`, and invoking one returns `403` with `insufficient_scope`. Other wallet and purchase operations need only `vaults:use`. |
+| Create a browser | Container-wide `browsers:create` and `browsers:use`, because the response includes connection URLs. Add `profiles:use` on its profile, `profiles:write` if it saves changes, `vaults:use` on each linked vault, `extensions:use` on saved extensions, `proxies:use` on selected saved proxies, and `telemetry_destinations:use` on an export destination. |
+| Access an existing browser | The browser action, plus `profiles:use` on its attached profile, `vaults:use` on linked vaults, and `extensions:use` on saved extensions. If the browser saves profile changes, also grant `profiles:write`. |
+| Update a browser | `browsers:write` and `browsers:use`, plus permissions on attached resources and newly selected resources. |
+| Create or update a pool | The pool's `create` or `write` action, plus `profiles:use` and `proxies:use` on selected resources, including proxy routes. Selecting saved extensions isn't supported for scoped credentials yet. |
+| Acquire a pooled browser | `browser_pools:use`, container-wide `browsers:use`, and permissions on the pool's profile/extensions and the browser's actual attachments. An acquire-time profile also requires `profiles:write` when saving changes. |
+| Release a pooled browser | `browser_pools:use` and access to the leased browser, including its attachments. |
+| Force-delete a pool with leased browsers | `browser_pools:delete` and `browsers:delete` on every leased browser. |
| Run a proxy health check | `proxies:use` and `proxies:read`. |
-List endpoints return only the objects the credential can access, so a credential without a matching grant gets an empty list.
+Browsers used for managed auth logins, reauthentication, or health checks additionally require `auth_connections:use` and the current connection's profile, credential, and provider permissions. This applies to browser lists and direct access. If the source connection is unavailable, those browsers remain hidden and inaccessible to scoped keys.
+
+### Auth connections and vaults
+
+| Operation | Requires |
+| --- | --- |
+| Create or update an auth connection, start a login, or submit login input | The connection's action, `profiles:use` and `profiles:write` on its profile, and `credentials:use` on a linked credential. Add `credentials:write` when saving values into an existing credential, `profiles:create` when creating a profile, and `credential_providers:use` for a provider-backed connection. Creating a credential, including automatically during a later login, requires container-wide `credentials:create`, `credentials:use`, and `credentials:write`. |
+| Select a proxy or telemetry destination for an auth connection | `proxies:use` or `telemetry_destinations:use` on the selected resource, in addition to connection and login-resource permissions. Stored telemetry destinations are also checked when you start a login. |
+| Fill from a vault | `vaults:use` and browser access, including the browser's attachments. |
+| Create a vault item backed by an auth connection | `vaults:write` on the vault, `auth_connections:use` on the connection, and `credentials:use` on its saved credential. |
+| Bind a provider wallet to a vault | `vaults:write` on the vault and `vault_provider_configs:use` on the provider configuration. |
+| Add or remove a stored wallet card (`add_payment_method`, `remove_payment_method`) | `vaults:use` and `vaults:write`. These operations appear in `available_operations` only with write access. Other wallet and purchase operations require `vaults:use`. |
+
+Connection updates check the resulting configuration. Turning off credential saving also checks the existing configuration, because an already-running login can still save values. Background health checks and reauthentication continue using the connection's saved configuration after the configuring API key is revoked; update or delete the connection to change that behavior.
+
+### Apps and services
+
+| Operation | Requires |
+| --- | --- |
+| Deploy an app | Container-wide `deployments:create`, `deployments:delete`, and `invocations:write`. By default, the runtime key gets only project-wide `invocations:write`. Supply `runtime_policy` for additional permissions; it must explicitly include that minimum and exclude `api_keys:issue_beyond_expiry`. Each invocation gets a fresh 65-minute key; the deployment policy doesn't expire with your credential. |
+| Invoke an app action | Container-wide `invocations:create`. Your policy must cover the runtime policy. Existing shared runtime keys must also be live and expire no later than yours. |
+| Read invocation events | `invocations:read` and `deployments:read`, because the stream includes deployment state. |
+| Create a browser attached to an invocation | Browser creation permissions plus `invocations:write` on the invocation. |
+| Create or rotate an API key with a key that has a policy | `api_keys:create` on the new key's container, or `api_keys:rotate` on the existing key, plus every permission in the resulting key's policy. If your key expires, the new or replacement key must expire no later than it unless you also hold `api_keys:issue_beyond_expiry` on the target and request a finite lifetime of up to 3650 days. You can't issue or rotate a key carrying that permission. |
+| Update an audit export destination | `audit_log_export_destinations:write` and organization-wide `audit_logs:read`. |
+| Resolve a browser configuration | `config_registry:create` and `config_registry:read`. |
+
+## Lists and authentication
-## Not available to credentials with a policy
+Resource lists, such as browsers, profiles, pools, and API keys, filter permissions before pagination. A key with no grant for those resources receives an empty list.
-A credential with a policy gets `403` with `insufficient_scope` on:
+`GET /auth/context` describes the calling credential and needs no additional policy action; the key must still be valid and unexpired.
-- API key management, including creating, listing, rotating, and deleting keys.
-- Browser pools.
-- Project and organization endpoints, such as listing projects or reading limits.
-- Creating browsers that use saved extensions, telemetry export, or app invocations.
-- Any other endpoint not covered by the actions above.
+Payment-authenticated browser creation, card-capture tokens, and managed auth handoff-code exchange keep their own authentication protocols. An API key policy doesn't replace those credentials.
diff --git a/info/api-key-policy-examples.mdx b/info/api-key-policy-examples.mdx
new file mode 100644
index 00000000..d0419902
--- /dev/null
+++ b/info/api-key-policy-examples.mdx
@@ -0,0 +1,273 @@
+---
+title: "API Key Policy Examples"
+description: "Policies for browser automation, pools, managed auth, app execution, and administration"
+---
+
+Start with the example closest to your workload and keep only the permissions you need. Each snippet defines a `policy` value to pass to the [API key creation call](/info/api-keys#create-a-scoped-key). TypeScript and Python examples grant the same permissions.
+
+The IDs below represent resources you've already created. Replace them with IDs returned by your own API requests; exact resource IDs are validated when you issue a key. Most examples fit a project-scoped key with `project_id: 'proj_staging_9f3k'`. Examples that include organization resources require an organization-scoped key.
+
+For every available action and its prerequisites, see [API key permissions](/info/api-key-permissions).
+
+
+
+
+Use an organization-scoped key to read organization limits and view or update one project. Omit `project_id` when issuing this key.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'organizations:read', resource: 'organizations/org_8f3k9m2q' },
+ { action: 'projects:read', resource: 'projects/proj_staging_9f3k' },
+ { action: 'projects:write', resource: 'projects/proj_staging_9f3k' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "organizations:read", "resource": "organizations/org_8f3k9m2q"},
+ {"action": "projects:read", "resource": "projects/proj_staging_9f3k"},
+ {"action": "projects:write", "resource": "projects/proj_staging_9f3k"},
+ ],
+}
+```
+
+
+Add `projects:delete` on `projects/proj_staging_9f3k` to archive or restore the project. Create additional projects with `projects:create` on `organizations/org_8f3k9m2q/*`.
+
+
+
+Create and control browsers in the staging project using one saved extension.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'browsers:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'browsers:use', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'extensions:read', resource: 'projects/proj_staging_9f3k/extensions/ext_9k4m2q7s' },
+ { action: 'extensions:use', resource: 'projects/proj_staging_9f3k/extensions/ext_9k4m2q7s' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "browsers:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "browsers:use", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "extensions:read", "resource": "projects/proj_staging_9f3k/extensions/ext_9k4m2q7s"},
+ {"action": "extensions:use", "resource": "projects/proj_staging_9f3k/extensions/ext_9k4m2q7s"},
+ ],
+}
+```
+
+
+Pass `ext_9k4m2q7s` in the browser request's `extensions` list. Include `extensions:use` on every saved extension attached to a browser you access.
+
+
+
+Create browsers in staging and send their telemetry to one saved destination.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'browsers:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'browsers:use', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'telemetry_destinations:read', resource: 'projects/proj_staging_9f3k/telemetry_destinations/tdst_8k2q4m6r' },
+ { action: 'telemetry_destinations:use', resource: 'projects/proj_staging_9f3k/telemetry_destinations/tdst_8k2q4m6r' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "browsers:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "browsers:use", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "telemetry_destinations:read", "resource": "projects/proj_staging_9f3k/telemetry_destinations/tdst_8k2q4m6r"},
+ {"action": "telemetry_destinations:use", "resource": "projects/proj_staging_9f3k/telemetry_destinations/tdst_8k2q4m6r"},
+ ],
+}
+```
+
+
+Select destination ID `tdst_8k2q4m6r` in `telemetry.export.otlp.destination`. `telemetry_destinations:read` lets you inspect the destination; `telemetry_destinations:use` authorizes export.
+
+
+
+Acquire and release browsers from one pool that uses a saved profile.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'browser_pools:read', resource: 'projects/proj_staging_9f3k/browser_pools/pool_6m2k9q4s' },
+ { action: 'browser_pools:use', resource: 'projects/proj_staging_9f3k/browser_pools/pool_6m2k9q4s' },
+ { action: 'browsers:use', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'profiles:use', resource: 'projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "browser_pools:read", "resource": "projects/proj_staging_9f3k/browser_pools/pool_6m2k9q4s"},
+ {"action": "browser_pools:use", "resource": "projects/proj_staging_9f3k/browser_pools/pool_6m2k9q4s"},
+ {"action": "browsers:use", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "profiles:use", "resource": "projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1"},
+ ],
+}
+```
+
+
+Use pool `pool_6m2k9q4s`, configured with profile `prof_7h2kq9x4m1`. If its browsers also carry vaults or saved extensions, grant use of those resources too. An acquire-time profile that saves changes also needs `profiles:write`.
+
+
+
+Read a connection and start logins using its saved profile and credential, including saving updated credential values.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'auth_connections:read', resource: 'projects/proj_staging_9f3k/auth_connections/mconn_5k3m8q2r' },
+ { action: 'auth_connections:use', resource: 'projects/proj_staging_9f3k/auth_connections/mconn_5k3m8q2r' },
+ { action: 'profiles:use', resource: 'projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1' },
+ { action: 'profiles:write', resource: 'projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1' },
+ { action: 'credentials:use', resource: 'projects/proj_staging_9f3k/credentials/cred_4q8m2k6s' },
+ { action: 'credentials:write', resource: 'projects/proj_staging_9f3k/credentials/cred_4q8m2k6s' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "auth_connections:read", "resource": "projects/proj_staging_9f3k/auth_connections/mconn_5k3m8q2r"},
+ {"action": "auth_connections:use", "resource": "projects/proj_staging_9f3k/auth_connections/mconn_5k3m8q2r"},
+ {"action": "profiles:use", "resource": "projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1"},
+ {"action": "profiles:write", "resource": "projects/proj_staging_9f3k/profiles/prof_7h2kq9x4m1"},
+ {"action": "credentials:use", "resource": "projects/proj_staging_9f3k/credentials/cred_4q8m2k6s"},
+ {"action": "credentials:write", "resource": "projects/proj_staging_9f3k/credentials/cred_4q8m2k6s"},
+ ],
+}
+```
+
+
+Use connection `mconn_5k3m8q2r`, configured with profile `prof_7h2kq9x4m1` and credential `cred_4q8m2k6s`. Provider-backed connections additionally require `credential_providers:use` on the organization-owned provider, so they need an organization-scoped key. If the connection must create a credential, grant container-wide `credentials:create`, `credentials:use`, and `credentials:write` instead of exact-ID credential grants.
+
+
+
+Deploy and run an app in staging, and read its deployment and invocation results.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'deployments:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'deployments:delete', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'deployments:read', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'invocations:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'invocations:write', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'invocations:read', resource: 'projects/proj_staging_9f3k/*' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "deployments:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "deployments:delete", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "deployments:read", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "invocations:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "invocations:write", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "invocations:read", "resource": "projects/proj_staging_9f3k/*"},
+ ],
+}
+```
+
+
+Use a key with this policy to deploy and invoke the app. This example requires scoped deployments to be enabled; until then the deploy request returns `403`. With `runtime_policy` omitted, the runtime key gets only project-wide `invocations:write`, not the rest of the deploying key's permissions. For browser, profile, vault, or other operations, grant the deploying key those permissions and include them in an explicit runtime policy as shown below. An invocation's caller must cover the runtime key's full policy. Each invocation gets a new key valid for 65 minutes, independent of the deploying key's expiry.
+
+
+
+When you deploy with a scoped key and omit `runtime_policy`, the app gets only project-wide `invocations:write`. Use an explicit runtime policy to add browser access without deployment-management permissions. This app creates browsers without saved profiles or other attached resources.
+
+
+```typescript TypeScript
+const runtimePolicy = {
+ statements: [
+ { action: 'invocations:write', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'browsers:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'browsers:use', resource: 'projects/proj_staging_9f3k/*' },
+ ],
+};
+
+const invokerPolicy = {
+ statements: [
+ { action: 'invocations:create', resource: 'projects/proj_staging_9f3k/*' },
+ ...runtimePolicy.statements,
+ ],
+};
+```
+
+```python Python
+runtime_policy = {
+ "statements": [
+ {"action": "invocations:write", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "browsers:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "browsers:use", "resource": "projects/proj_staging_9f3k/*"},
+ ],
+}
+
+invoker_policy = {
+ "statements": [
+ {"action": "invocations:create", "resource": "projects/proj_staging_9f3k/*"},
+ *runtime_policy["statements"],
+ ],
+}
+```
+
+
+Send the runtime policy as JSON in the `runtime_policy` multipart field of `POST /deployments`. The deploying key needs every runtime permission plus `deployments:create` and `deployments:delete` on the project. Issue a separate key with the invoker policy to start actions without deployment-management access.
+
+A supplied runtime policy with only `browsers:create` and `browsers:use` is rejected with `400`: it must explicitly include project-wide `invocations:write`. Permissions aren't silently added.
+
+A key with only `invocations:create` still fails to invoke this app: it doesn't cover the runtime's browser and callback permissions. If you omit `runtime_policy`, the app gets only project-wide `invocations:write`, and an invoking key needs that permission plus `invocations:create`. Add `invocations:read` and `deployments:read` if the invoker also needs invocation results and event streams.
+
+
+
+Read staging API-key metadata, read organization audit logs, and look up browser configuration recommendations. Issue this as an organization-scoped key by omitting `project_id`.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { action: 'api_keys:read', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'audit_logs:read', resource: 'organizations/org_8f3k9m2q/*' },
+ { action: 'config_registry:read', resource: 'projects/proj_staging_9f3k/*' },
+ ],
+};
+```
+
+```python Python
+policy = {
+ "statements": [
+ {"action": "api_keys:read", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "audit_logs:read", "resource": "organizations/org_8f3k9m2q/*"},
+ {"action": "config_registry:read", "resource": "projects/proj_staging_9f3k/*"},
+ ],
+}
+```
+
+
+API-key reads return metadata and policies. Creating delegated keys requires `api_keys:create` on their container plus the permissions you intend to delegate; rotating keys requires `api_keys:rotate` and coverage of their policy.
+
+
diff --git a/info/api-keys.mdx b/info/api-keys.mdx
index bdb90016..17b922ec 100644
--- a/info/api-keys.mdx
+++ b/info/api-keys.mdx
@@ -23,6 +23,8 @@ API keys can be **org** or **project** scoped:
- Set `project_id` to create a project-scoped key that can only access resources in that project.
- When you authenticate with a project-scoped key, you can only create another project-scoped key for the same project.
+Organization/project scope sets the key's boundary. A `policy` separately limits which actions and resources it can access inside that boundary. Both organization- and project-scoped keys can have policies.
+
## Create an API key
Use the SDKs when your backend needs to provision keys for environments, customers, or automation jobs.
@@ -94,7 +96,7 @@ func main() {
## Scope a key to specific resources
-By default, an API key can do anything in its organization or project. Add a `policy` when you create a key to limit what it can do. Keys created without `policy` work exactly as before.
+A personal API key without a policy is unrestricted within its organization or project. Add a `policy` when you create a key to limit what it can do. Keys created without `policy` work exactly as before.
Use scoped keys when you hand a credential to code you trust less than your backend, such as an AI agent or a short-lived job.
@@ -102,13 +104,15 @@ Use scoped keys when you hand a credential to code you trust less than your back
A policy is a list of **statements**. Each statement allows one **action** on one **resource**, and the key is denied everything no statement allows.
-- A **resource** is either one object, `projects/{project_id}/{kind}/{id}`, or everything in a container, `projects/{project_id}/*` or `organizations/{org_id}/*`.
-- An **action** is `{kind}:{verb}`, such as `browsers:use` or `vaults:read`.
+- A **resource** selects one project-owned object, such as `projects/{project_id}/extensions/{extension_id}`, an organization-owned object, such as `credential_providers/{provider_id}`, or a container such as `projects/{project_id}/*` or `organizations/{org_id}/*`.
+- An **action** is an exact name such as `browsers:use`, `extensions:read`, or `api_keys:create`. A container wildcard grants that action throughout the container, not every action.
A statement can also carry a **condition** that narrows it to matching requests. A condition names a request attribute, a comparison operator, and that operator's values. See [Limit a key to your IP ranges](/info/api-keys#limit-a-key-to-your-ip-ranges).
Some operations need more than one action. For example, creating a browser with a profile needs `browsers:create` and `browsers:use` on the project, plus `profiles:use` on that profile. See [API key permissions](/info/api-key-permissions) for every action and what each operation requires.
+Policies cover browsers, profiles, vaults, proxies, extensions, telemetry destinations, browser pools, tasks and reports, apps, managed auth, credentials, organization/project administration, API keys, audit logs, and the configuration registry. Start with a [policy example](/info/api-key-policy-examples) for your workload.
+
### Create a scoped key
This key can create and control browsers in one project, only with profile `prof_7h2kq9x4m1` or no profile, and expires in one hour:
@@ -164,10 +168,11 @@ print(api_key.key) # Save this value now. Kernel won't show it again.
### Expiry and revocation
-- Use `expires_at` for an exact expiry, such as minutes from now, instead of `days_to_expire`. A scoped key can't outlive the key that creates it.
+- Use `expires_at` for an exact expiry, such as minutes from now, instead of `days_to_expire`. When you create a key with a policy, it can't outlive the issuing credential unless that credential holds `api_keys:issue_beyond_expiry` on the target. Kernel returns `400` for an expiry it can't honor; it never silently shortens the requested lifetime.
- Expired and deleted keys can't authenticate new API requests.
-- Deleting a key through the API or dashboard, or rotating it with `expire_in_days: 0`, also ends browser sessions associated with that key. Cleanup runs asynchronously and discards unsaved profile changes.
+- Deleting a key through the API or dashboard, or rotating it with `expire_in_days: 0`, also ends browser sessions associated with that key, including pool browsers it acquired and hasn't released. Cleanup runs asynchronously and discards unsaved profile changes.
- Grace-period expiry and natural expiry do **not** end existing browsers. Delete those browsers explicitly if you need to stop them.
+- Connection URLs (CDP, WebDriver, live view) stop working when their browser ends, not when the key stops authenticating.
- If browser cleanup can't be scheduled, deletion or immediate rotation fails without committing the key change.
- Rotating a scoped key keeps its policy.
@@ -175,7 +180,61 @@ print(api_key.key) # Save this value now. Kernel won't show it again.
Automatic cleanup only covers browsers associated with the key. Some browsers created before this behavior was introduced may not have that association. Delete those browsers directly. Cleanup doesn't undo profile changes you've already saved, delete browser pools, or stop app invocations or deployments.
-Scoped keys can't manage API keys, and they get `403` on endpoints that don't support scoped access yet.
+### Delegate a narrower key
+
+You can use a scoped key to create another scoped key:
+
+1. Grant the issuer `api_keys:create` on the new key's project or organization container.
+2. Supply a `policy` whose statements are covered by the issuer's policy, and keep the new key inside the issuer's organization/project boundary.
+3. Set the new key's expiry no later than the issuer's expiry, or grant the issuer `api_keys:issue_beyond_expiry` on that container and request a finite lifetime of at most 3650 days.
+
+For example, an issuer with `api_keys:create` and `browsers:use` on a project can issue a key with only `browsers:use` on one browser in that project. Use the same SDK creation call shown above with the narrower policy.
+
+Use `api_keys:read` to inspect keys, `api_keys:write` to rename them, `api_keys:delete` to revoke them, and `api_keys:rotate` to replace them. When a scoped key rotates another key, it must also cover the target key's policy, and the replacement's expiry follows the same rule as creation, with `api_keys:issue_beyond_expiry` checked on the existing key. These permissions are separate, so you can grant metadata access without granting key issuance or rotation.
+
+### Allow longer-lived child keys
+
+Use an unscoped credential to issue a trusted key with `api_keys:issue_beyond_expiry`. This permission doesn't grant creation, rotation, or resource access by itself.
+
+
+```typescript TypeScript
+const issuer = await kernel.apiKeys.create({
+ name: 'ci-key-issuer',
+ project_id: 'proj_staging_9f3k',
+ days_to_expire: 30,
+ policy: {
+ statements: [
+ { action: 'api_keys:create', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'api_keys:issue_beyond_expiry', resource: 'projects/proj_staging_9f3k/*' },
+ { action: 'browsers:use', resource: 'projects/proj_staging_9f3k/*' },
+ ],
+ },
+});
+```
+
+```python Python
+issuer = client.api_keys.create(
+ name="ci-key-issuer",
+ project_id="proj_staging_9f3k",
+ days_to_expire=30,
+ policy={
+ "statements": [
+ {"action": "api_keys:create", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "api_keys:issue_beyond_expiry", "resource": "projects/proj_staging_9f3k/*"},
+ {"action": "browsers:use", "resource": "projects/proj_staging_9f3k/*"},
+ ],
+ },
+)
+```
+
+
+Authenticate with `issuer.key` to create a child with `days_to_expire: 365` and only `browsers:use` on this project. Its expiry is one year, not silently shortened to the issuer's 30 days. Without the special permission, that request returns `400`.
+
+The child must have a finite expiry of at most 3650 days. Scoped callers cannot create or rotate keys whose policies contain `api_keys:issue_beyond_expiry`, so the child can't inherit this authority. Add `api_keys:rotate` separately to let the issuer rotate other keys.
+
+
+Grant this permission only to trusted issuers. Their child keys can remain valid after the issuer expires or is revoked.
+
## Limit a key to your IP ranges
@@ -241,6 +300,8 @@ client.api_keys.update(
```
+To change permissions with a scoped key, you need `api_keys:set_policy` on the target key. You must cover both its current and replacement policies; you can’t convert an unrestricted key this way. To change its name in the same request, you also need `api_keys:write`.
+
Updating `policy` **fully replaces** the key's permissions, so send the complete policy, not just the statements you're changing. The new policy takes effect within the authorization cache (~10 seconds) and applies only to new requests—already-open browser connections keep running.
Attaching a policy to a key that doesn't have one makes the key scoped: every action and resource the policy doesn't list is denied. There's no way to remove a policy from a key and go back to unrestricted—if you no longer need a scoped key, delete it.
@@ -251,15 +312,17 @@ A key used through a hosted MCP server is evaluated against the MCP server's egr
## Deployment API keys
-When you deploy an app, Kernel mints a **deployment-scoped API key** for that deployment and injects it into the deployment (and every invocation it runs) as the `KERNEL_API_KEY` environment variable. Because the SDKs read `KERNEL_API_KEY` from the environment by default, your app can call the Kernel API as itself without you managing a key.
+Kernel injects `KERNEL_API_KEY` into each invocation. The SDK reads it automatically. For new deployments with a runtime policy, Kernel stores the policy on the deployment and issues a fresh project-scoped key when each invocation starts. Each key expires 65 minutes after issuance, even if the run finishes earlier. The policy doesn't expire with the deploying key, so you don't need to redeploy when that key expires or is revoked.
-Key points about deployment keys:
+Deploying with a scoped key requires container-wide `deployments:create`, `deployments:delete`, and `invocations:write`. If you omit `runtime_policy`, the runtime gets only project-wide `invocations:write` for reporting results. This permission applies to all invocations in the project, not just that deployment’s runs. To grant more, send the policy as a JSON multipart field on `POST /deployments`. It must explicitly include the callback permission, stay within the deployer’s project and permissions, name existing resources, and exclude `api_keys:issue_beyond_expiry`. A scoped invoker needs `invocations:create` and every permission in the runtime policy.
-- **One key per deployment.** Each deploy (including a redeploy of the same app) mints a fresh deployment key. `KERNEL_API_KEY` is a [reserved environment variable](/apps/deploy#reserved-environment-variables) — a value you supply at deploy time is overridden by the injected key. To use your own long-lived key, pass it under a non-reserved name.
-- **Lifecycle tied to the deployment.** A deployment key stays valid while its deployment is active. When you redeploy, the new deployment supersedes the old one, and the old deployment's key is released once it is no longer needed — that is, once the superseded deployment is stopped **and** no invocation is still running on it.
-- **In-flight invocations are drained, not cut off.** If an invocation is still running on a deployment that gets superseded, its key is kept valid until that invocation completes; the key is released right after. An idle redeploy (nothing in flight) releases the old key immediately. In the rare case where an invocation's workflow terminates without releasing the key, a background sweep releases it after a grace period (~95 minutes). You do not need to manage any of this — it is automatic.
+Moving a deployment to another host preserves the policy. Stopping it prevents new runs; it doesn't revoke keys already issued. `KERNEL_API_KEY` is a [reserved environment variable](/apps/deploy#reserved-environment-variables). To supply a credential for your own API calls, pass it under another name.
-If you need a credential whose lifetime you control (for CI, a persistent backend, or a resource that should outlive any single deployment), create an org- or project-scoped key as described below and pass it explicitly to the client. This only affects the calls your app makes — the platform still injects the deployment key and uses it to run the invocation and report its result, so you're choosing the credential for your own calls, not replacing the deployment key.
+
+Until scoped deployments are enabled, creating a deployment with a scoped credential or sending `runtime_policy` with any credential returns `403`. Deploying with an unrestricted credential and no `runtime_policy` is unchanged. See the [app policy example](/info/api-key-policy-examples).
+
+
+**Existing deployments and unscoped defaults:** Existing shared keys aren't migrated. Deploying with an unrestricted credential and omitting `runtime_policy` still creates one shared runtime key; supplying the field opts into per-invocation keys. Scoped callers cannot invoke an unrestricted runtime. For an existing shared key with a policy, the key must be live, its permissions covered, and its expiry no later than the invoker's. Host moves preserve these bounds, and superseded deployments keep their shared key until in-flight runs drain.
## List and inspect API keys
@@ -408,6 +471,10 @@ Two optional parameters control the timing:
- `days_to_expire` sets the new key's lifetime in days (`1`-`3650`). Omit it to give the new key the same lifetime the rotated key originally had, or to never expire if the old key never did.
- `expire_in_days` sets how long the old key keeps working before it expires. Use `0` to revoke it immediately, or omit it for the default 7-day grace window. The old key stops authenticating automatically once the window passes—you don't need to delete it.
+If the key you rotate with has no policy, these lifetime rules apply to every target, including keys with policies, and you don't need `api_keys:issue_beyond_expiry`.
+
+If the key you rotate with has a policy, it needs `api_keys:rotate` on the target and must cover the target's policy. When the caller expires, the replacement must expire no later than the caller, or the caller must hold `api_keys:issue_beyond_expiry` on the target and request a finite lifetime of up to 3650 days. The same check applies when you omit `days_to_expire` and reuse the old lifetime. A disallowed expiry returns `400`, never a shortened replacement. A caller with a policy cannot rotate a key that itself carries `api_keys:issue_beyond_expiry`.
+
```typescript TypeScript
const rotated = await kernel.apiKeys.rotate('key_01jwv4tn5m8k3q2v7x9p0a1bc2', {
@@ -489,7 +556,8 @@ It's still a stored secret. Prefer federation wherever your workload has an iden
| --- | --- | --- |
| `400 Bad Request` | The name is missing, `days_to_expire` is outside `1`-`3650`, `expire_in_days` is outside `0`-`3650`, or `project_id` is empty. | Send a name, choose a valid expiry, or omit `project_id` for an org-scoped key. |
| `400 Bad Request` (rotate) | `days_to_expire` is shorter than `expire_in_days`, so the new key would expire before the old key's grace window ends. | Raise `days_to_expire` or lower `expire_in_days`. |
-| `400 Bad Request` (scoped key) | The policy has an unknown action or a resource outside the key's organization or project, the expiry is invalid or later than your own key's, or a condition is malformed: `source_ip` values must be CIDR networks (not bare addresses, host-bit entries, or IPv4-in-IPv6 notation), name a supported `key` and `operator`, and `policy: null` isn't accepted on update. | Check the policy against [API key permissions](/info/api-key-permissions) and send one expiry field. |
+| `400 Bad Request` (policy) | The action, resource, or condition is invalid, or the update sets `policy: null`. | Check the [permission reference](/info/api-key-permissions) and send the complete replacement policy. |
+| `400 Bad Request` (issuer expiry) | The requested lifetime exceeds the issuer’s when creating a key with a policy or rotating with a scoped caller. | Request a shorter lifetime or check the [longer-lived key exception](#allow-longer-lived-child-keys). |
| `401 Unauthorized` | Kernel couldn't authenticate the request. | Set a valid `KERNEL_API_KEY`. |
| `403 Forbidden` (`insufficient_scope`) | A scoped key is missing a permission. | The message names the missing action and resource. Add it to the policy. |
| `404 Not Found` | The project, API key, or a resource named in the policy doesn't exist, or the caller can't access it. | Check the ID. If you're using a project-scoped key, you can only rotate keys in that same project. |
diff --git a/info/projects.mdx b/info/projects.mdx
index cf0ecc37..0af5fecf 100644
--- a/info/projects.mdx
+++ b/info/projects.mdx
@@ -104,13 +104,13 @@ func main() {
API keys can be **org-wide** or **project-scoped**.
-- **Existing API keys are org-wide.** They see every resource in your organization across all projects. Include an `X-Kernel-Project-Id` header to restrict a single request to one project.
+- **Organization-scoped API keys** can reach resources across projects. If the key has a [policy](/info/api-key-permissions), its grants determine which actions and resources it can access. Include an `X-Kernel-Project-Id` header to select a project for a request.
- **Project-scoped API keys** can only access resources inside the project they were issued for. Create one from the **API Keys** page in the dashboard, the [CLI](/reference/cli/api-keys), an SDK, or the [API keys guide](/info/api-keys), and pass the target `project_id` when generating the key. Requests made with a scoped key are automatically limited to that project — no header required. If you do send an `X-Kernel-Project-Id` header and it conflicts with the key's project, the request is rejected with `403 Forbidden`.
-- **Most project administration requires an org-wide credential.** A project-scoped key may rename its own project, but cannot create, archive, or delete projects, or change project limits.
+- **Most project administration requires an org-wide credential.** A project-scoped key may rename its own project, but cannot create, archive, restore, or delete projects, or change project limits. Policy-scoped keys additionally need `projects:read` to view the target project, `projects:write` to rename it or change its limits, and `projects:delete` to archive, restore, or delete it. An update that changes status along with other fields needs both `projects:write` and `projects:delete`. Creating a project requires `projects:create` on `organizations/{org_id}/*`; organization limits use `organizations:read` and `organizations:write`.
### OAuth
-OAuth tokens (used by the Kernel CLI and MCP server) are **always org-wide**. You cannot bind an OAuth session to a single project. To scope OAuth-authenticated requests, send the `X-Kernel-Project-Id` header with each request — or use the CLI's `--project` flag (see below).
+At native OAuth consent, you choose which actions the client can take and whether it can use one project or all projects. With one project selected, requests use that project automatically. With all projects selected, use `X-Kernel-Project-Id` or the CLI’s `--project` flag to target a project other than the default. Selecting a project for a request never grants access to it.
### Workload identity federation
@@ -138,7 +138,7 @@ kernel projects create staging
kernel projects limits set staging --max-concurrent-sessions 5
```
-Under the hood, `--project` (or the env var) adds the `X-Kernel-Project-Id` header to every authenticated request. It's the recommended way to target a specific project when you're logged in with OAuth (`kernel login`), since OAuth itself is always org-wide.
+Under the hood, `--project` (or the env var) adds the `X-Kernel-Project-Id` header to every authenticated request. The project must be covered by your credential.
## Managing projects
diff --git a/reference/cli/api-keys.mdx b/reference/cli/api-keys.mdx
index 5d59254e..4a19e9cb 100644
--- a/reference/cli/api-keys.mdx
+++ b/reference/cli/api-keys.mdx
@@ -2,7 +2,7 @@
title: "API Keys"
---
-Manage [API keys](/info/api-keys) from the CLI.
+Manage [API keys](/info/api-keys) from the CLI. Native OAuth sessions can’t manage keys. Set `KERNEL_API_KEY` to a personal API key with the permissions you need, or use the dashboard.
For CI jobs, cloud services, and Kubernetes pods, use [workload identity federation](/info/workload-identity/overview) instead of an API key. There's no secret to store, and the credential expires in minutes. Service accounts, issuers, and federation rules are managed from the dashboard.
diff --git a/reference/cli/projects.mdx b/reference/cli/projects.mdx
index 427f5212..f4f52f25 100644
--- a/reference/cli/projects.mdx
+++ b/reference/cli/projects.mdx
@@ -17,7 +17,7 @@ export KERNEL_PROJECT=proj_abc123
kernel apps list
```
-Under the hood, the flag adds the `X-Kernel-Project-Id` header to every authenticated API request. OAuth-based logins (`kernel login`) remain org-wide by default, so this is the recommended way to target a single project when logged in with OAuth.
+Under the hood, the flag adds the `X-Kernel-Project-Id` header to every authenticated API request. With a [single-project OAuth grant](/info/projects#oauth), requests use that project automatically. With an all-projects grant, use the flag to target a project other than the default.
Project-scoped API keys are already bound to a project server-side, so you don't need `--project` when using them — but if you do pass it, it must match the key's project or the request is rejected.