How to change id of a key meanwhile keep quota and quota_remaing

When you say ID of the key, do you mean the value of the key or the alias of the key. In this case value means the string of characters used in authorizing an API. And the alias is simply the custom identifier of the key. It can be seen in the key definition a shown below

image

Yes, you can definitely change both. However, not all values may remain the same. For example
the last_updated and the date_created fields are generated internally and would be modified.

Another one and one you already know is the quota_remaining will take the value from the quota_max. I am waiting on feedback if this can actually be modified.

In the meantime, you could temporarily give the user a new key based on the remaining quota. You can use the Create Custom Key / Import Key. So what you want is:

new quota_max = old quota_remaining
new quota_remaining = old quota_remaining
new quota_renewal_rate = 0
new quota_renews = 0

This way the user would at least get to finish the quota he had on the old key and the quota would not renew.

Then afterwards you can provide him with a new key with the quota_max set to the initial figure.