await unkey.keys.update({
keyId: "xyz_AS5HDkXXPot2MMoPHD8jnL",
ownerId: "new owner",
remaining: 300,
refil: {
interval: "monthly",
amount: 100,
refillDay: 15,
},
enabled: true
});
{
result: {
key: "xyz_AS5HDkXXPot2MMoPHD8jnL"
keyId: "key_YALWkHZaA4neUa1JJoXTAw"
}
}
All json fields are optional, so you can update only the fields you need.
To delete a field, set it to null
.
Request
The ID of the key you want to update.
Update the name of the key.
Update the owner id of the key.
Update the metadata of a key. You will have to provide the full metadata
object, not just the fields you want to update.
Update the expire time of a key.
The expire time is a unix timestamp in milliseconds.
Unkey comes with per-key ratelimiting out of the box.
Either fast
or consistent
.
Read more here
The total amount of burstable requests.
How many tokens to refill during each refillInterval
Determines the speed at which tokens are refilled.
In milliseconds
Update the remaining usage of a key.
Unkey allows automatic refill on ‘remaining’ on a ‘daily’ or ‘monthly’ interval.
The amount to refill ‘remaining’.
Read more here
value from 1
to 31
.
The day each month to refill ‘remaining’. If no value is given, The 1st will be used as a default.
Read more here
Sets if the key is enabled or disabled.
Response
await unkey.keys.update({
keyId: "xyz_AS5HDkXXPot2MMoPHD8jnL",
ownerId: "new owner",
remaining: 300,
refil: {
interval: "monthly",
amount: 100,
refillDay: 15,
},
enabled: true
});
{
result: {
key: "xyz_AS5HDkXXPot2MMoPHD8jnL"
keyId: "key_YALWkHZaA4neUa1JJoXTAw"
}
}