API key management
Create, list, and revoke API keys programmatically.
HTTP endpoints on this page
- POST/api-keys
- GET/api-keys
- DELETE/api-keys/{api_key_id}
Parameters and response shapes for each are in the API reference.
You can manage API keys from the Dashboard or through the SDK. Each user can have multiple active keys.
Methods on this page
List keys
api_keys.list()Return your active API keys and their labels.Any tier
Returns
list of dict
One entry per key, newest first.
- api_key_id : str
- The handle to pass to
revoke(). - key_prefix : str
- First 12 characters, e.g.
pk_live_ab12. The full key is never returned after creation, so this is what lets you tell keys apart without being able to reconstruct one. - name : str
- The label you gave it.
- is_active : bool
- False once revoked.
- created_at : str
- When it was created.
- last_used_at : str or None
- None until the key is first used.
- expires_at : str or None
- None for keys that do not expire.
Examples
python
keys = client.api_keys.list()
for key in keys:
print(key["name"], key["key_prefix"], key["created_at"])Create a key
api_keys.create(name="")Mint a new API key. The only call that ever returns the key material.Any tier
Parameters
- name : str, default ""
- A label for the key. Name it by purpose —
"notebook","production","CI pipeline"— so you know which to revoke if one is compromised. Left blank, the key is named after your account.
Returns
dict
- api_key : str
- The key material. Shown exactly once — store it before the call returns or mint another.
- api_key_id : str
- The handle to pass to
revoke(). - warning : str
- A reminder that the key will not be shown again.
Examples
python
new_key = client.api_keys.create(name="Training script")
# Save this, it won't be shown again
print(new_key["api_key"])Revoke a key
api_keys.revoke(key_id)Invalidate a key immediately.Any tier
Parameters
- key_id : str
- The
api_key_idfromlist()orcreate()— not the key material itself.
Notes
Revocation takes effect at once: any request still using the key returns 401 Unauthorized. You can also revoke from the Dashboard with the delete button next to any key.
Examples
python
new_key = client.api_keys.create(name="Training script")
client.api_keys.revoke(key_id=new_key["api_key_id"])