Services
KeyService
The service used to make key related requests.
Available via the keys
property of the Client
.
See the full docs
on the KeyService
.
Create key
Creates a new API key for the api with the given ID.
result = await client.keys.create_key(
"api_123", owner_id="jonxslays", prefix="test"
)
Verify key
Verifies that a key is valid, and within ratelimit.
result = await client.keys.verify_key("test_123DEF", "api_789")
Revoke key
Revokes access and removes the key with the given ID.
result = await client.keys.revoke_key("key_456GHI")
Update key
Updates the key with the given ID.
from unkey import Refill, RefillInterval
result = await client.keys.update_key(
"key_456GHI",
meta={"billing_tier": "premium"},
ratelimit=None,
expires=None,
remaining=1000,
refill=Refill(1000, RefillInterval.Daily)
)
Update remaining
Updates the number of verifications remaining for the key with the given ID.
from unkey import UpdateOp
result = await client.keys.update_remaining("key_456GHI", 100, UpdateOp.Set)
Get key
Retrieves details for the key with the given ID.
result = await client.keys.get_key("key_789JKL")
Was this page helpful?