Clavem

Documentation

Free trials

Let people try your app before they buy. Your app starts the trial on its first launch, and Clavem keeps the clock, sends a reminder and counts who buys.

How it works

  1. You turn trials on for a product. Pick a length from 1 to 365 days. Optionally pick a plan for the trial. "Ask for an email" is on unless you turn it off.
  2. Your app starts the trial on its first launch. It calls POST /v1/trials/start with the product id and a fingerprint of the device. No secret, no key to type.
  3. Clavem answers with a license key that ends after your number of days. The app stores it and, from then on, checks it at every launch like any other license.
  4. When the trial ends, the license answers valid: false. Your app shows its buy screen.
  5. When the tester buys, Clavem notices. The trial is counted as converted, and you see what share of your testers buy.

A trial is a normal license with an end date. Activate, validate, the signed token and offline checks work as they do for a paid key. The status is still inactive, active or expired, so no new value appears in your code. Only a trial adds a trial object to license_key and trial: true to the token, and the responses for every other license are unchanged.

Trials are free. Pay As You Go does not charge for them. A running trial counts toward your plan's license limit like any active license, and a trial whose tester bought stops counting, so nobody is counted twice. Running trials may use at most half of your plan's licenses: the other half always stays free for the licenses you sell. A trial license has one device, the one that started it.

Turn trials on

Trials are a setting of the product. Nothing starts until you turn them on, and your app can only start one for a product that has them on.

SettingAPI and MCP nameMeaning
Trial lengthtrial_days1 to 365 days. null means trials are off, which is the default.
Plan during the trialtrial_planThe key of one of the product's plans, or null for none. The trial license is on that plan, so your app reads its features from it. A plan the trial uses cannot be removed until you point the trial elsewhere.
Ask for an emailtrial_requires_emailOn by default. On, a start without an email is refused, and each person gets one trial. Off, a trial can start from the device alone. A trial with no email gets no reminder.
Remindertrial_reminder_daysDays before the end that a tester who gave an email is reminded, 0 to 30. 0 sends none. The default is 3.
Buy linkbuy_urlAn https address, up to 500 characters, or null. It goes in the reminder email and comes back to your app with the trial, so the app can show a Buy button.

In the dashboard

Open the product and find Trials. Tick Offer a free trial, fill in the settings and save. The same section lists every trial of the product, with numbers on top. In the Licenses list a trial has a Trial badge, its end date and, once the tester has bought, the license that replaced it.

With the API

The five fields are part of the product. Create a product with them, or change them with PATCH. null clears trial_days, trial_plan and buy_url.

Turn on a 14-day trial
curl -X PATCH https://clavem.io/v1/admin/products/75 \
  -H "Authorization: Bearer sk_clavem_…" \
  -H "Content-Type: application/json" \
  -d '{
    "trial_days": 14,
    "trial_plan": "pro",
    "trial_requires_email": true,
    "trial_reminder_days": 3,
    "buy_url": "https://inkwell.example/buy"
  }'

With Claude or another MCP client

create_product, update_product and get_product carry the same five fields. Connect the MCP server and ask:

Ask Claude
Turn on a 14-day free trial for Inkwell on the Pro plan. Ask for an email, remind people 3 days before the end, and send them to https://inkwell.example/buy.

Turning trials off only stops new starts. Trials that are already running keep going until they end, and a device that already has a trial gets it back, even if you turned trials off or archived the product since. A change to the settings never touches a running trial: its end date and plan were fixed when it started.

Start a trial from your app

POST https://clavem.io/v1/trials/start needs no secret. The product id is public, like a license key, so it is safe to ship in your app. It takes a JSON or a form body, answers CORS requests from any origin, and uses the License API's flat error shape. The API reference has the parameters and every error.

NameTypeDescription
product_idinteger, requiredThe id on the product's page.
fingerprintstring, requiredA stable id for the device, up to 200 characters. How to make one.
instance_namestring, requiredA name for the device, up to 120 characters, shown to you in the dashboard.
emailstring, optionalThe tester's address. Required when the product asks for one.
Request
curl https://clavem.io/v1/trials/start \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": 75,
    "fingerprint": "90863d8344c32668298e6474aee0798ddd57bdf6c440915a4ffbd98765dd794a",
    "instance_name": "Ada'"'"'s MacBook Pro",
    "email": "ada@example.com"
  }'
Response201 Created
{
  "activated": true,
  "error": null,
  "license_key": {
    "id": 512,
    "status": "active",
    "key": "6TQ8N-X4WPD-2HJ7C-RM9AV-K3E5F",
    "activation_limit": 1,
    "activation_usage": 1,
    "created_at": "2026-11-27T09:14:02.331Z",
    "expires_at": "2026-12-11T09:14:02.331Z",
    "test_mode": false,
    "plan": "pro",
    "entitlements": { "sync": true, "seats": 5 },
    "trial": {
      "ends_at": "2026-12-11T09:14:02.331Z",
      "days_left": 14,
      "buy_url": "https://inkwell.example/buy"
    }
  },
  "instance": {
    "id": "47596ad9-a811-4ebf-ac8a-03fc7b6d2a17",
    "name": "Ada's MacBook Pro",
    "created_at": "2026-11-27T09:14:02.340Z"
  },
  "meta": {
    "store_id": 79,
    "order_id": null,
    "order_item_id": 512,
    "product_id": 75,
    "product_name": "Inkwell",
    "variant_id": 75,
    "variant_name": "Pro",
    "customer_id": 71,
    "customer_name": null,
    "customer_email": "ada@example.com"
  },
  "token": "sgt1.eyJ2IjoxLCJsaWQiOjUxMiwi…"
}

The answer is the activate response with license_key.trial added. days_left counts whole days and rounds up, so a trial that has an hour left says 1. The device is already activated, so the app stores license_key.key, instance.id and token and has nothing more to do. The token carries trial: true and, as exp, the end date.

Calling it again

Your app can call it on every launch without harm. A device never gets a second trial: the same fingerprint gets the same license back, on the same seat, with 200 instead of 201. Deleting and installing your app again does not reset the clock. It is also how a device gets its trial back after you turned trials off. After the end date, the same call answers 200 with the license as it is, expired, and activated: false.

The same device after the trial ended200 OK
{
  "activated": false,
  "error": "This license key has expired.",
  "license_key": {
    "id": 512,
    "status": "expired",
    "key": "6TQ8N-X4WPD-2HJ7C-RM9AV-K3E5F",
    "activation_limit": 1,
    "activation_usage": 1,
    "expires_at": "2026-12-11T09:14:02.331Z",
    "trial": {
      "ends_at": "2026-12-11T09:14:02.331Z",
      "days_left": 0,
      "buy_url": "https://inkwell.example/buy"
    },
    …
  },
  "instance": null,
  "meta": { … },
  "token": "sgt1.eyJ2IjoxLCJsaWQiOjUxMiwi…"
}

Answers

StatusWhenWhat your app does
201A new trial started.Store the key, the instance id and the token.
200This device already had a trial.Store them again. If activated is false, the trial is over: show the buy screen.
400A parameter is missing or malformed. The message starts with its name.Fix the request.
402Your Clavem account is paused, for example because a Pay As You Go balance ran out.Let the app run without a trial and try again later.
403Your account is at its plan's license limit, or running trials already use half of it (the body has code: "plan_limit"). A device that already has a trial still gets it.Let the app run without a trial and try again later.
404The product does not exist or has trials off, and this device has no trial.Show your buy screen.
409This email already has a trial on another device. No key is returned.Tell the person to use the device they started on, or to buy.
422The product asks for an email and none was sent.Ask for the email and call again.
429Too many requests. Retry-After: 60. Or you have 10,000 trials running (the body has code: "trial_limit" and there is no Retry-After).Try again later.
Email already used409 Conflict
{
  "activated": false,
  "error": "A trial was already started with this email address."
}

The 409 never says who has the trial and never returns its key. An email address is not proof of who someone is, so only the device that started a trial can get it back.

trial.js
const BASE = 'https://clavem.io';
const PRODUCT_ID = 75; // from your product page

// Replace with your platform's secure storage, as in the quickstart.
const store = {
  load: () => JSON.parse(localStorage.getItem('license') ?? 'null'),
  save: (value) => localStorage.setItem('license', JSON.stringify(value)),
};

// Call it when the app starts and nothing is stored. fingerprint() is one of the snippets above.
export async function startTrial(fingerprint, deviceName, email) {
  let res, body;
  try {
    res = await fetch(BASE + '/v1/trials/start', {
      method: 'POST',
      headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ product_id: PRODUCT_ID, fingerprint, instance_name: deviceName, email }), // email may be undefined
      signal: AbortSignal.timeout(8000),
    });
    body = await res.json();
  } catch {
    return { state: 'try-later' }; // offline: try again at the next launch
  }

  if (res.status === 201 || res.status === 200) {
    // A new trial, or this device's trial again. Keep the key: from now on, every launch validates it like any license.
    store.save({ licenseKey: body.license_key.key, instanceId: body.instance?.id ?? null, token: body.token });
    const trial = body.license_key.trial;
    if (body.activated) return { state: 'trial', daysLeft: trial.days_left };
    // 200 with activated: false is a trial that is over (or was switched off).
    return { state: body.license_key.status === 'expired' ? 'ended' : 'blocked', buyUrl: trial.buy_url, message: body.error };
  }
  if (res.status === 409) return { state: 'email-used' };   // that address has a trial on another device
  if (res.status === 422) return { state: 'needs-email' }; // this product asks for an email: ask, then call again
  if (res.status === 404) return { state: 'no-trial' };    // trials are off for this product: show your buy screen
  return { state: 'try-later', message: body.error };       // 402, 429 or a 5xx
}

The platform guides have the complete launch flow for Swift, Electron and Tauri. The trial start is one more call before it, when nothing is stored yet.

Make a device fingerprint

A trial belongs to a device, and the fingerprint is how Clavem knows the device. It has to be the same every time the app runs on that computer, and different on another computer. The operating system's own machine id does that. Hash it before you send it, so the raw hardware id never leaves the computer.

  • Send a hash, and add a prefix of your own before you hash, so the same computer has a different fingerprint in each of your apps.
  • Clavem compares fingerprints exactly, never loosely. For the trial it keeps only a SHA-256 hash of the product id and the fingerprint. The activation and the token's fp claim carry the fingerprint as you sent it, which is one more reason to send a hash.
  • Use the same fingerprint when the tester activates their paid key. That is how Clavem sees that the person who tried the app on this computer is the one who bought it. More below.
  • If you cannot read an id, do not make one up. A random id that is not stored gives a new trial at every launch.

No machine id is perfect. On Windows and Linux, reinstalling the operating system gives a new id. On a Mac, replacing the logic board normally does. A clone of a virtual machine can share one. Machine fingerprinting pitfalls goes through them. A tester whose id changes gets a new trial, and that is the failure to prefer over blocking a customer.

Swift on macOS

Reads IOPlatformUUID from IOKit and hashes it with CryptoKit. kIOMainPortDefault needs macOS 12 or later.

Fingerprint.swift
import CryptoKit
import Foundation
import IOKit

/// A stable id for this Mac, hashed so the raw hardware UUID never leaves it. Nil if the UUID cannot be read.
func deviceFingerprint() -> String? {
    let entry = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice"))
    guard entry != 0 else { return nil }
    defer { IOObjectRelease(entry) }
    guard let uuid = IORegistryEntryCreateCFProperty(entry, kIOPlatformUUIDKey as CFString, kCFAllocatorDefault, 0)?
        .takeRetainedValue() as? String else { return nil }
    // "inkwell:" is a prefix of your own, so the same Mac has a different fingerprint in another app.
    let digest = SHA256.hash(data: Data("inkwell:\(uuid)".utf8))
    return digest.map { String(format: "%02x", $0) }.joined()
}

Electron and Node

node-machine-id reads the machine id of the operating system: IOPlatformUUID on macOS, MachineGuid on Windows and the dbus machine id on Linux. Use it in the main process. It is a dependency of your app. Clavem needs nothing installed.

fingerprint.js
// Main process. npm install node-machine-id
import { createHash } from 'node:crypto';
import machineId from 'node-machine-id';

// node-machine-id returns a SHA-256 hash of the operating system's machine id. Hash it again with a prefix of
// your own, so the same computer has a different fingerprint in another app.
export function fingerprint() {
  return createHash('sha256').update('inkwell:' + machineId.machineIdSync()).digest('hex');
}

Tauri and Rust

The machine-uid crate returns the operating system's machine id. Hash it with sha2.

Cargo.toml
# src-tauri/Cargo.toml
[dependencies]
machine-uid = "0.5"
sha2 = "0.10"
fingerprint.rs
// src-tauri/src/fingerprint.rs
use sha2::{Digest, Sha256};

/// A stable id for this computer, hashed so the raw machine id never leaves it.
/// None if the operating system gives no machine id.
pub fn fingerprint() -> Option<String> {
    let id = machine_uid::get().ok()?;
    // "inkwell:" is a prefix of your own, so the same computer has a different fingerprint in another app.
    let digest = Sha256::digest(format!("inkwell:{id}").as_bytes());
    Some(format!("{digest:x}"))
}

Browser extensions and web apps

A browser gives a page no hardware id, and guessing one from fonts or the canvas is fragile and invasive. Store a random id the first time instead, and send that.

fingerprint.js
// Browser extension. Needs the "storage" permission. In a web page, use localStorage the same way.
export async function fingerprint() {
  const { deviceId } = await chrome.storage.local.get('deviceId');
  if (deviceId) return deviceId;
  const fresh = crypto.randomUUID(); // random, so there is nothing personal to hash
  await chrome.storage.local.set({ deviceId: fresh });
  return fresh;
}

This one resets. The id lives as long as the browser keeps the extension's or the site's data. Clearing it, or removing and installing the extension again, gives a new id and so a new trial. For these products, Ask for an email is the better limit: each address gets one trial, whatever the browser forgets.

When the trial ends

Nothing special happens in your app's code. The trial is a license, so the launch-time flow in the quickstart already handles it: validate answers 200 with valid: false, the status expired and an error to show. Expiry is evaluated when the license is read, so there is no delay between the end date passing and the API saying so, and the token carries exp for the offline check.

Validate, after the end200 OK
{
  "valid": false,
  "error": "This license key has expired.",
  "license_key": {
    "status": "expired",
    "expires_at": "2026-12-11T09:14:02.331Z",
    "trial": { "ends_at": "2026-12-11T09:14:02.331Z", "days_left": 0, "buy_url": "https://inkwell.example/buy" },
    …
  },
  …
}

To tell a trial from a purchase, look for license_key.trial. While it runs, you can show days_left. When it has ended, show your buy screen and send the person to trial.buy_url, or to your own link when you left it empty. Keep their data reachable: a trial that locks people out of their own work turns a maybe into a no.

Reading it
// After validate, in the launch-time flow from the quickstart.
const trial = body.license_key.trial; // only a trial license has it
if (trial && body.valid) showBanner(trial.days_left + ' days left in your trial');
if (trial && !body.valid) showBuyScreen(trial.buy_url ?? YOUR_BUY_URL);

From buy screen to licensed

  1. The tester buys through your Stripe, Polar, Dodo Payments or Creem checkout, as any customer does, and receives a normal license key by email.
  2. They paste it into your app. The app calls activate with the new key and the same fingerprint, stores the new key in place of the trial key and carries on, as in the quickstart.
  3. Clavem counts the trial as converted. See Conversion.

The purchase does not extend the trial key. It is a new license, and your app should accept a replacement. If you want to give someone more time instead, extend the trial: an ended trial comes back, and the app's next validate says so.

Conversion

A trial is converted when the tester buys. Clavem looks for it in two ways, and either one is enough:

  • The same email. A live license of the same product is issued to the address the trial was started with. It does not matter how: a Stripe checkout, a Polar order, a Dodo or Creem payment, the dashboard, the Admin API, MCP or an import.
  • The same device. A license of the same product that is not a trial is activated with the fingerprint the trial was started with. This catches the buyer who pays with another address, and the trial that was started without an email.

A test-mode license never converts a trial, so testing your checkout with your own address leaves the numbers alone. A trial converts once, with a trial.converted event in the activity feed, and a converted trial's dates cannot be changed any more. A refunded purchase still counts as a conversion: a refund does not undo it.

The dashboard shows the numbers on the product's Trials section. started counts the trials begun in a window (the last 90 days by default, up to 365), and active, converted, expired and disabled split those same trials. The conversion rate is converted divided by started. It is also in GET /v1/admin/trials/stats and the get_trial_stats tool. Trials that are still running have not had their chance to buy yet, so read the rate over a window that is longer than your trial.

The reminder email

A tester who gave an email gets one reminder before the trial ends. It says when the trial ends, links to your buy link if you set one, and is sent in your store's name with replies going to your support address, as the license email is.

  • When: trial_reminder_days before the end, but never before the trial is half over. A 2-day trial with the default of 3 is reminded a day before the end, not an hour after it started. The hourly job sends it, so it can be up to an hour late.
  • Who: trials started with an email that have not converted and are not disabled, on a product whose reminder is not 0. A trial without an email gets none.
  • Once. If you extend the trial, the tester gets another before the new end, as long as that reminder time is still ahead.
  • Limits: your own email address must be confirmed in Clavem, a paused account sends nothing, and one account sends at most 1,000 reminders in 24 hours. An address gets at most one reminder per day from your account.
  • Why you got this. Anyone can type any address into a trial, and Clavem does not confirm it. So every reminder says why it was sent, and that nothing else will follow.

Look at, extend and end trials

The dashboard, the Admin API and MCP do the same things, with the same rules.

WhatDashboardAdmin APIMCP tool
List trials, newest firstProduct, Trials, with a filter by statusGET /v1/admin/trialslist_trials
Started, active, converted, expired, disabled and the rateThe numbers above the listGET /v1/admin/trials/statsget_trial_stats
Give a trial more timeExtend in the listPOST /v1/admin/trials/:id/extendextend_trial
End a trial nowEnd in the listPOST /v1/admin/trials/:id/endend_trial
Add 7 days to a trial
curl https://clavem.io/v1/admin/trials/87/extend \
  -H "Authorization: Bearer sk_clavem_…" \
  -H "Content-Type: application/json" \
  -d '{ "days": 7 }'
  • Extending adds days (1 to 365) or sets the end to ends_at. Send one of them. A trial that is still running is extended from its end, and one that has ended is brought back and counts from now.
  • A trial never runs past 365 days after it started. Past that, extending answers 409 with trial_max.
  • Ending a trial expires its license at once. Extending brings it back.
  • A converted trial cannot be extended or ended: 409 with trial_converted.
  • A date without a time, such as 2027-03-31, means midnight at the start of that day, UTC, in the Admin API. In MCP it means the end of that day, UTC. Send a full timestamp such as 2027-03-31T12:00:00Z and both agree.

A trial license cannot be edited like another license. A change that extends or clears its end date, or changes its device limit, is refused with 409 and trial_license. Use extend or end. You can still disable and enable it, change its plan and move its end earlier. An import that names the key of a trial license skips it with the reason trial_license.

Limits

  • One trial per product and device. And, when a start carries an email, one per product and email. A new device with the same email gets 409.
  • This is not abuse-proof, and it cannot be. A person with a second computer, a fresh virtual machine or another email address can start another trial. Asking for an email makes it a little harder, not impossible, because the address is not confirmed. For most apps, that is a fair price for a trial that starts by itself. Free trials for desktop apps says more about how much to care.
  • At most 365 days, from the day the trial started, however often you extend it.
  • At most 10,000 running trials per account. A trial that has ended, converted or been disabled does not count. At the limit, new starts answer 429 with trial_limit, and devices that already have a trial still get theirs.
  • Rate limits: 120 requests a minute per IP address, counted separately from the other License API calls, and a stricter 10 new starts a minute per IP address, with or without an email. A device that already has its trial does not count toward the stricter one. Over a limit, the answer is 429 with Retry-After: 60.
  • Trial licenses are free. Pay As You Go does not charge for them, and a trial that ends costs you nothing. A running trial counts toward your plan's license limit; a converted one does not. At the limit, new starts answer 403 with plan_limit.
  • Trials use at most half of the plan. On a plan with a license limit, new starts also answer 403 with plan_limit once running trials reach half of it, rounded down: 50 on Free, 500 on Indie. So anonymous trial starts can never fill your plan, and the other half stays for the licenses you sell. Pay As You Go has no license limit, so only the 10,000 cap applies there.

API reference · MCP server · Offline verification