﻿---
title: License
description: The license state of this device, or of this program under an Application license, and the calls that refresh, activate and deactivate it.
url: https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/
---

# License – C API Reference – Deformable v0.5.0

The license: its state, and the calls that refresh, activate and deactivate it. Nothing ever refuses to run: without a license the Free license runs, and a scene simulates at most 2,500 tetrahedrons. Two licenses lift the limit: the Standalone license of this device and user, and the Application license that a program activates for itself. A license failure's message is written to show the user as it is, such as "Free license: this would simulate 3,000 tetrahedrons; the limit is 2,500 per scene".

[`deformable_license_activate`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_activate) takes both kinds of key. A Standalone key is activated online once and stays on the device; the library keeps one Standalone state per device and user, shared by every program that loads it: the plugins and the SDKs. An Application key is checked offline and holds for the process only, so a program activates it at every start, before any other engine call; with it, the other calls contact nothing, and a plugin host refuses it. [`deformable_license_status`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_status) never contacts the licensing service and is cheap enough to call on every redraw. [`deformable_license_refresh`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_refresh), [`deformable_license_activate`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_activate) and [`deformable_license_deactivate`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_deactivate) wait on the network for at most their timeout, so a host with an interface calls them off its interface thread. [`deformable_license_set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_set_online_access) keeps a process off the network when its user asked for that.

## DeformableLicenseState

**Enum** · `deformable.h`

```c
typedef int32_t DeformableLicenseState;
```

The license state of this program, as [`DeformableLicenseStatus`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestatus) reports it in `state`: its Application license, or
else the Free or Standalone license of this device and user, which every program that loads the library shares.

**Values**

- `DEFORMABLE_LICENSE_STATE_FREE_LICENSE` (`0`): No license key: the Free license, at most `tetrahedron_limit` (2,500) tetrahedrons per scene.
- `DEFORMABLE_LICENSE_STATE_STANDALONE_LICENSE` (`1`): A Standalone license key with a lease that licenses this device; no limit.
- `DEFORMABLE_LICENSE_STATE_NEEDS_ONLINE` (`2`): A Standalone license key whose lease ran out, or that this device's clock leaves untrusted: the Free license runs
  until the next renewal online.
- `DEFORMABLE_LICENSE_STATE_DEVELOPMENT` (`3`): A development build of the library: licensing is off, no limit, and nothing contacts the licensing service. It is
  not the Application license.
- `DEFORMABLE_LICENSE_STATE_APPLICATION_TRIAL` (`4`): An Application trial key runs in this program: no limit, until the key ends.
- `DEFORMABLE_LICENSE_STATE_APPLICATION_TRIAL_ENDED` (`5`): The Application trial key of this program ended: the Free license runs.
- `DEFORMABLE_LICENSE_STATE_APPLICATION_LICENSE` (`6`): A full Application license key runs in this program; no limit.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `LicenseState`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#licensestate) · [Python `LicenseState`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#licensestate)

## DeformableLicenseStatus

**Struct** · `deformable.h`

```c
typedef struct DeformableLicenseStatus {
    DeformableLicenseState state;
    uint32_t days_left;
    uint32_t tetrahedron_limit;
    uint8_t has_license_key;
    char message[128];
} DeformableLicenseStatus;
```

The license state as a status line shows it.

**Fields**

- `state` ([`DeformableLicenseState`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate)): Which license state the program is in; the other fields detail it.
- `days_left` (`uint32_t`): In [`DEFORMABLE_LICENSE_STATE_APPLICATION_TRIAL`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate-deformable_license_state_application_trial), the whole days until the trial key ends counting the current day;
  0 in any other state.
- `tetrahedron_limit` (`uint32_t`): The most tetrahedrons one scene simulates: 2,500 under the Free license and every state that falls back to it,
  0 when there is no limit.
- `has_license_key` (`uint8_t`): 1 when a Standalone license key is stored on this device, so a host offers Deactivate rather than Activate; 0
  under an Application license.
- `message` (`char[128]`): The status line, NUL-terminated UTF-8: "Free license: up to 2,500 tetrahedrons per scene — Buy license",
  "Standalone license", "Application license: Acme Inc.", ... The company of an Application license is cut to
  fit.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `LicenseStatus`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#licensestatus) · [Python `LicenseStatus`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#licensestatus)

## deformable_license_status

**Function** · `deformable.h`

```c
DeformableStatus deformable_license_status(
    DeformableLicenseStatus *status);
```

Writes the license state of this program to `status`: its Application license, or else the Free or Standalone license
of this device and user. It never contacts the licensing service and never waits on the network: it reads the
per-user license store at most once every 2 seconds, so it is cheap enough to call on every redraw.

**Parameters**

- `status` ([`DeformableLicenseStatus *`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestatus)): Out. Receives the license state.

**Errors**

- Only the statuses every call can give, which the [conventions](https://help.tangerina.io/deformable/v0.5.0/api-references/c/overview/#conventions) describe.

**Example**

```c
DeformableLicenseStatus status;
CHECK(deformable_license_status(&status));
if (status.tetrahedron_limit)
    printf("%s (%u per scene)\n", status.message,
           (unsigned)status.tetrahedron_limit);
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `status`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#status) · [Python `license.status`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#license-status)

## deformable_license_refresh

**Function** · `deformable.h`

```c
DeformableStatus deformable_license_refresh(
    uint32_t timeout_milliseconds,
    DeformableLicenseStatus *status);
```

Renews the stored Standalone key's lease when it no longer licenses this device, or when it is 6 hours old or ends
within a day and no contact ran in the last 5 minutes, waiting at most `timeout_milliseconds`. Without a key, and under
an Application license, nothing is sent and it gives the state as it is. The engine renews the lease on its own while
it runs, so a host calls this when the program starts and when its user asks.

It waits on the network, so a host with an interface calls it off its interface thread. Contacts run one at a time
per process: a second caller waits for the first.

**Parameters**

- `timeout_milliseconds` (`uint32_t`): How long to wait for the service, in milliseconds: at least 1; above 60,000 counts as 60,000. 15,000 (15 s) suits a host with no reason to choose otherwise.
- `status` ([`DeformableLicenseStatus *`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestatus)): Out. Receives the license state after the call, on success and on a `DEFORMABLE_STATUS_LICENSE_*` failure, so a host shows the state after a failure too. May be `NULL`.

**Errors**

- [`DEFORMABLE_STATUS_INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_invalid_argument): `timeout_milliseconds` is 0.
- [`DEFORMABLE_STATUS_LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_service_unavailable): The service could not be reached or did not answer, its answer did not verify or this device's clock contradicts it, or [`deformable_license_set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_set_online_access) forbade every contact. The lease is kept until it runs out.
- [`DEFORMABLE_STATUS_LICENSE_KEY_REJECTED`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_key_rejected): The service no longer accepts the key: it was revoked or refunded, or this device was removed. The license is then forgotten at once and the Free license runs.
- [`DEFORMABLE_STATUS_LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_storage_failed): The per-user license store could not be written; the message names its folder.

**Example**

```c
DeformableLicenseStatus status;
if (deformable_license_refresh(15000, &status))
    puts(deformable_last_error_message());
else
    puts(status.message);
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `refresh`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#refresh) · [Python `license.refresh`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#license-refresh)

## deformable_license_activate

**Function** · `deformable.h`

```c
DeformableStatus deformable_license_activate(
    const char *license_key,
    uint32_t timeout_milliseconds,
    DeformableLicenseStatus *status);
```

Activates `license_key`, a Standalone or an Application license key, told apart by their shape: a Standalone key is
tgdfp-xxxxx-xxxxx-xxxxx-xxxxx, an Application key tgdfp-\<payload hex\>-\<signature hex\>.

A Standalone key is activated on this device with the licensing service, waiting at most `timeout_milliseconds`; the
state is then [`DEFORMABLE_LICENSE_STATE_STANDALONE_LICENSE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate-deformable_license_state_standalone_license). The key already stored here renews its lease instead. It
waits on the network, so a host with an interface calls it off its interface thread.

An Application key is checked offline, without waiting, and licenses this program for as long as it runs: nothing is
stored or sent, so the program activates it at every start, as its first Deformable call, before status and refresh.
The state is then [`DEFORMABLE_LICENSE_STATE_APPLICATION_LICENSE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate-deformable_license_state_application_license), or [`DEFORMABLE_LICENSE_STATE_APPLICATION_TRIAL`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate-deformable_license_state_application_trial) for a
trial key. The same key again changes nothing. A full key covers the versions of the library released until its
updates end, and keeps working in them forever. A development build of the library checks the key the same way but
stays [`DEFORMABLE_LICENSE_STATE_DEVELOPMENT`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestate-deformable_license_state_development).

On failure, [`deformable_last_error_message`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformable_last_error_message) says why the key was not activated, written to show the user as it is.

**Parameters**

- `license_key` (`const char *`): The license key, NUL-terminated UTF-8, where letter case does not matter and spaces and line breaks are removed.
- `timeout_milliseconds` (`uint32_t`): How long to wait for the service, in milliseconds: at least 1; above 60,000 counts as 60,000. 15,000 (15 s) suits a host with no reason to choose otherwise. An Application key never waits.
- `status` ([`DeformableLicenseStatus *`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestatus)): Out. Receives the license state after the call, on success and on a `DEFORMABLE_STATUS_LICENSE_*` failure, so a host shows the state after a failure too, except after a refused Application key in a program that has neither set an Application license nor read its license state yet, so a refused key leaves nothing on the device. May be `NULL`.

**Errors**

- [`DEFORMABLE_STATUS_INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_invalid_argument): `license_key` is not UTF-8 or no license key ("This is not a license key"), an Application key that does not verify ("This license key is not valid"), another Standalone key while one is stored on this device ("Deactivate the current license first"), another Application key once one is set ("Another Application license key is already set in this program"), or a Standalone key in a program on an Application license ("This program uses an Application license"); or `timeout_milliseconds` is 0. Nothing changes then.
- [`DEFORMABLE_STATUS_LICENSE_KEY_REJECTED`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_key_rejected): The service refused the Standalone key: it does not exist, was revoked or refunded, is not for Deformable, or every seat of the license is in use. Or the Application key was revoked ("This Application license key was revoked"), is a trial key that ended ("Application trial ended — Buy license"), covers only versions released before this one, or was given inside a plugin host, where it does not work.
- [`DEFORMABLE_STATUS_LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_service_unavailable): The service could not be reached or did not answer, its answer did not verify or this device's clock contradicts it, or [`deformable_license_set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_set_online_access) forbade every contact.
- [`DEFORMABLE_STATUS_LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_storage_failed): The per-user license store could not be written; the message names its folder.

**Example**

```c
DeformableLicenseStatus status;
const char *key = "tgdfp-xxxxx-xxxxx-xxxxx-xxxxx";
if (deformable_license_activate(key, 15000, &status))
    puts(deformable_last_error_message());
else
    puts(status.message);

// An app on an Application license activates its key, exactly as
// copied from the Licenses page, first thing at every start.
// This one is shaped like an Application key but signed by
// nobody, so it is refused.
const char *application_key =
    "tgdfp-7b2276657273696f6e223a317d-"
    "0000000000000000000000000000000000000000000000000000000000000000"
    "0000000000000000000000000000000000000000000000000000000000000000";
if (deformable_license_activate(application_key, 15000, &status))
    puts(deformable_last_error_message());
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `activate`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#activate) · [Python `license.activate`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#license-activate)

## deformable_license_deactivate

**Function** · `deformable.h`

```c
DeformableStatus deformable_license_deactivate(
    uint32_t timeout_milliseconds,
    DeformableLicenseStatus *status);
```

Forgets the Standalone license on this device at once, even offline, so the Free license runs; then frees its seat
with the licensing service, waiting at most `timeout_milliseconds`, so the key can be activated on another device. When
the seat cannot be freed, the customer removes this device on the Licenses page. With no key stored, or under an
Application license, it does nothing and succeeds. It waits on the network, so a host with an interface calls it off
its interface thread.

**Parameters**

- `timeout_milliseconds` (`uint32_t`): How long to wait for the service, in milliseconds: at least 1; above 60,000 counts as 60,000. 15,000 (15 s) suits a host with no reason to choose otherwise.
- `status` ([`DeformableLicenseStatus *`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformablelicensestatus)): Out. Receives the license state after the call, on success and on a `DEFORMABLE_STATUS_LICENSE_*` failure, so a host shows the state after a failure too. May be `NULL`.

**Errors**

- [`DEFORMABLE_STATUS_INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_invalid_argument): `timeout_milliseconds` is 0.
- [`DEFORMABLE_STATUS_LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_service_unavailable): The seat could not be freed: the service could not be reached, or [`deformable_license_set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_set_online_access) forbade every contact. The license is forgotten here all the same.
- [`DEFORMABLE_STATUS_LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_storage_failed): The per-user license store could not be changed; the message names its folder.

**Example**

```c
DeformableLicenseStatus status;
CHECK(deformable_license_deactivate(15000, &status));
// has_license_key is 0 now: the host offers Activate again.
puts(status.message);
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `deactivate`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#deactivate) · [Python `license.deactivate`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#license-deactivate)

## deformable_license_set_online_access

**Function** · `deformable.h`

```c
DeformableStatus deformable_license_set_online_access(uint8_t allowed);
```

Allows (`allowed` not 0, the default) or forbids (`allowed` 0) every contact with the licensing service from this
process, for a host whose user turned online access off. Forbidden, nothing is sent: [`deformable_license_refresh`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_refresh) and
[`deformable_license_activate`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_activate) give [`DEFORMABLE_STATUS_LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/errors/#deformablestatus-deformable_status_license_service_unavailable) and change nothing,
[`deformable_license_deactivate`](https://help.tangerina.io/deformable/v0.5.0/api-references/c/license/#deformable_license_deactivate) forgets the license without freeing its seat, and the engine never renews the lease on
its own, so it runs out as it would offline. An Application key is checked offline and is not affected. It grants
nothing and reads no license state, and it fails only when the library fails inside.

**Parameters**

- `allowed` (`uint8_t`): Not 0 allows every contact, 0 forbids them.

**Errors**

- Only the statuses every call can give, which the [conventions](https://help.tangerina.io/deformable/v0.5.0/api-references/c/overview/#conventions) describe.

**Example**

```c
// The user turned online access off in the host's settings.
CHECK(deformable_license_set_online_access(0));
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.5.0/user-guides/c/getting-started/#license) · [Rust `set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/rust/license/#set_online_access) · [Python `license.set_online_access`](https://help.tangerina.io/deformable/v0.5.0/api-references/python/license/#license-set_online_access)
