How to update user token from API?

Hello. I tried to find information on this issue among the topics of this forum, but did not find anything.

I wasn’t aware of that route, too, but after a quick look at RestApi.php I saw, that it is already implemented.

Just call https://cockpit-url.com/api/cockpit/refreshUserApiKey?token=current-user-token to refresh the user token.

But it looks like you could lock yourself out if you call that route with your own api key, because you can’t authenticate again - without a valid api token to get your new one :wink:

If you have permission to update accounts, you can also use the /api/cockpit/saveUser route with a locally updated api key.

Or look at the code of both methods and write your own api endpoint to fit your needs.