Skip to content

Commit ff3251e

Browse files
feat: Discard browser sessions on immediate API key revocation (#5272)
Stainless-Generated-From: b21adf53a0794511848e818b6bb5d13aeef06400
1 parent a9204e8 commit ff3251e

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

‎src/kernel/resources/api_keys.py‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ def delete(
303303
timeout: float | httpx.Timeout | None | NotGiven = not_given,
304304
idempotency_key: str | None = None,
305305
) -> None:
306-
"""Delete an API key.
307-
308-
A key cannot delete itself; use a different key to delete
309-
this one.
306+
"""
307+
Delete an API key and asynchronously end browser sessions attributed to it,
308+
discarding unsaved profile changes. A key cannot delete itself; use a different
309+
key to delete this one. If cleanup cannot be registered, the key is not deleted.
310310
311311
Args:
312312
extra_headers: Send extra headers
@@ -352,7 +352,11 @@ def rotate(
352352
353353
Issues a new key that copies the name and project of the
354354
rotated key, and schedules the rotated key to expire after a grace period so
355-
in-flight callers can swap over. The new plaintext key is returned once.
355+
in-flight callers can swap over. The new plaintext key is returned once. With
356+
expire_in_days set to 0, browser sessions attributed to the old key are ended
357+
asynchronously and unsaved profile changes are discarded. Grace-period and
358+
natural expiry do not end existing browsers. If cleanup cannot be registered, an
359+
immediate rotation is not committed.
356360
357361
Args:
358362
days_to_expire: Lifetime in days for the new key, up to 3650. Omit to reuse the rotated key's
@@ -663,10 +667,10 @@ async def delete(
663667
timeout: float | httpx.Timeout | None | NotGiven = not_given,
664668
idempotency_key: str | None = None,
665669
) -> None:
666-
"""Delete an API key.
667-
668-
A key cannot delete itself; use a different key to delete
669-
this one.
670+
"""
671+
Delete an API key and asynchronously end browser sessions attributed to it,
672+
discarding unsaved profile changes. A key cannot delete itself; use a different
673+
key to delete this one. If cleanup cannot be registered, the key is not deleted.
670674
671675
Args:
672676
extra_headers: Send extra headers
@@ -712,7 +716,11 @@ async def rotate(
712716
713717
Issues a new key that copies the name and project of the
714718
rotated key, and schedules the rotated key to expire after a grace period so
715-
in-flight callers can swap over. The new plaintext key is returned once.
719+
in-flight callers can swap over. The new plaintext key is returned once. With
720+
expire_in_days set to 0, browser sessions attributed to the old key are ended
721+
asynchronously and unsaved profile changes are discarded. Grace-period and
722+
natural expiry do not end existing browsers. If cleanup cannot be registered, an
723+
immediate rotation is not committed.
716724
717725
Args:
718726
days_to_expire: Lifetime in days for the new key, up to 3650. Omit to reuse the rotated key's

0 commit comments

Comments
 (0)