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
- In your app on the offline machine, create an activation request file. The app signs it with the installation's own key.
- 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
- Log in at app.permitplane.com and open the licence page (app.permitplane.com/ops/vendor/licenses/…).
- Under Offline activation, upload the request file.
- Click Process request file and save the response file.
- 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
- Copy the response file to the offline machine.
- Import it in your app within 7 days, or sooner if the licence ends sooner.
- Keep the file safe like a licence key. It holds the installation's credentials.
Free the slot again
- In your app, create a deactivate request file.
- Exchange it the same way. The slot is free again.
A deactivate request file never goes stale.
If the exchange is refused
| Situation | Result |
|---|---|
| Same request file sent again, import window open | The same response file |
| Request file already used for another licence | Refused with 409 |
| Request file for another product or environment | Refused with 409 |
| Deactivate file from another device | Refused |
Your developer: exchange with the management API
- Use an API key with the
offline_activations.managepermission. - Send a unique
Idempotency-Keyheader, as with every change. - Post the request file:
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:
| Field | Meaning |
|---|---|
response_file | Text to save as the response file |
filename | Suggested file name |
exchange_id, activation_id | IDs of the exchange and installation |
import_deadline | Last moment to import |
"state": "released" | Reply to a deactivate request (no response file) |
- Save
response_filefrom the first reply. Replays and audit rows show it redacted. - 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.
| Error | Status |
|---|---|
invalid_offline_request (not a valid request file) | 422 |
offline_request_expired | 409 |
offline_request_scope, offline_request_conflict | 409 |
activation_released | 409 |
license_suspended, license_revoked, license_expired | Licence 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).
- Create the client with the machine-wide stores from
@permitplane/client/node:
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();- Call
activateSilentlyat every start:
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'- Read
result.sourceto see which source was used, never the key. Examples:env:ACME_LICENSE_KEY,file:/etc/acme/license.key,value.
Options
| Option | What it does |
|---|---|
keySources | Tried in order: { env: NAME }, { file: PATH }, { value: KEY }. You choose the names. |
offlineRequestPath | With no network, writes an offline request file there and returns offline_request_written. |
consumeKeyFile | Deletes the key file after a successful activation. Only the file the key came from. |
maxAttempts, maxWaitMs | Retry limits. Defaults: 5 attempts, 120 s total waiting. |
log | Gets 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.
InvalidLicenseKeyErrorif a source held a non-key, elseLicenseUsageError. - 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,503and504are retried. Backoff is 1 s, 2 s, 4 s, up to 30 s. - A
Retry-Afterheader 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 throwsTransportError. - After
offline_request_written, take the file through the offline steps. Then callimportOfflineResponsewith the response file. - A key file that cannot be deleted raises an error naming the path. The activation itself has succeeded.
- Keep
consumeKeyFileoff 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
// 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.
importOfflineResponseaccepts 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
Rejectedand changes nothing.codeisrequest,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.
| OS | Default folder |
|---|---|
| Windows | %ProgramData%\<Vendor>\<Product> |
| macOS | /Library/Application Support/<Vendor>/<Product> |
| Linux | /var/lib/<vendor>/<product> (lower case, spaces become -) |
- Pass
{ vendor, product }for these folders, or{ dir }for another place. - Protect the folder. The files are plain JSON and hold a private key.
| OS | Protection |
|---|---|
| Linux and macOS | Folders 0700, files 0600. Run the service and the activation under one account (usually root). |
| Windows | The SDK gives full control to SYSTEM, Administrators and the creating account only. Activate under the service account. |
| Windows installer | Pre-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).
- Give the client a
PlatformClockwith a boot ID that survives your process. The clock in@permitplane/client/testingis 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
- Take the key as a hidden property.
- Write it to a file under
%ProgramData%in a deferred custom action running as SYSTEM. - Let the service activate on first start with
{ file }andconsumeKeyFile: true.
<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>msiexec /i Widget.msi `
LICENSEKEY=PP-XXXXX-XXXXX-XXXXX-XXXXX /qn /l*v install.log- Write your
WriteKeyFilehelper. It readsCustomActionData. It writes%ProgramData%\Acme\Widget\license.keyfor SYSTEM and Administrators only. - Create the folder with this ACL:
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.
- Stage the key as a file first, as root (an MDM script or the admin).
- Let the pkg's postinstall run your activation tool as root.
# 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-activateDocker
- Use a secret file, not an environment variable.
docker inspectshows environment variables. - Keep the store on a volume. Without saved state, the container activates at every start.
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: {}- Activate from the secret, with
{ dir: process.env.ACME_STATE_DIR }for both stores:
await client.activateSilently({
keySources: [
{ file: '/run/secrets/acme_license_key' },
{ env: 'ACME_LICENSE_KEY' },
],
});- Leave
consumeKeyFileoff. Secrets are read-only.
Kubernetes
- Mount a Secret as a file.
- Keep the state on a persistent volume. Use a StatefulSet (one volume per pod).
- Size the licence for the replicas. Each pod with its own state takes its own seat.
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 }- Activate with
{ file: '/var/run/secrets/acme/license.key' }andconsumeKeyFileoff. - After activation, remove the Secret. The node no longer needs the key.