await unkey.keys.update({
  keyId: "xyz_AS5HDkXXPot2MMoPHD8jnL",
  ownerId: "new owner",
  remaining: 300,
  refil: {
    interval: "daily",
    amount: 100
  },
  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

keyId
string
required

The ID of the key you want to update.

name
string | null

Update the name of the key.

ownerId
string | null

Update the owner id of the key.

meta
JSON | null

Update the metadata of a key. You will have to provide the full metadata object, not just the fields you want to update.

expires
int | null

Update the expire time of a key.

The expire time is a unix timestamp in milliseconds.

ratelimit
Object | null

Unkey comes with per-key ratelimiting out of the box.

remaining
int | null

Update the remaining usage of a key.

refill
Object

Unkey allows automatic refill on ‘remaining’ on a ‘daily’ or ‘monthly’ interval.

enabled
boolean

Sets if the key is enabled or disabled.

Response

result
key
string
required

The updated key.

keyId
string
required

The updated key id.

await unkey.keys.update({
  keyId: "xyz_AS5HDkXXPot2MMoPHD8jnL",
  ownerId: "new owner",
  remaining: 300,
  refil: {
    interval: "daily",
    amount: 100
  },
  enabled: true
});
{
  result: {
    key: "xyz_AS5HDkXXPot2MMoPHD8jnL"
    keyId: "key_YALWkHZaA4neUa1JJoXTAw"
	}
}