How long does a user api key last. What is the validity period?

I’m wondering if the user api key is regenerated. I don’t want to manually regenerate the key once in a while. It would be nice that it’s at least every login session.

I cannot find the answer anywhere.

Thank you in advance!

The user api key doesn’t regenerate, but you can build your own logic and call it with a cronjob or apply it to an event. Something like this (not tested):

$app->on('admin.init', function() {

    // regenerate user api key after each login
    $this->on('cockpit.authentication.success', function($user) {

        $user['api_key'] = 'new random string';

        $this->storage->save('cockpit/accounts', $user);


1 Like