Invalid License API Errors

Problem

When using the WHMCS API, you see the following error:

<result>error</result>
<message>Your license key is invalid</message>

Cause

This issue occurs when you perform a required license check from a non-web context (for example, the command line interface or a cron job) and the server’s outbound IP address is different than the license’s IP address.

WHMCS offers both external and internal APIs. This error typically occurs when you did not choose the correct API to use.

  • Use the internal API in a web context within WHMCS files, hooks, modules, and custom pages.
  • Use the external API in non-web contexts and from any other locations.

Solution

In most cases, daily usage of the Admin Area (a web context) will ensure that a recent license response is valid for short-term use in non-web contexts. If you see this error, however, your installation may not be undergoing daily use.

For non-web contexts, we recommend making API calls remotely against the website instead of using the localAPI helper function. This ensures that your calls perform any required license check relative to the website request. The license check will reference your website’s specific IP address instead of the general outbound IP address of your website’s server.

This requires changing your script to send HTTP requests to the API endpoint at https://example.com/whmcs/includes/api.php, where example.com is the licensed valid domain and whmcs is the licensed valid directory.

For more information, see Authentication.

Last modified: November 12, 2024