This example covers software like desktop apps (macOS or Win) and Chrome extensions that their activation is based on license keys and also any SaaS products that issue a license key to customers.
If you are integrating Freemius with a WordPress plugin, theme, or add-on, please follow the WordPress SDK integration guide.
Initial steps
- Sign up to Freemius.
- Create a new SaaS or App product tailored to your needs.
- Go to the Plans and configure the plans and prices.
For pre-purchase registration, see the Checkout integration section in the SaaS Integration doc.
Revealing License Keys to Customers
This configuration is only relevant for SaaS products. For Apps license keys are always shown to the buyers.
Go to the Settings and turn on the switch to show license keys to customers:
Checkout integration
Integrate the checkout with your buy buttons as a modal dialog triggered using JavaScript, or by using direct checkout links.
If you require registration prior to purchasing, check the Checkout integration section in the SaaS Integration doc.
License Key Integration
Create a license form in your app to validate the key.
License Activation
To activate a license key via the API:
POST https://api.freemius.com/v1/products/{product_id}/licenses/activate.json?uid={uuid}&license_key={license_key}
{uuid}
– Must be replaced with a unique 32-char identifier (you need to generate it).- You can use
crypto.randomUUID().replace(/-/g, '')
with JavaScript, which is now standard on all modern browsers and JS runtimes. Make sure to store it in the local storage where the license is activated (for Chrome extension use chrome.storage).
- You can use
{license_key}
– The entered license key
If the license key is valid, the endpoint will return an object with install_id
property.
* Make sure you store it in the local storage where the license is activated as you’ll need it for license validation and deactivation (for Chrome extension use chrome.storage).
License Deactivation
To deactivate a license via the API:
POST https://api.freemius.com/v1/products/{product_id}/licenses/deactivate.json?uid={uuid}&install_id={install_id}&license_key={license_key}
{uuid}
– Must be replaced with the stored install’s uuid{install_id}
– Must be replaced with the stored install’s ID{license_key}
– Must be replaced with the stored license key
License Validation
To validate a license, first fetch the activated license:
GET https://api.freemius.com/v1/products/{product_id}/installs/{install_id}/license.json?uid={uuid}&license_key={license_key}
{uuid}
– Must be replaced with the stored install’s uuid{install_id}
– Must be replaced with the stored install’s ID{license_key}
– Must be replaced with the stored license key
If the license is indeed activated on the specified install, the endpoint returns a License
object, which has the expiration
and is_cancelled
properties (among others).
If is_cancelled
is true
, then it means the license was canceled from the Developer Dashboard, and therefore, the license is invalid. If the license wasn’t canceled, then the expiration
will hold the license expiration date formatted as Y-m-d H:i:s
(it can also be equal to null
for lifetime licenses).