const { result, error } = await unkey.keys.update({ keyId: "key_1233", ownerId: "new owner", remaining: 300, refill: { interval: "monthly", amount: 100, refillDay: 15, }, enabled: true});if (error) { // handle potential network or bad request error // a link to our docs will be in the `error.docs` field console.error(error.message); return;}console.log(result)
Copy
Ask AI
{ "result": {}}
Keys
Update
Update an api key for your users
Copy
Ask AI
const { result, error } = await unkey.keys.update({ keyId: "key_1233", ownerId: "new owner", remaining: 300, refill: { interval: "monthly", amount: 100, refillDay: 15, }, enabled: true});if (error) { // handle potential network or bad request error // a link to our docs will be in the `error.docs` field console.error(error.message); return;}console.log(result)
Copy
Ask AI
{ "result": {}}
All json fields are optional, so you can update only the fields you need.
To delete a field, set it to null.
Copy
Ask AI
const { result, error } = await unkey.keys.update({ keyId: "key_1233", ownerId: "new owner", remaining: 300, refill: { interval: "monthly", amount: 100, refillDay: 15, }, enabled: true});if (error) { // handle potential network or bad request error // a link to our docs will be in the `error.docs` field console.error(error.message); return;}console.log(result)
The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this back to you, so you know who is accessing your API.
Under the hood this upserts and connects an ìdentity for you.
To disconnect the key from an identity, set externalId: null.