diff --git a/apps/deploy.mdx b/apps/deploy.mdx
index e574db30..ad29f697 100644
--- a/apps/deploy.mdx
+++ b/apps/deploy.mdx
@@ -45,6 +45,10 @@ 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
+
+When you run `kernel deploy` with a scoped API key, the app gets only project-wide `invocations:write` to report results. Deployment succeeds, but browser calls from the app return `403`. The CLI has no runtime policy flag. To grant browser access, [deploy through the API with an explicit app runtime policy](/info/api-keys#app-runtime-policy).
+
## Environment variables
You can set environment variables for your app using the `--env` flag. For example:
@@ -71,7 +75,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 SDK uses this key automatically. For apps with a runtime policy, the key grants only the [app runtime permissions](/info/api-keys#app-runtime-policy).
- `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..b768175b 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. Use organization-scoped authentication to create the destination in the browser’s project. For a non-default project, set `X-Kernel-Project-Id` (CLI: `--project`). A key bound to that project can select the destination but can’t create it.
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..a4dec8b4 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,46 @@ 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}` | Use for organization-owned resources. For project resources this resolves against the request's project; prefer `projects/{project_id}/{kind}/{id}` to name the project explicitly. |
-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. |
+
+Use IDs, not display names, in policy resources, even when an endpoint accepts either. 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.
+
+
+## Action wildcards
+
+When you create an API key or replace its policy, you can write `*` in place of a whole part of an action:
+
+| Action | Expands to |
+| --- | --- |
+| `browsers:*` | Every `browsers` action. |
+| `*:delete` | Every `delete` action that applies to the statement's resource. |
+| `*:*` | Every action that applies to the statement's resource. |
+
+Kernel expands the wildcard when it saves the policy, keeping the statement's resource and condition, and stores only the matching actions. The key doesn't gain actions Kernel adds later, and a scoped issuer must hold every expanded action. On a project container, a wildcard skips organization actions; on one object, it keeps only that object's actions.
+
+- A wildcard never includes `api_keys:issue_beyond_expiry`. List it explicitly.
+- Partial wildcards such as `brow*:use`, a bare `*`, unknown names, and wildcards matching nothing on their resource return `400`.
+- Federation rules and app runtime policies accept only exact actions.
## Conditions
@@ -52,11 +85,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. |
+| `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 +109,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 +119,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 +129,185 @@ How conditions evaluate:
| Action | Allows |
| --- | --- |
-| `proxies:create` | Create proxies. Grant it on a project or organization. |
-| `proxies:read` | List proxies and view their configuration, without credentials. |
+| `proxies:create` | Create and validate proxies. |
+| `proxies:read` | List proxies and view their configuration, without credentials. Listing or inspecting reserved proxy IPs needs container-wide `proxies:read`. |
| `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 or fetch a ZIP from the Chrome Web Store. Fetching a ZIP doesn’t save it. |
+| `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. |
+| `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. |
+| `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. |
+| `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 [app runtime policy](/info/api-keys#app-runtime-policy) for the permissions your app uses when it runs.
+
+
+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` | Issue longer-lived keys under the [issuer expiry rule](/info/api-keys#delegate-a-narrower-key). Scoped callers can't delegate this permission. |
+| `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. |
+
+See [Delegate a narrower key](/info/api-keys#delegate-a-narrower-key) for policy and expiry requirements.
+
+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`. |
+| Save a browser to a profile | `browsers:use` and the attachment permissions above. Grant `profiles:write` on an existing destination profile, or container-wide `profiles:create` to save under a new name. |
+| Upload extensions directly to a running browser | `browsers:use` and its attachment permissions. This uploads files to the browser rather than creating a saved extension. |
+| 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`, plus any additional permissions in the [app runtime policy](/info/api-keys#app-runtime-policy). |
+| Invoke an app action | Container-wide `invocations:create`. Your policy must cover the [app runtime policy](/info/api-keys#app-runtime-policy). For apps with a shared key, see [Existing deployments](/info/api-keys#existing-deployments). |
+| 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 policy. The [issuer expiry rule](/info/api-keys#delegate-a-narrower-key) also applies. |
+| 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..d3c59006
--- /dev/null
+++ b/info/api-key-policy-examples.mdx
@@ -0,0 +1,269 @@
+---
+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: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: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"},
+ ],
+}
+```
+
+
+When creating the browser, enable at least one telemetry source (for example, set `telemetry.browser.console.enabled` to `true`) and set `telemetry.export.otlp.destination` to `{"id": "tdst_8k2q4m6r"}`. Export without capture returns `400`. See the [complete browser request](/browsers/telemetry/export#export-a-sessions-telemetry).
+
+
+
+Acquire and release browsers from one pool that uses a saved profile.
+
+
+```typescript TypeScript
+const policy = {
+ statements: [
+ { 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: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 this key to deploy and invoke the app. If you omit `runtime_policy`, the [app runtime policy](/info/api-keys#app-runtime-policy) grants only project-wide `invocations:write`, not the rest of the deploying key’s permissions. The next example adds browser access.
+
+
+
+Use an explicit runtime policy to give the app 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` can't invoke this app: it doesn't cover the runtime's browser and callback permissions. Add `invocations:read` to read results and `deployments:read` as well to read the event stream.
+
+
+
+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`. For configuration registry requests, send `X-Kernel-Project-Id: proj_staging_9f3k` to select the project named in the policy.
+
+
+```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..598b8dad 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. To grant several actions at once, see [action wildcards](/info/api-key-permissions#action-wildcards).
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` instead of `days_to_expire` for an exact expiry. When creating a key with a policy, follow the [issuer expiry rule](#delegate-a-narrower-key).
- 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. If the issuer expires, set the child's expiry no later than the issuer's. To issue a longer-lived child, the issuer needs `api_keys:issue_beyond_expiry` on the new key's container and must request a finite lifetime of at most 3650 days. Kernel returns `400` rather than shortening a disallowed lifetime. When rotating with a scoped key, the same expiry rule applies, but Kernel checks the permission on the existing key.
+
+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. Grant these actions separately from key issuance.
+
+### 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`.
+
+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.
@@ -249,21 +310,101 @@ Attaching a policy to a key that doesn't have one makes the key scoped: every ac
A key used through a hosted MCP server is evaluated against the MCP server's egress address, so an IP-restricted key is denied everywhere until MCP support ships. If you route keys through a hosted MCP server, leave `source_ip` conditions off those keys for now.
-## Deployment API keys
+
+
+## App runtime policy
+
+An app’s runtime policy controls which Kernel API calls that version can make. Set it when you deploy. Your app keeps those permissions if the key you used to deploy expires or is revoked; you don’t need to redeploy or store a key for the app.
+
+**Default:** When you deploy with a scoped key and omit `runtime_policy`, the app gets only `invocations:write` on `projects/{project_id}/*` so it can report results. That grant lets the app update other apps’ invocations in the same project. Put apps that don’t trust each other in separate projects.
+
+**To grant more access**, send `runtime_policy` as a JSON form field on `POST /deployments`. The SDKs don't accept `runtime_policy` yet, so these examples call the API directly. Set `KERNEL_PROJECT_ID` to your project ID and `KERNEL_API_KEY` to your deploying key, and put `main.py` and its dependency manifest at the root of `app.zip`:
+
+
+```typescript TypeScript
+import { readFile } from 'node:fs/promises';
+
+const projectId = process.env.KERNEL_PROJECT_ID!;
+const resource = `projects/${projectId}/*`;
+const runtimePolicy = {
+ statements: [
+ { action: 'invocations:write', resource },
+ { action: 'browsers:create', resource },
+ { action: 'browsers:use', resource },
+ ],
+};
+
+const form = new FormData();
+form.append('file', new Blob([await readFile('app.zip')]), 'app.zip');
+form.append('entrypoint_rel_path', 'main.py');
+form.append('runtime_policy', JSON.stringify(runtimePolicy));
+
+const response = await fetch('https://api.onkernel.com/deployments', {
+ method: 'POST',
+ headers: {
+ Authorization: `Bearer ${process.env.KERNEL_API_KEY}`,
+ 'X-Kernel-Project-Id': projectId,
+ },
+ body: form,
+});
+if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
+console.log(await response.json());
+```
+
+```python Python
+import json
+import os
+
+import httpx
+
+project_id = os.environ["KERNEL_PROJECT_ID"]
+resource = f"projects/{project_id}/*"
+runtime_policy = {
+ "statements": [
+ {"action": "invocations:write", "resource": resource},
+ {"action": "browsers:create", "resource": resource},
+ {"action": "browsers:use", "resource": resource},
+ ]
+}
+
+with open("app.zip", "rb") as app:
+ response = httpx.post(
+ "https://api.onkernel.com/deployments",
+ headers={
+ "Authorization": f"Bearer {os.environ['KERNEL_API_KEY']}",
+ "X-Kernel-Project-Id": project_id,
+ },
+ files={"file": ("app.zip", app, "application/zip")},
+ data={
+ "entrypoint_rel_path": "main.py",
+ "runtime_policy": json.dumps(runtime_policy),
+ },
+ timeout=120,
+ )
+response.raise_for_status()
+print(response.json())
+```
+
+
+This app can report results and create browsers without attachments. Include the unconditional project-wide `invocations:write` grant and any additional permissions your app needs. The policy must fit within the app’s project and your own permissions, reference existing resources, and exclude `api_keys:issue_beyond_expiry`.
+
+To deploy with a scoped key, grant it container-wide `deployments:create`, `deployments:delete`, and `invocations:write`, plus any additional permissions in the app’s policy. To run the app with a scoped key, grant it `invocations:create` on the container and every permission in the app’s policy.
+
+Kernel supplies a short-lived `KERNEL_API_KEY` with the app’s permissions for each run. 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.
-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.
+See the [app policy example](/info/api-key-policy-examples) for separate deployer, runtime, and invoker permissions.
-Key points about deployment keys:
+### Existing deployments
-- **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.
+
+Scoped callers can't invoke an app that runs with an unrestricted shared key, even with `invocations:create`. To let them run it, redeploy with an explicit runtime policy that their permissions cover.
+
-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.
+Deploying with an unrestricted credential and omitting `runtime_policy` creates a shared key; it doesn't migrate the app to per-invocation keys. If the shared key has a policy, it must be live, its permissions must be covered by the caller, and it must expire no later than the caller. Host moves preserve these rules; superseded deployments keep their shared key until in-flight runs drain.
## List and inspect API keys
-List keys to audit what exists. List and retrieve responses include `masked_key`, `project_id`, `project_name`, `created_by`, expiry metadata, and `policy` for scoped keys, but they don't include the plaintext key.
+Use `GET /org/api_keys` to list keys and `GET /org/api_keys/{id}` to inspect one. List and retrieve responses include `masked_key`, `project_id`, `project_name`, `created_by`, expiry metadata, and `policy` for scoped keys, but they don't include the plaintext key. If `policy` is absent, the key is unrestricted within its project or organization.
The list returns `active` keys by default: keys that are neither deleted nor expired. Pass `status` to see the others, and combine these filters to narrow the list:
@@ -325,7 +466,7 @@ func main() {
panic(err)
}
- apiKey, err := client.APIKeys.Get(ctx, "key_01jwv4tn5m8k3q2v7x9p0a1bc2")
+ apiKey, err := client.APIKeys.Get(ctx, "key_01jwv4tn5m8k3q2v7x9p0a1bc2", kernel.APIKeyGetParams{})
if err != nil {
panic(err)
}
@@ -340,7 +481,7 @@ func main() {
Rename a key when the owner or purpose changes. Update its `policy` to add, change, or remove IP rules and permissions without rotating the credential. Delete a key when the workload no longer needs access.
-An API key cannot delete itself. Authenticate with a different key when deleting a key, so the request cannot revoke the credential that is authorizing it. Deleting a key also ends its associated browsers asynchronously and discards their unsaved profile changes.
+An API key cannot delete itself. Authenticate with a different key when deleting a key, so the request cannot revoke the credential that is authorizing it. A deleted key stops authenticating new requests within the authorization cache (~10 seconds). Deleting a key also ends its associated browsers asynchronously and discards their unsaved profile changes.
@@ -384,7 +525,7 @@ func main() {
ctx,
"key_01jwv4tn5m8k3q2v7x9p0a1bc2",
kernel.APIKeyUpdateParams{
- Name: "staging-ci-rotated",
+ Name: kernel.String("staging-ci-rotated"),
},
)
if err != nil {
@@ -408,6 +549,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. The [issuer expiry rule](#delegate-a-narrower-key) applies even when you omit `days_to_expire` and reuse the old lifetime. A scoped caller can't rotate a key that itself carries `api_keys:issue_beyond_expiry`.
+
```typescript TypeScript
const rotated = await kernel.apiKeys.rotate('key_01jwv4tn5m8k3q2v7x9p0a1bc2', {
@@ -489,7 +634,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`. | For `source_ip`, use CIDR notation without host bits or IPv4-in-IPv6 addresses. Check the [permission reference](/info/api-key-permissions) and send the complete replacement policy. |
+| `400 Bad Request` (issuer expiry) | The requested lifetime exceeds what the issuer can grant. | Check the [issuer expiry rule](#delegate-a-narrower-key). |
| `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/authentication.mdx b/info/authentication.mdx
index 01f06ca1..ad345cf4 100644
--- a/info/authentication.mdx
+++ b/info/authentication.mdx
@@ -34,7 +34,7 @@ By default, a static API key works from anywhere, for anyone who holds it, until
| Any other platform that issues OIDC tokens | [Federation with a custom OIDC issuer](/info/workload-identity/custom-oidc) |
| A server or tool with no identity provider | A [service account API key](/info/workload-identity/service-accounts#service-account-api-keys), limited to one project and an explicit policy |
| Your laptop, while you develop | `kernel login` for the [CLI](/reference/cli/auth), or a personal [API key](/info/api-keys) with a short expiry for the SDKs |
-| A KERNEL app deployment | The [deployment key](/info/api-keys#deployment-api-keys) KERNEL injects for you |
+| A KERNEL app deployment | Use the injected credential. Its permissions come from [the app's runtime policy](/info/api-keys#app-runtime-policy) when one is set. |
| An MCP client such as Claude or Cursor | [OAuth](/reference/mcp-server/authentication) |
## When an API key is still the right tool
diff --git a/info/projects.mdx b/info/projects.mdx
index cf0ecc37..4988040a 100644
--- a/info/projects.mdx
+++ b/info/projects.mdx
@@ -25,12 +25,12 @@ A project must also be empty before it can be deleted. If active resources remai
## Scoping requests to a project
-Pass the `X-Kernel-Project-Id` header with a project ID on any API request to scope it to a specific project. Project names are not accepted in this header. Without the header (and without a project-scoped API key), requests act on your organization's **default project**: reads return the default project's resources, and writes create resources in it.
+Use `X-Kernel-Project` to select a project by exact name or ID. `X-Kernel-Project-Id` accepts only an ID. Send one header, not both: sending both returns `400 conflicting_project_headers`. Without either header or a project-scoped credential, reads and writes use your organization's **default project**.
```bash
curl https://api.onkernel.com/browsers \
-H "Authorization: Bearer $KERNEL_API_KEY" \
- -H "X-Kernel-Project-Id: proj_abc123"
+ -H "X-Kernel-Project: proj_abc123"
```
### Resolution rules
@@ -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. See the [project permissions](/info/api-key-permissions#organizations-and-projects).
### 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
@@ -120,9 +120,9 @@ A [federation rule](/info/workload-identity/overview#federation-rules) names exa
The Kernel [CLI](/reference/cli/projects) has first-class project support:
-- A global `--project ` flag scopes any command to a single project ID.
+- A global `--project ` flag scopes a command to a project by ID or exact name.
- The `KERNEL_PROJECT` environment variable does the same, so you can set it once in your shell or CI.
-- A `kernel projects` command group lets you list, create, get, and delete projects, and manage per-project limit overrides.
+- A `kernel projects` command group lets you list, create, get, update, and delete projects, and manage per-project limit overrides.
```bash
# Scope a single command
@@ -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` 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..e0ea39a8 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.
@@ -23,7 +23,10 @@ kernel api-keys create \
| Flag | Description |
|------|-------------|
| `--name ` | API key name. Required. |
-| `--days-to-expire ` | Number of days until expiry, from `1` to `3650`. Omit for no expiry. |
+| `--days-to-expire ` | Number of days until expiry, from `1` to `3650`. Use this or `--expires-at`, not both. |
+| `--expires-at ` | Exact future expiry in RFC 3339 format. See [issuer expiry limits](/info/api-keys#delegate-a-narrower-key). |
+| `--policy ` | Grant only the actions and resources in this [policy](/info/api-key-policy-examples). Without a policy, the key is unrestricted within its project or organization. |
+| `--service-account-id ` | Issue a key for this service account instead of yourself. Requires organization administrator access, `--project-id`, and a non-empty `--policy`. |
| `--project-id ` | Create a project-scoped API key for this project. Omit for org-wide. |
| `--output json`, `-o json` | Output the raw JSON object, including the plaintext `key` on create. |
@@ -33,7 +36,7 @@ kernel api-keys create \
## `kernel api-keys list`
-List API keys in the authenticated organization. API keys are masked. The list shows active keys: keys that are neither deleted nor expired.
+List API keys in the authenticated organization. API keys are masked. By default, the list shows active keys: keys that are neither deleted nor expired.
```bash
kernel api-keys list --limit 20
@@ -43,6 +46,11 @@ kernel api-keys list --limit 20
|------|-------------|
| `--limit ` | Maximum number of results to return. |
| `--offset ` | Number of results to skip. |
+| `--status ` | `active`, `expired`, `deleted`, or `all`. Use `--status all` instead of the deprecated list flag `--include-deleted`. |
+| `--name `, `--query ` | `--name` matches an exact name. `--query` searches names, creators, and projects; IDs and masked keys must match exactly. |
+| `--project-id `, `--created-by ` | Filter by project (or `org` for organization-wide keys) or creator. |
+| `--principal-type `, `--service-account-id ` | Filter by principal type (`user` or `service_account`) or service account. |
+| `--sort-by `, `--sort-direction ` | Sort by `created_at`, `name`, `expires_at`, or `last_used_at`, in `asc` or `desc` order. |
| `--output json`, `-o json` | Output the raw JSON array. |
## `kernel api-keys get `
@@ -60,7 +68,7 @@ kernel api-keys get key_01jwv4tn5m8k3q2v7x9p0a1bc2
## `kernel api-keys update `
-Rename an API key.
+Rename an API key, replace its policy, or both. Supply at least one of `--name` and `--policy`.
```bash
kernel api-keys update key_01jwv4tn5m8k3q2v7x9p0a1bc2 --name staging-ci-rotated
@@ -68,7 +76,8 @@ kernel api-keys update key_01jwv4tn5m8k3q2v7x9p0a1bc2 --name staging-ci-rotated
| Flag | Description |
|------|-------------|
-| `--name ` | New API key name. Required. |
+| `--name ` | New API key name. |
+| `--policy ` | Complete replacement policy. Omitted statements are not retained. |
| `--output json`, `-o json` | Output the raw JSON object. |
## `kernel api-keys rotate `
diff --git a/reference/cli/projects.mdx b/reference/cli/projects.mdx
index 427f5212..be158dce 100644
--- a/reference/cli/projects.mdx
+++ b/reference/cli/projects.mdx
@@ -6,7 +6,7 @@ Manage [Projects](/info/projects) from the CLI and scope other commands to a spe
## Scoping commands to a project
-Use the global `--project` flag (or the `KERNEL_PROJECT` environment variable) to scope any `kernel` command to a project ID. Project names are accepted by project-management commands whose arguments say ``, but not by this global request-scoping flag.
+Use the global `--project` flag (or the `KERNEL_PROJECT` environment variable) to select a project by ID or exact name.
```bash
# Scope by ID
@@ -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` 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.
@@ -27,7 +27,7 @@ Under the hood, the flag adds the `X-Kernel-Project-Id` header to every authenti
### `kernel projects list`
-List all projects in the authenticated organization.
+List visible projects. Filter by exact name with `--name` or search with `--query`; use `--limit` and `--offset` to paginate.
### `kernel projects create `