Skip to main content

Activate a license

POST 

https://api.freemius.com/v1/products/{product_id}/licenses/activate.json


Activate a license and if needed, create an install with the given properties.

No Authorization header is required. If the provided license doesn't have an associated user, the endpoint will require the first_name, last_name, and user_email parameters to create a new user and associate it with the license.

This endpoint can return the following error codes:

  • license_expired: License has already expired.
  • invalid_license_key: License key is invalid (e.g., does not match any record).
  • license_error: General error while validating the license.
  • license_utilized: License quota has reached maximum capacity.
  • license_activated: License is already activated on the given install. This usually indicates your app is out of sync with Freemius. You may accept the license and grant premium features. If needed, re-establish the connection by calling the deactivation endpoint and activating again.

All errors include a descriptive message from the API, which you may choose to display to the user. For example:

  • license_expired: Your license has expired on 2025-01-01 (id = 12345).
  • invalid_license_key: Invalid license key.
  • license_error: License activation is not authorized for the site(s) listed below. Please follow the provided link to whitelist the site(s) from the User Dashboard.
  • license_activated: License is already activated on install 12345.
  • license_utilized: Your license quota of 1234 production site(s) has been reached. If you believe this is a mistake, please contact support at [email protected].

You can get the error code from the response.error.code. For example

fetch(activationEndpoint).then((response) => {
return response.json();
}).then((data) => {
if (data.error) {
// Error detected
const errorCode = data.error.code;
const errorMessage = data.error.message;
// handleError(errorCode, errorMessage);
} else {
// Operation successful
}
}).catch((error) => {
// Handle network error
});

Request

Path Parameters

    product_id integer<int64>required

    The ID of the product.

    Possible values: >= 1

    Example: 1234

Bodyrequired

    uidstring<uid>required

    Unique identifier of the caller. The UID must be same when pinging and when activating or deactivating a license. The generation of the UID is a responsibility of the client.

    Possible values: >= 32 characters and <= 32 characters

    Example: 7W131pej6bJYV8WYM9KgGoBNB9bCiSrY
    license_keystringrequired

    The license key. This is used for activating the license on the user's site.

    Example: sk_123FGqM456Pa786WtOp%^+67Y+;sXXz
    urlstring

    Site's homepage URL.

    titlestring

    Site's title.

    versionstring

    Product's version.

    is_marketing_allowedbooleannullable

    Whether or not the user has given their consent for marketing materials. A null value indicates that the user has not made a decision yet.

    install_idinteger

    Install ID when activating on an already existing install. If provided must belong to the same user as the license owner and must have the same UID. The new license will be activated for the install and existing one will be deactivated.

    first_namestring

    First name of the user (only needed when activating a ghost license).

    last_namestring

    Last name of the user (only needed when activating a ghost license).

    user_emailstring

    Email address of the user (only needed when activating a ghost license).

    allow_unreleased_plan_activationboolean

    Whether to allow license activation if the plans of the product has not been released yet. Useful for testing purpose only.

Responses

License activated successfully.

Schema
user_idstring<int64>

The unique identifier of the entity.

Possible values: >= 1

Example: 123456
user_secret_keystring

The secret key associated with the entity for authorization.

Example: sk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
user_public_keystring

The public key associated with the entity for authorization.

Example: pk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
plugin_idstring<int64>

The unique identifier of the entity.

Possible values: >= 1

Example: 123456
license_plan_namestring<slug>

The name of the plan. Only lowercase characters allowed.

Example: professional
license_plan_idstring<int64>

The ID of the plan associated with the entity.

Possible values: >= 1

Example: 123456
license_pricing_idstring<int64>nullable

The ID of the pricing associated with the entity.

Possible values: >= 1

Example: 123456
is_marketing_allowedbooleannullable

Whether or not the user has given their consent for marketing materials. A null value indicates that the user has not made a decision yet.

install_idstring<int64>

The unique identifier of the entity.

Possible values: >= 1

Example: 123456
install_secret_keystring

The secret key associated with the entity for authorization.

Example: sk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
install_public_keystring

The public key associated with the entity for authorization.

Example: pk_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
install_api_tokenstring

The API access token with which authenticated requests can be made for this install entity. You need to set this token as the Bearer token in the Authorization header. For example:

Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9

Example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9
We use essential cookies to enable our site to function. With your consent, we also use analytics and advertising cookies to understand how visitors interact with our site and to improve our services.
Learn More