---
title: "set_instance"
description: "set_instance — set or remove the license key. Works without sign-in."
url: "https://docs.justcat.it/reference/python-module/set-instance/"
---
# set_instance

## Signature

```python
cat.set_instance(license_key: str, logging_level: LoggingLevel = None) -> None
```

## Parameters

| Parameter | Type | Default | Meaning |
|-----------|------|---------|---------|
| `license_key` | str | required | The key to store. An empty string, whitespace or `None` **removes** the stored key. |
| `logging_level` | LoggingLevel | `None` | `cat.LoggingLevel` member; used only when this is the first call of the process. See [Logging](https://docs.justcat.it/reference/python-module/introduction/#logging "Logging"). |

## What it does

Writes the key to `%APPDATA%\CAT\.catconfig` (`~/.config/CAT/.catconfig` on Linux), the file that identifies this installation and is shared by every CAT tool on the machine. It does **not** sign in — a key can be installed on a machine that has no portal access and no token. Setting a key is how the **Enterprise** plan is activated; once a valid key is stored, every function works offline and `CAT_PORTAL_TOKEN` is no longer read. The key takes effect immediately for the next call.

The key is checked before it is stored: a genuine CAT key is stored even when it is expired or not yet valid (what it unlocks is decided at every use, and a future key starts working the day its window opens); anything that is not a CAT key — a typo, a truncated paste — is refused and the stored key is left unchanged.

## Returns

`None`.

## Raises

`ValueError: The license key was not set. <reason>` when the key is not a CAT key. Removing a key never fails.

## Examples

```python
# activate the Enterprise plan on this machine
cat.set_instance("your-license-key")
print(cat.get_instance().LicenseKey)

# go back to no key (sign-in with CAT_PORTAL_TOKEN applies again)
cat.set_instance("")
```

## Related

- [Introduction](https://docs.justcat.it/reference/python-module/introduction/ "Introduction") — session model, logging, .NET objects, exceptions, sign-in. (sign-in, plans and the license key)
- [`get_instance`](https://docs.justcat.it/reference/python-module/get-instance/ "get_instance") — see what is stored.
- [Get CAT license](https://docs.justcat.it/how-to-guides/licensing-and-admin/get-license/ "Get CAT license") · [Apply a license key](https://docs.justcat.it/how-to-guides/licensing-and-admin/apply-license-key/ "Apply a license key") · [Compare plans](https://docs.justcat.it/compare-plans/ "Compare plans").

