Skip to content

Docs / Using Saemol

License keys and access for your app

Saemol already reads your sales. Your app only has to ask one question: may this person use it? There are two ways to ask, and you can use both.

License keyUser accounts
ForDesktop apps, games, pluginsWeb apps and SaaS with sign-in
The customerEnters a key onceSigns in as usual
Your app callsSaemol directly, with the keySaemol from your server, with an API key
You needNothing else — no server, no API key in the appA workspace API key (Developers)

Plan: every plan. Rules count against the plan's entitlement-rule limit.

1. Choose what a sale unlocks

In Entitlements → Rules, add a rule: when this item sells on a platform, unlock this product. Choose how long: for life, a number of days, or while the subscription is paid. For license keys, tick Issue a license key and set how many devices one key may run on (3 by default).

Which platforms can unlock access:

KindPlatformsWhy
Purchases and subscriptionsFastSpring, Gumroad, Hotmart, Lemon Squeezy, Paddle, Polar, Whop, WooCommerceEach sale names the buyer and the item
Subscriptions onlyStripeStripe names the buyer and the product on the subscription, not on the payment, so a Stripe rule lasts while the subscription is paid
Not at allApp Store, Google Play, Steam and other store reportsReports are totals without buyers. For these sales you can issue a key by hand

WooCommerce orders unlock access only when the order holds a single product.

2a. License keys

When a buyer's access starts, Saemol issues one key per buyer and product, such as SML-3F9A2-C81D0-7B4E9-A05C2 (test-mode keys start with SMLT-). You get it two ways:

  • the license.issued webhook (Developers → Webhooks) carries the key, so your server can email it;
  • Entitlements → License keys lists every key with a copy button.

Your app then calls Saemol with the key. No API key is involved, so nothing secret ships inside your app.

// When the customer enters their key (once per computer)
const res = await fetch('https://saemol.com/api/v2/licenses/activate', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ license_key: key, device_id: deviceId, device_name: 'Studio Mac' }),
})
const license = await res.json()
if (!license.valid) return showError(license.reason)

// Each time the app starts: the same body to /api/v2/licenses/validate
// To move to another computer: the same body to /api/v2/licenses/deactivate

With the Node SDK (@saemol/sdk 0.8.0 or later): activateLicense({ licenseKey, deviceId }), validateLicense(...), deactivateLicense(...).

device_id is any stable id you choose for the computer or install. Saemol stores only a hash of it. The customer may type the key in any case, with or without dashes.

Every well-formed request answers 200 with valid. When it is false, reason says why:

reasonMeaningWhat your app can do
not_foundNo such keyAsk the customer to check the key
no_accessThe sale behind the key no longer grants access (refunded, subscription ended)Show your purchase page
expiredA key issued by hand passed its end dateShow your purchase page
revokedYou revoked the keyContact support
device_limitThe key is active on as many devices as allowedAsk to deactivate another device, or free them in the console
not_activatedvalidate with a device the key was never activated onCall activate

A key never decides access on its own: it follows the sale. A refund that ends access ends the key; if the same buyer buys again, the same key works again. Keys are limited to 30 calls a minute each — validate when the app starts, cache the answer, and allow a grace period when the computer is offline.

Keys issued by hand (Entitlements → License keys → Issue a key by hand) are for sales Saemol cannot see: another store, an invoice, a gift. They can have their own end date, are marked by hand, and are never counted as sales.

2b. User accounts

Put your own user id where the platform keeps your data at checkout, under the name app_user_id:

PlatformWhere
Stripesubscription_data.metadata.app_user_id in Checkout, or metadata.app_user_id on the subscription
Paddlecustom_data.app_user_id on the transaction

Saemol links that buyer to your user on the next sync. It never changes a link you already made: a buyer linked to another user stays with that user. For other platforms, or if you prefer, link from your server with customers.link() right after checkout.

Then ask from your server:

import { Saemol } from '@saemol/sdk'
const saemol = new Saemol({ apiKey: process.env.SAEMOL_API_KEY })
const access = await saemol.entitlements.check({ appUserId: user.id, productId: 'PRODUCT_ID' })
if (!access.hasAccess) return deny(access.reason)

3. Check that it works

Developers → Connect your app turns step 3 green when Saemol receives the first activation or API call.

From sale to use

Entitlements → License keys shows, per platform: buyers under rules that issue keys, keys issued, keys activated on a device, and keys checked in the last 30 days. A platform where many buyers never activate is worth a look — an unclear download page, or customers who bought and forgot.

What Saemol does not do

  • It does not guess who a buyer is. A link comes from app_user_id you set, or from your own customers.link() call.
  • It does not cut access the moment a refund arrives unless your rule says so: by default the refund waits in the review queue and access stays until you decide.
  • It does not issue keys for store reports (App Store, Google Play, Steam): those have no buyers. Issue those by hand.

This guide is kept with Saemol’s code and changes when the connector does.