PermitPlane Docs
All docs pages

Unattended and offline activation

Activate your app on a machine that is never online, or from an installer with nobody at the keyboard.

For a floating licence, borrow a seat instead. See Floating licences.

Activate a machine that is never online

1. Your customer: create the request file

  1. In your app on the offline machine, create an activation request file. The app signs it with the installation's own key.
  2. Copy the file to a machine that is online, for example by USB stick or email.

The request file is at most 8192 bytes. Exchange it within 7 days.

2. You: exchange it for a response file

  1. Log in at app.permitplane.com and open the licence page (app.permitplane.com/ops/vendor/licenses/…).
  2. Under Offline activation, upload the request file.
  3. Click Process request file and save the response file.
  4. Send the response file to your customer.

The Offline activation section shows only if your role may run offline activations. Exchanging takes one installation slot of the licence.

3. Your customer: import the response file

  1. Copy the response file to the offline machine.
  2. Import it in your app within 7 days, or sooner if the licence ends sooner.
  3. Keep the file safe like a licence key. It holds the installation's credentials.

Free the slot again

  1. In your app, create a deactivate request file.
  2. Exchange it the same way. The slot is free again.

A deactivate request file never goes stale.

If the exchange is refused

SituationResult
Same request file sent again, import window openThe same response file
Request file already used for another licenceRefused with 409
Request file for another product or environmentRefused with 409
Deactivate file from another deviceRefused

Your developer: exchange with the management API

  1. Use an API key with the offline_activations.manage permission.
  2. Send a unique Idempotency-Key header, as with every change.
  3. Post the request file:
HTTP
POST licenses/{id}/offline-exchanges
{"request_file": "<contents of the request file>"}

The route is relative to the management API base URL. The full reference is in the API reference after sign-in.

The reply holds these fields:

FieldMeaning
response_fileText to save as the response file
filenameSuggested file name
exchange_id, activation_idIDs of the exchange and installation
import_deadlineLast moment to import
"state": "released"Reply to a deactivate request (no response file)
  1. Save response_file from the first reply. Replays and audit rows show it redacted.
  2. To get it again, send the same request file with a new Idempotency-Key. While the import window is open, you get the identical file.
ErrorStatus
invalid_offline_request (not a valid request file)422
offline_request_expired409
offline_request_scope, offline_request_conflict409
activation_released409
license_suspended, license_revoked, license_expiredLicence state errors

Your developer: activate silently with the TypeScript SDK

A licence key needs no browser and no prompt. Use activateSilently in @permitplane/client (Node 22.3 or newer).

  1. Create the client with the machine-wide stores from @permitplane/client/node:
TypeScript
import { LicenseClient } from '@permitplane/client';
import {
  FileKeyStore,
  FileStateStore,
} from '@permitplane/client/node';

const where = { vendor: 'Acme', product: 'Widget' };
const client = new LicenseClient({
  config, clock,
  keyStore: new FileKeyStore(where),
  stateStore: new FileStateStore(where),
});
await client.initialize();
  1. Call activateSilently at every start:
TypeScript
const result = await client.activateSilently({
  keySources: [
    { env: 'ACME_LICENSE_KEY' },
    { file: '/etc/acme/license.key' },
  ],
  offlineRequestPath:
    '/var/lib/acme/widget/activation.request.json',
  consumeKeyFile: true,
});
// result.outcome: 'already_active' | 'activated'
//   | 'offline_request_written'
  1. Read result.source to see which source was used, never the key. Examples: env:ACME_LICENSE_KEY, file:/etc/acme/license.key, value.

Options

OptionWhat it does
keySourcesTried in order: { env: NAME }, { file: PATH }, { value: KEY }. You choose the names.
offlineRequestPathWith no network, writes an offline request file there and returns offline_request_written.
consumeKeyFileDeletes the key file after a successful activation. Only the file the key came from.
maxAttempts, maxWaitMsRetry limits. Defaults: 5 attempts, 120 s total waiting.
logGets short progress lines with the source label only.

How it behaves

  • A missing, empty or non-key source is skipped.
  • If no source is usable, the call throws. InvalidLicenseKeyError if a source held a non-key, else LicenseUsageError.
  • A key the server refuses is an error. The next source is not tried.
  • A verified paid activation already saved: nothing happens, no network call.
  • A saved state that is no longer valid, such as an expired paid grant, activates again.
  • Network errors, timeouts, 429, 502, 503 and 504 are retried. Backoff is 1 s, 2 s, 4 s, up to 30 s.
  • A Retry-After header is followed exactly. A wait that does not fit ends the call.
  • Retries reuse one attempt ID, so a lost response never takes a second seat.
  • Without offlineRequestPath, no network throws TransportError.
  • After offline_request_written, take the file through the offline steps. Then call importOfflineResponse with the response file.
  • A key file that cannot be deleted raises an error naming the path. The activation itself has succeeded.
  • Keep consumeKeyFile off for read-only mounts, such as Kubernetes secrets.
  • The key is never stored, logged, put in errors or put in the request file.
  • In a long-lived process, prefer a file or a secret over { value }.

Exchange offline from code

TypeScript
// text of the request file; saved as pending
const request = await client.createOfflineRequest('activate');
// ... send it, receive the response file ...
// verifies everything, then stores the grant
await client.importOfflineResponse(responseText);
// releases locally; upload to free the seat
const release = await client.createOfflineRequest('deactivate');

The Flutter, Go, Java, PHP, Rust, C and C# clients have the same two calls (C#: CreateOfflineRequest, ImportOfflineResponse). See the Reference section of their quickstarts.

  • importOfflineResponse accepts only the response to the latest pending request.
  • It must be signed by a pinned key, for this installation key and product.
  • It must arrive inside its import window, with signed licence data that outlives it.
  • Any failure throws Rejected and changes nothing. code is request, signature, installation, import_expired, time, …
  • createOfflineRequest('deactivate') ends the rights at once and clears the saved state. Keep its text until you have uploaded it.
  • While a floating seat is held, call releaseSeat() first.

Pick the machine-wide store folder

FileKeyStore keeps the installation key. FileStateStore keeps credentials and the clock anchor. Every process using the same folder shares one installation.

OSDefault folder
Windows%ProgramData%\<Vendor>\<Product>
macOS/Library/Application Support/<Vendor>/<Product>
Linux/var/lib/<vendor>/<product> (lower case, spaces become -)
  1. Pass { vendor, product } for these folders, or { dir } for another place.
  2. Protect the folder. The files are plain JSON and hold a private key.
OSProtection
Linux and macOSFolders 0700, files 0600. Run the service and the activation under one account (usually root).
WindowsThe SDK gives full control to SYSTEM, Administrators and the creating account only. Activate under the service account.
Windows installerPre-create the folder with the icacls line in the MSI recipe. Keep the parent <Vendor> folder private too.

A folder with default permissions is refused with "machine directory ... is not private". Writes are atomic (temp file and rename).

  1. Give the client a PlatformClock with a boot ID that survives your process. The clock in @permitplane/client/testing is for tests only.

Your developer: use an installer recipe

Each recipe stores the key where only the installing account can read it. It activates once and removes the key. Test with a sandbox key.

Windows MSI

  1. Take the key as a hidden property.
  2. Write it to a file under %ProgramData% in a deferred custom action running as SYSTEM.
  3. Let the service activate on first start with { file } and consumeKeyFile: true.
XML
<Property Id="LICENSEKEY" Secure="yes" Hidden="yes" />
<CustomAction Id="StageKey.Set" Property="StageKey"
  Value="[LICENSEKEY]" />
<CustomAction Id="StageKey" BinaryRef="Helper"
  DllEntry="WriteKeyFile" Execute="deferred"
  Impersonate="no" Return="check" />
<InstallExecuteSequence>
  <Custom Action="StageKey.Set" Before="StageKey"
    Condition="LICENSEKEY" />
  <Custom Action="StageKey" Before="InstallFinalize"
    Condition="LICENSEKEY" />
</InstallExecuteSequence>
PowerShell
msiexec /i Widget.msi `
  LICENSEKEY=PP-XXXXX-XXXXX-XXXXX-XXXXX /qn /l*v install.log
  1. Write your WriteKeyFile helper. It reads CustomActionData. It writes %ProgramData%\Acme\Widget\license.key for SYSTEM and Administrators only.
  2. Create the folder with this ACL:
PowerShell
icacls <dir> /inheritance:r `
  /grant:r "*S-1-5-18:(OI)(CI)F" "*S-1-5-32-544:(OI)(CI)F"

Hidden="yes" keeps the key out of the verbose log. Never pass the key on your own helper's command line. Any user can see it there.

macOS pkg

A pkg takes no parameters, and its scripts do not get your shell's environment.

  1. Stage the key as a file first, as root (an MDM script or the admin).
  2. Let the pkg's postinstall run your activation tool as root.
Shell
# MDM or admin, before the install
DIR="/Library/Application Support/Acme/Widget"
umask 077 && mkdir -p "$DIR" && \
  printf '%s' "$KEY" > "$DIR/license.key"
# postinstall (root); the tool calls
# activateSilently({ keySources: [{ file }],
#   consumeKeyFile: true })
/usr/local/bin/widget-activate

Docker

  1. Use a secret file, not an environment variable. docker inspect shows environment variables.
  2. Keep the store on a volume. Without saved state, the container activates at every start.
YAML
services:
  widget:
    image: acme/widget
    environment:
      ACME_STATE_DIR: /var/lib/acme/widget
    secrets: [acme_license_key]
    volumes: [widget-state:/var/lib/acme/widget]
secrets:
  acme_license_key: { file: ./license.key }
volumes:
  widget-state: {}
  1. Activate from the secret, with { dir: process.env.ACME_STATE_DIR } for both stores:
TypeScript
await client.activateSilently({
  keySources: [
    { file: '/run/secrets/acme_license_key' },
    { env: 'ACME_LICENSE_KEY' },
  ],
});
  1. Leave consumeKeyFile off. Secrets are read-only.

Kubernetes

  1. Mount a Secret as a file.
  2. Keep the state on a persistent volume. Use a StatefulSet (one volume per pod).
  3. Size the licence for the replicas. Each pod with its own state takes its own seat.
YAML
apiVersion: v1
kind: Secret
metadata: { name: acme-license }
stringData: { license.key: PP-XXXXX-XXXXX-XXXXX-XXXXX }
---
# in the pod spec
volumes:
  - name: license
    secret: { secretName: acme-license, defaultMode: 0400 }
containers:
  - name: widget
    volumeMounts:
      - name: license
        mountPath: /var/run/secrets/acme
        readOnly: true
      - { name: state, mountPath: /var/lib/acme/widget }
  1. Activate with { file: '/var/run/secrets/acme/license.key' } and consumeKeyFile off.
  2. After activation, remove the Secret. The node no longer needs the key.