Clavem

Move your licenses from Keygen to Clavem and keep customers' keys working

Keygen exposes every license through its API, so you can export keys, expiry dates and limits with a short script and import them into Clavem. Your app needs real code changes, because Keygen's API is shaped differently from the Lemon Squeezy style Clavem follows.

What carries over and what does not

A Keygen license has a key, an optional name, an expiry, a read-only status, a suspended flag, a maxMachines limit and a created timestamp, plus an owner relationship that points to a user with an email. As of November 2026 Keygen’s docs say status is “for status at-a-glance” and does not replace validation, so build your export from suspended and expiry, not from status.

Keygen Clavem import column Note
key key Kept as written, 12 to 256 characters.
owner’s email email Required. Keygen stores it on the user, not the license.
name name Optional.
maxMachines activation_limit null becomes -1, unlimited.
expiry expires_at ISO 8601. Empty never expires.
suspended status true becomes disabled.
created created_at
machines not imported See the fingerprint section.

Policies, entitlements, groups, heartbeats and check-in rules have no counterpart in Clavem’s documented License API. If your app depends on them, decide what replaces them before you start.

Step 1: export the licenses

Keygen’s list endpoints use cursor pagination: ask for page[size] up to 100 and follow links.next until it is null. This script reads users and licenses and writes licenses.csv with Clavem’s column names. It needs an admin token and Node 18 or later.

// KEYGEN_ACCOUNT=... KEYGEN_TOKEN=... node export-keygen.mjs
import { writeFile } from 'node:fs/promises';
const ORIGIN = 'https://api.keygen.sh';
const BASE = `${ORIGIN}/v1/accounts/${process.env.KEYGEN_ACCOUNT}`;
const headers = { Accept: 'application/vnd.api+json', Authorization: `Bearer ${process.env.KEYGEN_TOKEN}` };

async function* list(path) {
  let url = `${BASE}${path}?page[size]=100`;
  while (url) {
    const res = await fetch(url, { headers });
    if (!res.ok) throw new Error(`${res.status} ${url}`);
    const body = await res.json();
    yield* body.data;
    url = body.links?.next ? new URL(body.links.next, ORIGIN).href : null;
  }
}

const emails = new Map();
for await (const u of list('/users')) emails.set(u.id, u.attributes.email);

const cell = (v) => (v == null ? '' : /[",\n]/.test(String(v)) ? `"${String(v).replaceAll('"', '""')}"` : String(v));
const rows = [['key', 'email', 'name', 'activation_limit', 'expires_at', 'status', 'created_at']];
for await (const l of list('/licenses')) {
  const a = l.attributes;
  rows.push([
    a.key,
    emails.get(l.relationships?.owner?.data?.id) ?? a.metadata?.email, // adjust if you keep the buyer's email elsewhere
    a.name,
    a.maxMachines ?? -1,
    a.expiry,
    a.suspended ? 'disabled' : '',
    a.created,
  ].map(cell));
}
await writeFile('licenses.csv', rows.map((r) => r.join(',')).join('\n') + '\n');

Clavem’s file parser accepted every row. Licenses whose owner has no email are written with an empty email and will be rejected row by row with email is required, which tells you which ones to fix.

Step 2: import

Create the Clavem product, choose Import, CSV or JSON file, and pick it. The screen maps each header and shows the first five rows before anything is sent. Rows go in batches of 500, a bad row is listed without stopping the rest, and running the file again is safe. See Import existing licenses.

Three traps specific to Keygen

Soft limits become hard limits. Keygen documents that maxMachines is enforced only when the policy is strict, and that a floating, non-strict license is not invalidated for going over. Clavem refuses an activation once the limit is reached. A buyer who runs more machines than the limit allows will be able to activate only that many after the move. Count machines per license in Keygen’s machines list, find the ones above maxMachines, and raise their activation_limit in the file before you import.

Signed keys. Keygen’s ED25519_SIGN and similar schemes produce keys of the form key/<base64url data>.<signature>. Those can be long, and Clavem refuses keys above 256 characters. They are also case-sensitive, while Clavem matches keys without regard to capitals. If your keys carry signed data, check the longest one and look for two keys that differ only in case. An app that verifies the signature offline with an embedded public key needs no server for that check, so leave it in place as a fallback in the new build.

Fingerprints. Keygen machines are identified by fingerprint. Clavem’s activate call accepts an optional fingerprint and returns the existing seat when the same one activates again. Imported devices are stored without a fingerprint, so a machine imported from Keygen would take a second seat the first time the new app activates. Import without devices, set the limit to the license’s maxMachines, and the same devices simply activate again.

Step 3: change the app

Keygen answers a validation with meta.valid and a meta.code. Clavem answers with valid and an error string, and the HTTP status carries the outcome. The documented advice is to branch on the status and on valid, not on the error text.

// Before: Keygen
const res = await fetch(`https://api.keygen.sh/v1/accounts/${ACCOUNT}/licenses/actions/validate-key`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/vnd.api+json', Accept: 'application/vnd.api+json' },
  body: JSON.stringify({ meta: { key, scope: { fingerprint } } }),
});
const { meta } = await res.json();
if (!meta.valid) lock(meta.code);

// After: Clavem
const post = async (path, body) => {
  const res = await fetch(`https://clavem.io${path}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
  return { status: res.status, body: await res.json() };
};
let r = await post('/v1/licenses/validate', { license_key: key, instance_id: savedInstanceId });
if (r.status === 404 && r.body.license_key) {
  // the key exists but this device is not known yet: first launch after the update
  r = await post('/v1/licenses/activate', { license_key: key, instance_name: deviceName, fingerprint });
  if (r.body.activated) saveInstanceId(r.body.instance.id);
}
if (!(r.body.valid ?? r.body.activated)) lock(r.body.error);

The license_key check tells a known key with an unknown device apart from an unknown key, which answers 404 without that object. The device activation guide and the API reference have the full flow.

Payments and subscribers

Keygen does not take payments, so there are no subscriptions to move out of it. Your billing system stays where it is. If you want Stripe purchases to issue Clavem keys, connect Stripe and map products as described in Connecting Stripe. Keys imported from Keygen have no Stripe subscription, so Stripe events never change them. For subscription products, copy the expiry Keygen holds and move it with PATCH /v1/admin/licenses/:id as renewals arrive, or let new purchases issue new keys.

Rollback

Keep the Keygen account until the last build that calls it is out of use, because installed apps keep calling the old host. New builds point at Clavem, old builds at Keygen, and both sets of keys stay valid. Put the host behind a setting so one release can flip it back, and keep licenses.csv as the archive. Clavem exports every key as CSV from the Licenses screen.

Questions

Can Clavem import Keygen machines as devices?

It can, but it usually should not. Imported devices are matched by instance id, and a device that activates again with a fingerprint is not matched to an imported one, so it would take a second seat. Import without devices and let each app activate again.

What happens to Keygen keys that carry signed data?

Clavem accepts keys of 12 to 256 characters and keeps the string as written. A key that embeds a large dataset can be longer, and then it is refused. Clavem does not read or verify a Keygen signature; offline checks use its own signed token.

Do I lose anything by moving?

Keygen features that have no counterpart in the Clavem docs, such as policies, heartbeats, groups and user accounts, do not carry over. Clavem keeps a license, its limit, expiry, devices and buyer.

Sources

  1. Keygen API, the license object and list all licenses (checked November 2026)
  2. Keygen API, the machine object (checked November 2026)
  3. Keygen API, pagination (checked November 2026)
  4. Keygen API, policies (checked November 2026)
  5. Keygen API, cryptography and license key schemes (checked November 2026)