Skip to main content
An API key is the credential your server, script, or CI job uses to call Kernel without an interactive login. Treat it like a password: keep it out of client-side code, store it in a secret manager, and rotate it when access changes. Kernel only returns the plaintext key once, when you create it. Save the key value immediately. After that, Kernel only shows the masked value.
For anything that isn’t a person at a keyboard, use workload identity federation instead of an API key. An API key is a stored secret that works until someone revokes it. With federation, a CI job, cloud service, or Kubernetes pod exchanges a token from its own identity provider for a short-lived KERNEL access token, and there’s no secret to store. API keys remain the right tool for local development and for environments with no identity provider. See API authentication to choose.

Before you start

You need one existing Kernel credential to create another API key:
  • Set KERNEL_API_KEY before running the SDK examples.
API keys can be org or project scoped:
  • Omit project_id to create an org-scoped key that can access resources across your organization.
  • 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.

SDKs

Scope a key to specific resources

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.

How policies work

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 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.
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. 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 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 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:

Expiry and revocation

  • Use expires_at instead of days_to_expire for an exact expiry. When creating a key with a policy, follow the issuer expiry rule.
  • 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, 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.
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.

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.
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

Add a condition to a statement to restrict where requests can come from. The source_ip condition allows the statement only when the request’s client address is inside one of its CIDR networks:
Use this when a key is pinned to a fixed egress: if the key leaks into a log, a repository, or a third-party tool, requests from anywhere else get 403 before they touch your data. How conditions evaluate:
  • Each entry in values must be a CIDR network (203.0.113.0/24). A bare address without a mask, an entry with host bits set, and an IPv4 network written in IPv6 notation are rejected with 400 at creation—so a mistyped mask can’t silently grant a whole block.
  • Requests from outside every listed network get 403 with insufficient_scope, and the denial is recorded in your audit logs with the client IP, so you can widen the list from evidence.
  • A condition only narrows its own statement. If you want a key that only works from your network, add the same condition to every statement in its policy.
  • Kernel evaluates the address the trusted edge proxy reports, not a client-supplied header value, so a request can’t spoof its way in.

Add an IP allowlist to an existing key

You don’t need to rotate a key to add, change, or remove IP rules. Update the key with a policy, and the credential, name, project, and expiry stay the same—your consumers keep the same secret:
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.
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.

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 invocations:write on projects/{project_id}/* so it can report results. It also gets browsers:create, browsers:use, and browsers:delete on projects/{project_id}/* for each one your deploying key holds on the whole project, so an app that opens browsers works on its first run. A grant on a single browser doesn’t count. These grants are project-wide: the app can update other apps’ invocations and use or delete any browser in the project, not only ones it created. Put apps that don’t trust each other in separate projects. To keep an app callback-only, deploy it with an explicit runtime_policy that has only invocations:write on projects/{project_id}/*. 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:
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. For an app deployed with the default policy, that includes the browser permissions it received. If the invoking key is missing any, the 403 names them as action on resource. Permissions on individual resources appear as specific resources. 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. To supply a credential for your own API calls, pass it under another name. See the app policy example for separate deployer, runtime, and invoker permissions.

Existing deployments

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.
A deployment keeps the runtime policy it was created with. To change an app’s permissions, redeploy it. 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

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: In the dashboard, filter the list by Created by, Linked account, and Project, and switch between Active, Expired, and Deleted.

Rename, update permissions, or delete an API key

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. 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.

Rotate a key

rotate issues a replacement key in a single call and keeps the old key working for a short grace period, so your workload can switch over without downtime. The new key copies the rotated key’s name, project scope, and policy, and—like create—Kernel returns the plaintext key only once. 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 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.
After you rotate a key:
  1. Store the new plaintext key in your secret manager.
  2. Deploy or restart the workload that uses KERNEL_API_KEY.
  3. Verify the workload can call Kernel before the grace window ends.
To cut over immediately instead of using a grace window, pass expire_in_days: 0. The old key stops working, its associated browsers are ended asynchronously, and unsaved profile changes in those browsers are discarded. With a grace period, existing browsers keep running after the old key expires.

Service account API keys

A key you create for yourself acts as you. For a workload that can’t use workload identity federation, an organization admin can link a key to a service account instead, so the key belongs to the organization and keeps working when its creator leaves. A service account API key always has one project and an explicit policy, and it can’t hold API key permissions. Create one from the dashboard: click Create API Key, choose Continue with an API key, and pick the service account under Linked account. See Service account API keys. It’s still a stored secret. Prefer federation wherever your workload has an identity provider, and move existing workloads when you can.

Troubleshooting