Getting started
KeyGrant works with any app, in any language. These are the steps every integration takes, with one of the SDKs or with the REST API alone.
The steps
- Sign up. Create your account. What each plan includes is on Pricing.
- Create a product for your app in Products > New product: a name, a key
prefix, a trial length and the current version. The product gets:
- an API ID, made from its name, that every request names;
- its key prefix, which every license key starts with;
- a signing key, which signs every lease, and the public key set your app carries to verify them (below).
- Add a license model, one thing you sell: on the product's License models tab, choose Add a license model. It sets its keys' type, device limit, Offline days, versions, entitlements and price. See Choosing a licensing model and License models.
- Get a license key to try, in any of these ways:
- A test license: Create test license on the product's Licenses tab.
- By hand: Licenses > Issue a license.
- From Stripe or Paddle: link your account in Settings > Payments and map a price to the model. Each paid checkout then creates a key (Selling through Stripe, Selling through Paddle).
- From your server, with a secret key from API keys (Managing licenses from your server).
- Add licensing to your app with an SDK or the REST API: see Add licensing to your app.
- Test it. Create a test license for each case you want to see (valid, expired, revoked, at its device limit and more) and run your app with it. See Testing your integration.
- Go live.
- Release builds refuse test licenses (Keep test licenses out of release builds).
- Your server uses a
kg_live_secret key, not akg_test_one. - Each model sold through Stripe or Paddle maps to its live price: test-mode and live prices, and Paddle's sandbox ones, have different IDs.
Add licensing to your app
In your app, every integration does three things: it carries your product's public key, activates the key the customer enters, and checks the license on every launch.
Choose an SDK or the REST API
Each SDK's Use it section is its quick start. The SDKs share the same calls and behave the same way (How every SDK behaves).
Any language: call the client endpoints over HTTPS, and verify the signed lease yourself with a JWT library that supports EdDSA.
Get your product's public key
Your app verifies each lease offline with your product's public keys, so every build carries them. A public key cannot create, read or revoke anything, so it is safe in your app.
- From the dashboard: Copy key set, on the product's Signing key tab, copies them as
{"keys": [...]}. - From the API:
GET /pubkeyanswers the same set, and needs no API key.my-productbelow is your product's API ID, the last part of the product page's URL in the dashboard (/app/products/my-product). - For your own verifier: the tab also shows the key that signs as SPKI and as a
.pemfile, for a standard JWT library.
curl https://api.keygrant.dev/v1/products/my-product/pubkey
Carry the whole set, each key with its id (kid). The keys change only when you rotate the
signing key, in two steps that let you ship builds carrying the next key before it signs anything: see
Rotating the signing key.
- With an SDK: pass the set to its config. In Electron: Get the public key.
- Without one: verify each lease with the key its
kidnames (Verifying without an SDK).
Activate a key
The app sends the key the customer enters to KeyGrant. KeyGrant checks it, takes one of the key's device seats for this device, and returns a signed lease: a JWT the app stores and verifies offline. A refusal says why (Activation errors).
- With an SDK: its activate call. In Electron: Activate a key.
- Without one:
POST /activate.
Check the license on launch
On every launch, the app verifies the stored lease on the device, which usually needs no network.
- A lease lasts the key's Offline days, set by its license model when the key is issued, and never runs past the key's expiry plus its grace period: see How long a lease lasts.
- Near its end, the app renews it (When the SDK goes online).
- When KeyGrant cannot be reached, your app keeps working until the lease runs out. See Offline validation & grace.
- With an SDK: its status call verifies and renews. In Electron: Check the license on launch.
- Without one: verify the lease yourself, and renew it with
POST /validate.
Next
- Testing your integration: test licenses, test API keys and test checkouts.
- Selling through Stripe: a key for each paid checkout, with no code on your side.
- Selling through Paddle: a key for each paid checkout, from a checkout page of yours.
- Managing licenses from your server: issue, extend and revoke when you bill outside Stripe or Paddle.
- Licensing by version: which versions of your app a key runs, and selling upgrades.
- SDKs: what each SDK covers, and the calls they share.