Popular Pages

Our Work

See some of our best, most challenging projects.

Craft CMS

We're Craft CMS experts (and an Official Partner).

How to Make Craft CMS Plugin Licenses Using the Craftnet API

Ryan Masuga Sep 5, 2018 Read time: 3 minute read
Generate License Key with Craftnet API

Need to give away a free license for a commercial plugin in the Craft CMS Plugin Store? There is no GUI at id.craftcms.com to do this, so use the Craftnet API to easily generate license keys without a purchase.

We developed Link Vault for Craft 3 and had been using it on projects for a few months before it was approved and accepted into the Craft Plugin store as a commercial plugin.

Plugins that are in the Craft Plugin Store communicate with sites on which they’re installed, so now that Link Vault was in this official plugin list (and commercial), we were presented with license key “nag notices” in our Craft control panels.

Craft Plugin License Key Nag Notice

We needed to be able to gift ourselves a few licenses to cover the sites it was in use on (we could just pay ourselves, but that feels a little Inception-y, and I don’t want to rip a hole in the space-time continuum). Further, we will want to grandfather in all the users who had bought Link Vault for Craft 2 and may want to upgrade those sites. There is currently no way to do this when logged into id.craftcms.com, so you have to use the Craftnet API to create a plugin license, which is easy to do.

New Craft ID API Token

To generate a license key without requiring a purchase, you need your Craft ID username, and an API token from your account. Under Developer Settings, click “Generate New API Token” and copy that somewhere, because when you return to the page, it will be all asterisks.

With those two pieces of information, you have enough to generate a license key. Assuming my login is masugadesign and my API Token is uurzawyghj3ebb7mp8r762h7dn8htstx8xsl7ou7, I would open a terminal window and enter:

$ curl https://api.craftcms.com/v1/plugin-licenses \
   -u masugadesign:uurzawyghj3ebb7mp8r762h7dn8htstx8xsl7ou7 \
   -d $'{
          "edition": "standard",
          "plugin": "linkvault",
          "email": "plugins@gomasuga.com"
        }'

This will generate a standard Link Vault license for the user associated with the ”plugins@gomasuga.com” email address.

The response that comes back looks like this:

{  
   "license":{  
      "id":1234,
      "pluginId":55555,
      "editionId":66666,
      "ownerId":123,
      "cmsLicenseId":null,
      "pluginHandle":"linkvault",
      "edition":"standard",
      "expirable":false,
      "expired":false,
      "autoRenew":false,
      "email":"plugins@gomasuga.com",
      "key":"IC7D12345678901234567890",
      "notes":null,
      "lastVersion":null,
      "lastAllowedVersion":null,
      "lastActivityOn":null,
      "lastRenewedOn":null,
      "expiresOn":null,
      "dateCreated":null,
      "dateUpdated":null,
      "uid":null
   }
}

If you (or the person to whom you assigned the license) look under Plugins in your Craft ID account, you will see the new license there, under Licenses > Plugins.

New License Listed Under Plugins

Enter the full license key in your Craft control panel, and the green check-mark will indicate that you're all set.

Valid Craft Plugin

Alternatives

Just yesterday, Studio Espresso released Craftnet CP plugin for Craft CMS 3.x, which is a Craft plugin that allows you to "Generate one or more licenses for a plugin." You could try this as well, but note that the author says "Note that I made this mostly for myself and that future development will take place if and when I need it. Issues and PR's will be handled on a best-effort basis."

Update: Fred Carlsen of Superbig pointed out that he also has a plugin called Craftnet CLI, which should make this process a bit nicer via the command line.

Subscribe to our newsletter!

A few times a year we send out a newsletter with tips and info related to Craft CMS, technical SEO, and things we find interesting. No spam. Unsubscribe any time.

You Might Also Like

Laravel Mix and Craft CMS

Craft CMS and Laravel Mix

Catherine Kleimeier Jul 7, 2021  ·  13 minute read

We updated our build process for Craft CMS websites from a difficult to maintain Gulp process to one that uses Laravel Mix, which is easier for us to maintain, and more easily allows us to do advanced optimization.

Organizing Craft CMS Assets

Organizing Assets in Craft CMS [New Video]

Catherine Kleimeier Jun 3, 2021  ·  1 minute read

Effective file management and organization is an often-overlooked feature of a content management system. Doing it right helps with everything from boosting SEO to saving server space. Our video demonstrates how to organize assets in Craft CMS.

Converting Google Maps to Mapbox

Converting Google Maps to Mapbox

Catherine Kleimeier May 27, 2021  ·  5 minute read

If your website has a Google Map on it that hasn't been touched in years, there's a pretty good chance that it doesn't work anymore. If your Google Map no longer works because you don't have a valid billing account, or if you want a unique (less expensive) map solution, consider switching to Mapbox! In this post, we'll show you how we did it on our own site.