Skip to content

How to Sell Software Online with License Keys

Sell software online with license keys: issue a key per sale, check it from your app without a secret key, and turn it off after a refund or chargeback.
Selling Software12 min readBy Flint Pay, Product & API Team

Selling a desktop app, a plugin, a CLI, or a game from your own site takes three things: a checkout, a key for each buyer, and code in the app that checks the key. The checkout is the easy part. The support tickets come from what happens after: how many machines one purchase covers, what the app does on a plane, whether a refunded key keeps working, and whether a key posted on a forum can be guessed or shared.

The short answer#

On Flint, that's three pieces:

  1. A license key setting on the product. Add license_key_configuration to a digital product's variant, with a key prefix and a device limit.
  2. A checkout. Sell it through hosted checkout or a payment link. Flint issues one key for each unit the buyer pays for and emails it to them.
  3. Two calls from your app. Activate the key once per device, and validate it at launch. Neither call carries an API key, so nothing in your shipped app can read your account.

Refunds, chargebacks, and subscription cancellations turn keys off without code on your side. Your app sees the change on its next check.

Step 1: turn on generated keys#

Create a digital product with a license key setting on its variant. This one sells Lumen Pro for $49, with keys that start with LUMEN and work on up to three devices:

cURL
curl -X POST https://api.withflintpay.com/v1/products \
  -H "Authorization: Bearer $FLINT_API_KEY" \
  -H "Idempotency-Key: product-lumen-pro" \
  -H "Content-Type: application/json" \
  -d '{
    "variant_mode": "simple",
    "name": "Lumen Pro",
    "product_type": "digital",
    "default_variant": {
      "sku": "LUMEN-PRO",
      "unit_price_money": { "amount": 4900, "currency": "USD" },
      "license_key_configuration": {
        "source": "generated",
        "key_prefix": "LUMEN",
        "activation_limit": 3,
        "validity_period_days": null
      }
    }
  }'

Save data.product_id and data.default_variant.variant_id. Keys look like LUMEN-7K2QX-9RMDT-4W8PC-6HNZB-E3VYJ. Leave out activation_limit for unlimited devices, or set validity_period_days for keys that expire, such as a year of updates. License key setting lists every field.

Step 2: sell it through hosted checkout#

Create an order for the variant, then a checkout session for the order, and send the buyer to the session's url:

cURL
curl -X POST https://api.withflintpay.com/v1/orders \
  -H "Authorization: Bearer $FLINT_API_KEY" \
  -H "Idempotency-Key: order-user-4821-lumen-pro" \
  -H "Content-Type: application/json" \
  -d '{
    "line_items": [
      { "type": "variant", "variant_id": "var_1kmn0aExample", "quantity": 1 }
    ],
    "metadata": { "user_id": "user_4821" }
  }'

curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
  -H "Authorization: Bearer $FLINT_API_KEY" \
  -H "Idempotency-Key: checkout-user-4821-lumen-pro" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "order",
    "order_id": "ord_1kmn0aExample",
    "redirects": {
      "success_url": "https://example.com/thanks",
      "cancel_url": "https://example.com/pricing"
    }
  }'

Redirect to url exactly as returned. If you don't want a server call per sale, a payment link for the variant sells it from one URL. Either way, nothing about keys goes in the request. Each unit gets its own key, so a team that buys five seats gets five keys.

Keys are issued just after payment, normally within a few seconds, and Flint emails them to the order's buyer email:

  • The receipt lists each key on the order, up to 25.
  • A license key email carries any key issued after the receipt went out, and every resend.

To send your own email instead, set email_delivery_enabled: false on the setting and read each full key with POST /v1/license-keys/{license_key_id}/reveal. To show keys on your own thank-you page, wait for the license_key.created webhook, or list the order's keys with GET /v1/license-keys?order_id=... until the count matches the line's license_key_quantity, then reveal each one. order.paid can arrive before the keys exist. Lists show key_last4, never the full key, and reveal needs the commerce.license_keys.secrets.write scope. Sell with hosted checkout covers the order and checkout steps in full.

Step 3: activate the key from your app#

When the buyer pastes their key into the app, activate it. There's no Authorization header: the app sends the key and the product IDs it accepts, which you compile into the build.

cURL
curl -X POST https://api.withflintpay.com/v1/license-key-activations \
  -H "Idempotency-Key: 3f6c1a52-activate" \
  -H "Content-Type: application/json" \
  -d '{
    "product_ids": ["prod_1kmn0aExample"],
    "key": "LUMEN-7K2QX-9RMDT-4W8PC-6HNZB-E3VYJ",
    "name": "Studio MacBook Pro",
    "fingerprint": "9f2c6f0e7d1b4a53"
  }'

name is what you and the buyer see in device lists, so use the machine's name. fingerprint identifies this installation, such as a hash of the machine ID. A new device returns 201 and uses a slot. If an active activation on the key already has the same fingerprint, Flint returns it with 200, so reinstalling on the same machine doesn't use a second slot. Store the returned license_key_activation_id next to the key.

ResponseWhat to tell the buyer
404 RESOURCE_NOT_FOUND at keyThe key isn't valid for this app. Check it was typed correctly.
409 ACTION_NOT_ALLOWED, reason unsupported_stateThe key is disabled or expired.
409 LIMIT_REACHED, reason license_key_activationsEvery device slot is in use. Sign out another device first.

When one app is sold as several products#

If you sell the same app as Standard and Pro, or as yearly and lifetime, put every product ID in product_ids, up to 20. Any key for one of them activates, and the response's product_id and variant_id tell the app which one it is, so it knows which features to unlock. A key for a product the app doesn't list answers like a key that doesn't exist, so a key for your other app doesn't open this one.

Test builds list your sandbox product IDs. Sandbox keys start with TEST- and only work against sandbox products.

Step 4: validate at launch, and keep working offline#

On each launch, send the key and the stored activation ID:

cURL
curl -X POST https://api.withflintpay.com/v1/license-keys/validate \
  -H "Content-Type: application/json" \
  -d '{
    "product_ids": ["prod_1kmn0aExample"],
    "key": "LUMEN-7K2QX-9RMDT-4W8PC-6HNZB-E3VYJ",
    "license_key_activation_id": "lka_1kmn0aExample"
  }'

A completed check returns 200 whether the key works or not:

JSON
{
  "data": {
    "is_valid": false,
    "invalid_reason": "disabled",
    "status": "disabled",
    "license_key_id": "lk_1kmn0aExample",
    "product_id": "prod_1kmn0aExample",
    "variant_id": "var_1kmn0aExample",
    "activation_limit": 3,
    "active_activation_count": 1,
    "expires_at": null
  }
}

Read is_valid. When it's false, invalid_reason is one of not_found, disabled (refunded, disputed, canceled, or turned off by you), expired, or activation_not_found (this device was signed out, so activate again).

A failed check is different from an invalid key. Treat network errors, 429, and 5xx as "couldn't check": keep the last answer and when you got it, and let the app run on it for a grace period you choose. A request your app built wrong, any other 4xx, should fail loudly in testing instead.

TypeScript
const VALIDATE_URL = "https://api.withflintpay.com/v1/license-keys/validate";
const PRODUCT_IDS = ["prod_1kmn0aExample", "prod_1kmn0bExample"]; // Standard, Pro
const GRACE_MS = 7 * 24 * 60 * 60 * 1000; // A week without a successful check.

type Stored = { key: string; activationId: string; lastValid: boolean; checkedAt: number };

const lastAnswer = (stored: Stored) => ({
  allowed: stored.lastValid && Date.now() - stored.checkedAt < GRACE_MS,
  stored,
});

export async function checkLicense(stored: Stored): Promise<{ allowed: boolean; stored: Stored }> {
  let response: Response;
  try {
    response = await fetch(VALIDATE_URL, {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        product_ids: PRODUCT_IDS,
        key: stored.key,
        license_key_activation_id: stored.activationId,
      }),
    });
  } catch {
    return lastAnswer(stored); // Offline or unreachable.
  }
  if (response.ok) {
    const { data } = await response.json();
    const next = { ...stored, lastValid: data.is_valid === true, checkedAt: Date.now() };
    return { allowed: next.lastValid, stored: next };
  }
  if (response.status === 429 || response.status >= 500) return lastAnswer(stored);
  throw new Error(`License check failed with HTTP ${response.status}`);
}

Store checkedAt somewhere the buyer can't trivially edit, and check again in the background on long sessions rather than only at launch.

Step 5: release a device#

Buyers replace laptops. Give them a "Sign out this device" button that frees the slot:

cURL
curl -X POST https://api.withflintpay.com/v1/license-key-activations/lka_1kmn0aExample/release \
  -H "Content-Type: application/json" \
  -d '{
    "product_ids": ["prod_1kmn0aExample"],
    "key": "LUMEN-7K2QX-9RMDT-4W8PC-6HNZB-E3VYJ"
  }'

For a buyer who no longer has the old machine, your server can list a key's devices with GET /v1/license-key-activations?license_key_id=lk_1kmn0aExample and release one with your API key. In a customer account you build, a signed-in buyer can list their keys with GET /v1/me/license-keys, see their devices, and release one themselves.

What happens on a refund or chargeback#

Flint disables keys when a sale is reversed. A disabled key still exists: its devices stay activated, validate answers disabled, and access comes back if the key is reinstated.

What happensWhat Flint does to the keys
A refund that returns units of a one-time saleDisables that many of the line's keys
A full refund of a one-time orderDisables every key on it
A refund that failsPuts the keys back
A chargeback opensDisables every key on the order while it's open
You win the chargebackReinstates them
You lose the chargebackKeeps them disabled
A subscription is paused or canceledDisables its keys; they stay on through past_due

A partial refund picks keys still waiting for stock first, then keys already disabled, then keys with no active device, then the highest-numbered. To choose which keys it turns off, disable those keys before you refund. For a one-off exception, such as a key you disabled for abuse that turns out to be fine, POST /v1/license-keys/{license_key_id}/reinstate lifts every restriction in force. The license_key.disabled and license_key.updated webhooks tell your server when either happens.

Subscription plans can sell generated keys too. Keys are issued when the subscription becomes trialing or active and follow it from then on, which suits "a license while you pay" pricing. Refunding one of a subscription's payments doesn't touch its keys, though a chargeback does, so cancel the subscription to end access.

Selling keys you already hold: pools#

Some sellers don't generate keys. A game developer gets Steam keys from Steamworks; a reseller gets keys from a publisher. A key pool holds keys you upload, and its unsold keys are the variant's stock.

cURL
curl -X POST https://api.withflintpay.com/v1/license-key-pools \
  -H "Authorization: Bearer $FLINT_API_KEY" \
  -H "Idempotency-Key: pool-lumen-steam" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Lumen Steam keys", "low_stock_threshold": 50 }'

curl -X POST https://api.withflintpay.com/v1/license-key-pools/lkp_1kmn0aExample/keys \
  -H "Authorization: Bearer $FLINT_API_KEY" \
  -H "Idempotency-Key: pool-lumen-steam-batch-1" \
  -H "Content-Type: application/json" \
  -d '{
    "seller_authorization_confirmed": true,
    "keys": ["AAAAA-BBBBB-CCCCC", "DDDDD-EEEEE-FFFFF"]
  }'

seller_authorization_confirmed is required on every upload. It confirms that the rights holder lets you sell these keys, and Flint records who confirmed it, when, and how many keys were sent. Upload up to 1,000 keys per request; a key already in one of your pools comes back as existing, so a retried batch doesn't add duplicates. Then point a one-time digital variant at the pool with "source": "pool" and "license_key_pool_id": "lkp_1kmn0aExample".

Checkout refuses a sale the pool can't fill before the buyer pays. Flint checks stock when units are added to an order and when checkout starts, returning 409 INVENTORY_INSUFFICIENT when there aren't enough keys, and reserves one key per unit when payment starts. An abandoned or failed payment puts its keys back. If an order is paid without a reservation while the pool is empty, its key is pending until your next upload fills it, and Flint emails it then. Flint sends license_key_pool.low_stock when stock falls to your threshold and license_key_pool.out_of_stock at zero.

Pool keys don't answer your app's uncredentialed checks until you turn on public_validation_enabled on the pool, which needs every key in it to be at least 16 characters. Leave it off for keys another store checks, such as Steam keys. Disabling a Steam key after a refund changes what Flint's validate returns, not whether Steam still accepts it, so a refunded pool key is never sold again but may still redeem on Steam.

What sellers get wrong#

Keys that can be guessed#

A key is a password the buyer pays for. Keys built from a counter, a short random string, or a hash of the buyer's email can be enumerated or rebuilt, and a validation endpoint that answers quickly lets someone try thousands an hour.

Flint's generated keys are 25 characters drawn at random from a 32-character alphabet, which is 125 random bits; the prefix carries none. Buyers can type a key in lowercase, and an O or I typed by mistake reads as 0 or 1. On the validation side, not_found is one answer for a mistyped key, another merchant's key, and a key for a product your app doesn't list, so the response gives nothing away. Without a credential, Flint refuses an IP address for the rest of a 10-minute window after 10 keys not found, alongside per-IP and per-key rate limits. Validate a license key lists every limit.

The other common leak is the reverse: shipping a secret API key inside the app so it can check keys. Anyone can pull a string out of a binary. Flint's activate, validate, and release calls take no credential, so there's nothing to extract.

Activation limits that are missing or too tight#

With no limit, one key posted on a forum unlocks every copy. With a limit of one, every reinstall, new laptop, or OS upgrade becomes a support email. Two or three devices per key, a fingerprint that survives reinstalls, and a release button in the app cover most buyers. For a customer who needs more, raise one key's limit with PATCH /v1/license-keys/{license_key_id} and a new activation_limit instead of issuing a second key.

Locking out paying buyers when the check fails#

An app that treats "couldn't reach the server" as "invalid key" locks out paying buyers on flights, behind corporate proxies, and during any outage. Separate the two: a 200 with is_valid: false is an answer, a timeout isn't. Pick a grace period, keep the last good answer, and count from the last successful check.

Some sellers go the other way and sign keys offline with a private key, so the app never calls a server. Those keys can't be turned off after a refund or a leak, because nothing tells the app the key changed. An online check with an offline grace period gets you both.

Refunded keys that keep working#

A refund in a payment dashboard doesn't reach your license server unless you wrote the code that connects them, and a chargeback, which can land weeks after the sale, is easier still to miss. While a chargeback is open, the buyer has the money back and, without that code, still has the software. On Flint, both turn the key off on the app's next check, and winning the chargeback turns it back on.

Selling keys you aren't allowed to sell#

Selling your own software is an ordinary business. Reselling someone else's is not unless they've authorized it. Flint processes cards on Stripe, and Stripe's restricted businesses list prohibits "sales or distribution of music, movies, software, or any other licensed materials without appropriate authorization". Keys bought cheaply in one region and resold elsewhere, or keys with no paper trail from the publisher, can fall under that. If you sell keys from a pool, keep the agreement that lets you, because seller_authorization_confirmed records that you said you had it.

Test it#

Run the whole flow in your sandbox:

  1. Create the product with your sandbox API key and pay for it with a test card. The key arrives in the receipt and starts with TEST-.
  2. Activate it from a test build that lists your sandbox product ID, then validate it.
  3. Activate the same fingerprint again and check you get 200, not a second slot. Then fill every slot and check the next device gets 409 LIMIT_REACHED.
  4. Turn off networking and check the app keeps running on its last answer.
  5. Refund the order and check validate answers disabled.
  6. Pay a new order with the dispute test card in Simulate a dispute outcome, check the key is disabled, then simulate a won ruling and check it's valid again.

Sell software license keys has every request above with its options, and License keys has the full API reference, including key rotation for a leaked key and resending the email.

Sign up for a sandbox and issue your first license key there. The sandbox is free.

FAQ#

Do I need a merchant of record to sell software online?#

No. On Flint your business is the seller, and your name is on the charge and the receipt. Automatic tax calculates and collects US sales tax, and tax on digital goods and software sold to Canada, the EU, the UK, Australia, and New Zealand wherever you add a registration. You register and file. A merchant of record files tax as the seller instead, and most don't allow physical goods.

Can my app check a license key without an API key?#

Yes. Activate, validate, and release take the key and your product IDs with no Authorization header, and nothing the app sends can read or change your account. Rate limits and a single not_found answer keep the endpoint from being used to guess keys.

What happens to the license key when a buyer gets a refund?#

On a one-time sale, a refund that returns units disables that many keys, and a full refund disables all of them. A chargeback disables every key on the order while it's open, and winning it reinstates them. A subscription's keys turn off when it's paused or canceled. Your app sees is_valid: false with invalid_reason: "disabled" on its next check.

Can I sell Steam keys or other game keys?#

Yes, from a key pool, when the rights holder lets you sell them. Each upload confirms that authorization. Flint holds stock, refuses checkout when the pool is empty, and emails each key. Flint can't revoke a key on Steam after a refund.

Can I give a customer more devices?#

Yes. Change one key's activation_limit with PATCH /v1/license-keys/{license_key_id}, or release an old device for them from your server.

How much does Flint cost?#

Card payments cost 3.79% + 35¢ with no monthly fee. Payments that start or renew a subscription add 0.40%, automatic tax adds 0.50% on payments that carry tax, and cards issued outside the US add 1.50%. The sandbox is free. Pricing has the full rate card.

Sources#

Third-party facts above were checked on 2026-11-18.

  • Stripe restricted businesses: "Sales or distribution of music, movies, software, or any other licensed materials without appropriate authorization" is listed under products and services that infringe on intellectual property rights.