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

  1. Sign up. Create your account. What each plan includes is on Pricing.
  2. 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).
  3. 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.
  4. Get a license key to try, in any of these ways:
  5. Add licensing to your app with an SDK or the REST API: see Add licensing to your app.
  6. 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.
  7. Go live.
    • Release builds refuse test licenses (Keep test licenses out of release builds).
    • Your server uses a kg_live_ secret key, not a kg_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).

npm install @keygrant/electron

From npm

dotnet add package KeyGrant.Licensing

From NuGet

cargo add keygrant

From crates.io

https://github.com/keygrantdev/keygrant-swift.git

From GitHub

C++
GIT_REPOSITORY https://github.com/keygrantdev/keygrant-cpp.git

From GitHub

flutter pub add keygrant

From pub.dev

Any language: call the client endpoints over HTTPS, and verify the signed lease yourself with a JWT library that supports EdDSA.

POST /activate POST /validate Verifying without an SDK

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 /pubkey answers the same set, and needs no API key. my-product below 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 .pem file, for a standard JWT library.
Terminal
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.

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).

Check the license on launch

On every launch, the app verifies the stored lease on the device, which usually needs no network.

Next