# Automatic License Renewal

With automatic renewal, your SelfDocHub installation checks the license server once an hour and installs a renewed license on its own. This page explains how to switch it on in the application. You need a token first: see [Auto Renew Tokens](/documentation/auto-renew-tokens).

> **Roles:** Only an `admin` sees and can change the **Auto renew** block.

## Prerequisites

- A token created on the **Auto Renew** page of the admin dashboard. It must cover the device ID of this installation: either all licenses of the business or this device ID in its list.
- An installation with a valid license. Without one the application shows the full-page "No valid license found" screen instead of the License page, so install the first license as described in [License and Tiers](/documentation/license).
- Outgoing HTTPS access from the server to `admin.selfdochub.com`.

## Turning it on

1. Sign in as an administrator and open **License** in the top menu.
2. Under the main **License** block, open the **Auto renew** block. It is collapsed by default.
3. Paste the token into **Authorization token**.
4. Switch **Enabled** on.
5. Click **Save**.

Saving with the switch on starts a check right away, and the block shows its outcome a few seconds later. After that the check repeats every hour. The first check after the server starts runs shortly after the start.

The main **License** block can be collapsed with the arrow in its header as well. It is expanded by default.

## What the installation does

Each check sends the license server the token, the device ID and the `created_at` date of the installed `license.json`. The answer decides what happens:

| Result shown | What happened |
|--------------|---------------|
| a newer license was installed | The server returned a newer license. It was verified and installed, with no restart. |
| a new license was issued and installed | The installation had no license file and the server issued one. |
| the license is up to date | There is nothing newer. Nothing changes. |
| the server's license is not newer, nothing changed | The server returned a file that is not newer than the installed one. It is ignored. |

Before a received license is installed, the application checks its signature, that it was issued for this device ID and that it has not expired. An invalid, expired or older license is never installed, so a bad answer cannot replace a working license.

### The old license is kept

The current `license.json` in the data directory is **renamed, not deleted**, then the new file is written. The old file gets the time of the replacement in its name:

```text
data/license.json                       ← the installed license
data/license.json.20261116T101500Z.old  ← the replaced one, kept for safety
```

You can remove the `.old` files yourself when you no longer need them.

## The result of the last check

Below the switch the block shows the time of the last check and its result. If a check fails, the error is shown here, for example:

- `the license server answered 401: Invalid or missing token.` The token is wrong or was regenerated. Paste the new token.
- `the license server answered 403: This token is not valid for the given Device ID.` The token is limited to other licenses. Edit it in the dashboard.
- `request to the license server failed: ...` The server cannot reach `admin.selfdochub.com`. Check the network and proxy settings.

The result is kept in memory, so it is empty again after a restart until the next check.

## Where the token is kept

The token is saved in `license_auto_renew.json` in the data directory, readable only by the user that runs SelfDocHub. It is never sent back to the browser: after saving, the field is empty and only says that a token is saved. Leave the field empty and click **Save** to change just the switch. Paste a new token to replace the saved one. Include `license_auto_renew.json` in your backups like the rest of the data directory (see [Upgrading and Backups](/documentation/upgrading-and-backups)).

> **Note:** The license server address is fixed in the application, so the token can only be used with `admin.selfdochub.com`.

## Turning it off

Switch **Enabled** off and click **Save**. The token stays saved, and no more requests are sent. You can still install a license by hand at any time.

## Next steps

- [Auto Renew Tokens](/documentation/auto-renew-tokens)
- [License and Tiers](/documentation/license)
- [Notifications](/documentation/notifications)

---
Source: https://selfdochub.com/documentation/license-auto-renew
