banRevoke Api Key

Invalidate an API key when it's compromised or no longer needed.

circle-info

When to use: When a key is compromised, a service is decommissioned, or for regular key rotation.

chevron-rightPrerequisiteshashtag

5-Line Core

success = await api_key_provider.revoke_api_key(
    key_id=api_key.id,
    organization_id="default",
)
# Key is now invalid

When to Revoke

Scenario
Action

Key compromised

Revoke immediately

Service decommissioned

Revoke before removal

Employee leaves

Revoke personal keys

Regular rotation

Revoke after new key works

Step-by-Step

1

Get Key ID

2

Revoke the Key

3

Verify Revocation

4

Expected Output

circle-check

Complete Example

Create revoke_api_key.py:

Run it:

Expected output:

Key Rotation Pattern

Common Pitfalls

Pitfall
Solution

Revoking before new key deployed

Create and deploy new key first

Not notifying stakeholders

Coordinate with key users

Losing key ID

Track key IDs in secure storage


circle-info

Found an issue on this page? Report it on our feedback formarrow-up-right.

Last updated

Was this helpful?