Licensing API: check licence keys from your own software

amtekkie · Today

Sell software from your MyBB forum and check licence keys from the software itself. The Licensing module's API answers with signed, encrypted responses; the PHP client SDK activates keys, checks them offline-friendly and fetches updates. Other languages use the documented HTTP protocol.

In short
  • Download the SDK from MyStudio → Licensing → API & SDK
  • Answers are signed and encrypted; clients check them with the forum's public keys
  • MyStudio itself uses this API for its licence and updates

The client SDK

Download it from MyStudio → Licensing → API & SDK. It contains:

licence-config.phpAPI address, product id, the forum's public keys. No secrets.
MsLicenseClient.phpThe client: PHP 7.2+ with sodium; cURL or allow_url_fopen.
ExamplesIncluding a plugin-style settings page with a daily check and admin notice.
README.mdThe HTTP API, answer codes and fields; other languages.

Activate, check, update

$licence = new MsLicenseClient((require 'licence-config.php') + array(
    'version' => '1.4.0',
    'storage' => array(
        'get' => fn () => my_get_option('my_licence', ''),
        'set' => fn ($v) => my_set_option('my_licence', $v),
    ),
));
$licence->activate($keyTheCustomerEntered);   // once
if (!$licence->isValid()) {
    // limit features, show a notice
}
$u = $licence->update();   // latest_version, changelog, download (a one-hour link)
  • isValid() is fast: it checks the stored, signed answer locally and asks the server again only once a day by default.
  • Offline-friendly: if your forum is unreachable, the stored answer keeps working for the offline period (7 days by default), so a short outage never breaks a paying customer's site.
  • Deactivated sites stop: when the forum answers that the site isn't activated (the buyer moved the licence), the client drops its stored answer.
  • Your product decides what happens when isValid() returns false.

How answers are protected

  • Signed: every answer is signed with the forum's Ed25519 key; the client holds only the public key and rejects anything else, including an edited stored answer.
  • Encrypted: requests are sealed to the forum's key and answers to a one-time key the client sends. Encrypted requests only refuses plain ones.
  • Fresh: every request carries a random value the answer must echo, and old timestamps are refused.
  • Private keys stay in the forum's database, never in files. Rotate Keys creates new keypairs; ship the new licence-config.php afterwards.

Domain proof

A copy of your product could claim the buyer's domain. When a new server calls for a site, the answer carries a one-time code; the client serves it at https://{site}/.well-known/ms-licence/{code} and asks the forum to check. The client does this by itself. A copy on another server can't put the code on the buyer's site, so it can't pass. If the client can't write to the document root, give it a proof_dir or a proof callable.

In the forum's settings, domain proof can flag unproven servers (the default), require proof, or be off. Local development hosts and desktop installs need no proof.

Updates and releases

The update call returns the newest release the key includes, with its changelog and a one-hour download link, but only for valid licences within their update period. Releases come from the Shop product's release history, so uploading a new file in the Shop is all it takes. See the Shop and Licensing.

Make the licence worth having

No check is unbreakable in code that runs on someone else's server. Give licensed customers what a cracked copy can't: updates, support, and features or data served by your own server.

MyStudio itself uses this API for its own licence and one-click updates.