Skip to content

Commit 11ed269

Browse files
authored
Document browser lifecycle on API key revocation (#748)
Co-authored-by: meliaj <17581886+meliaj@users.noreply.github.com>
1 parent 86eccb5 commit 11ed269

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎info/api-keys.mdx‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,16 @@ print(api_key.key) # Save this value now. Kernel won't show it again.
159159
### Expiry and revocation
160160

161161
- 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.
162-
- An expired key is rejected immediately, and a deleted key within about 10 seconds. Neither revokes connection URLs (CDP, WebDriver, live view) the key already obtained. They keep working, including for new connections, until the browser is deleted, so delete the key's browsers to cut off access.
162+
- Expired and deleted keys can't authenticate new API requests.
163+
- 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.
164+
- Grace-period expiry and natural expiry do **not** end existing browsers. Delete those browsers explicitly if you need to stop them.
165+
- If browser cleanup can't be scheduled, deletion or immediate rotation fails without committing the key change.
163166
- Rotating a scoped key keeps its policy.
164167

168+
<Note>
169+
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.
170+
</Note>
171+
165172
Scoped keys can't manage API keys, and they get `403` on endpoints that don't support scoped access yet.
166173

167174
## Deployment API keys
@@ -243,7 +250,7 @@ func main() {
243250
Rename a key when the owner or purpose changes. Delete a key when the workload no longer needs access.
244251

245252
<Warning>
246-
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.
253+
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.
247254
</Warning>
248255

249256
<CodeGroup>
@@ -376,7 +383,7 @@ After you rotate a key:
376383
2. Deploy or restart the workload that uses `KERNEL_API_KEY`.
377384
3. Verify the workload can call Kernel before the grace window ends.
378385

379-
To cut over immediately instead of using a grace window, pass `expire_in_days: 0` so the old key stops working as soon as the new one is issued.
386+
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.
380387

381388
## Troubleshooting
382389

‎reference/cli/api-keys.mdx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ kernel api-keys rotate key_01jwv4tn5m8k3q2v7x9p0a1bc2 \
8888

8989
<Warning>
9090
Save the new plaintext key when you rotate it. Kernel won't return it again.
91+
With `--expire-in-days 0`, the old key's associated browsers are ended asynchronously
92+
and their unsaved profile changes are discarded. A grace-period expiry doesn't end
93+
existing browsers.
9194
</Warning>
9295

9396
## `kernel api-keys delete <id>`
9497

95-
Delete an API key.
98+
Delete an API key. Its associated browsers are ended asynchronously, and unsaved profile changes in those browsers are discarded.
99+
100+
<Note>
101+
Automatic cleanup only covers browsers associated with the key. Some older browsers
102+
may be unaffected; delete those browsers directly. See [API key expiry and revocation](/info/api-keys#expiry-and-revocation).
103+
</Note>
96104

97105
```bash
98106
kernel api-keys delete key_01jwv4tn5m8k3q2v7x9p0a1bc2 --yes

0 commit comments

Comments
 (0)