KeyKit Api Docs

A step-by-step guide to help you easily add license key generation, activation and validation to your WordPress plugins, themes or other software projects.

Start using KeyKit
Products
Create a New Product

In KeyKit, Licenses are tied to products. You can create a product on KeyKit either through your dashboard or via the api that represents your product that you want to start creating license keys for.


Once you've created a product, we will generate a unique product key that you can use to programmatically create license keys within your own code.

Product Attributes
Parameter Type Description Example
name String The name of your product "My WordPress Plugin"
  • PHP
  • Ruby
  • Curl
  • Node

  // === Creates a New Product ===
  // === Request: ===

  <?php

  $url = 'https://keykit.io/api/v1/products';

  $ch = curl_init($url);
  
  $token = YOUR_API_TOKEN; 
  $fields = json_encode(array('name'=> 'My Software'));
  
  $authorization = "Authorization: Bearer ".$token;
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json' , 
    $authorization));

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  $result = curl_exec($ch);
  curl_close($ch);

  # === Response: ===
  
  echo $result;  
  
  {
    "data": {
      "id": "19",
      "type": "product",
      "attributes": {
        "name": "My Software",
        "key": "prod_118830f35b2c0779ccac"
      }
    }
  }
  
  ?>
  

  # === Create A New Product ===
  # === With Ruby: ===
  # === Request: ===

  require 'httparty'

  url = 'https://keykit.io/api/v1/products

  body = { 
    name: "My Software"
   }

  headers = { 
    "Authorization": "Bearer #{YOUR_API_TOKEN}"
   }

  response = HTTParty.post(url, body: body, headers: headers)


  # === Response: ===

  puts response.body

  {
    "data": {
      "id": "19",
      "type": "product",
      "attributes": {
        "name": "My Software",
        "key": "prod_118830f35b2c0779ccac"
      }
    }
  }

  

  // === Create a New Product ===
  // === With Curl ===
  // === Request: ===

  curl https://keykit.io/api/v1/products \
      -H 'Authorization: Bearer "<YOUR_API_TOKEN>"' \
      -F name=My Software \

  // === Response: ===


  {
    "data": {
      "id": "19",
      "type": "product",
      "attributes": {
        "name": "My Software",
        "key": "prod_118830f35b2c0779ccac"
      }
    }
  }

  

  // === Create a New Product ===
  // === With Node ===
  // === Request: ===

  const request = require('request');

  var options = {
    method: 'POST',
    body: {
      name: 'My Software'
    },
    json: true,
    url: 'http://localhost:3000/api/v1/products',
    headers: {
      'Authorization':'Bearer <YOUR_API_TOKEN>'
    }
  };

  request(options,
      function (error, response, body) {
        console.log(response.body)
      }
  );


  # === Response: ===

  {
    "data": {
      "id": "19",
      "type": "product",
      "attributes": {
        "name": "My Software",
        "key": "prod_118830f35b2c0779ccac"
      }
    }
  }
  
Licenses
Create a New License Key

Once you have created a product (see the example above), you can start generating license keys for your software.


To generate a new license key, you will simply need to make a post request to the license key generate endpoint with your product's unique key as well as additional optional paramaters to customize your license keys.

License Key Attributes
Parameter Type Description Example
product_ref String The unique product key for the product this license key should be associated to prod_118830f35b2c0779ccac
max_activation_limit Integer The maximum number of activations allowed. If no value is set defaults to 1 1
expired_at Date Sets an expiration date on the license key. If no value provided, the key will not expire. 2020-01-01
status String By default new license keys have a status of pending. You can override this if you'd like to instead set a new default state at creation. Accepted statuses: ['pending', 'active', 'blocked', 'expired'] active
email String The customer email you want to associate to this license [email protected]
firt_name String The customer first name you want to associate to this license John
last_name String The customer last name you want to associate to this license Smith
company_name String The company name you want to associate to this license keykit
  • PHP
  • Ruby
  • Curl
  • Node

  // === Generate a new License Key For a Product ===
  // === Request: ===

  <?php

  $url = 'https://keykit.io/api/v1/licenses';

  $ch = curl_init($url);
  
  $token = YOUR_API_TOKEN; 
  $fields = json_encode(array(
    'product_ref'=> 
    'prod_118830f35b2c0779ccac'
  ));
  
  $authorization = "Authorization: Bearer ".$token;
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json', 
    $authorization));

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  $result = curl_exec($ch);
  curl_close($ch);

  # === Response: ===
  
  echo $result;  
  
  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "pending",
        "activated_at": null,
        "expired": false
      }
    }
  }
  
  ?>
  

  # === Generate a new License Key For a Product ===
  # === With Ruby: ===
  # === Request: ===

  require 'httparty'

  url = 'https://keykit.io/api/v1/licenses'
  body = { product_ref: "prod_118830f35b2c0779ccac" }
  headers = { "Authorization": "Bearer #{YOUR_API_TOKEN}" }

  response = HTTParty.post(url, body: body, headers: headers)


  # === Response: ===

  puts response.body

  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "pending",
        "activated_at": null,
        "expired": false
      }
    }
  }

  # Your new license key:
  puts response.body['data']['attributes']['key']
  # => 'a9e48217-203c-4c8a-b5cb-933fd4c95e06'
  

  // === Generate a new License Key For a Product ===
  // === With Curl ===
  // === Request: ===

  curl https://keykit.io/api/v1/licenses \
      -H 'Authorization: Bearer "<YOUR_API_TOKEN>"' \
      -F product_ref=prod_118830f35b2c0779ccac \
      -F expired_at=2020-11-01 \


  // === Response: ===

  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "pending",
        "activated_at": null,
        "expired": false
      }
    }
  }

  

  // === Generate a new License Key For a Product ===
  // === With Node ===
  // === Request: ===

  const request = require('request');

  var options = {
    method: 'POST',
    body: {
      product_ref: 'prod_118830f35b2c0779ccac'
    },
    json: true,
    url: 'https://keykit.io/api/v1/licenses',
    headers: {
      'Authorization':'Bearer <YOUR_API_TOKEN>'
    }
  };

  request(options,
      function (error, response, body) {
        console.log(response.body)
      }
  );


  # === Response: ===

  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "pending",
        "activated_at": null,
        "expired": false
      }
    }
  }
  
Licenses
Activate a License Key

To activate a license, your product will need to make a post request to the license key activate endpoint with your product's unique key as well the key for the license being activated and the domain it is being activated on. Additional optional paramaters can also be submitted.


Note: the license activate endpoint does not require your api token. Do not put your personal api token into any client-side or customer facing code.

License Key Attributes
Parameter Type Description Example
product_ref String The unique product key for the product this license key should be associated to prod_118830f35b2c0779ccac
key String The key for the license being activated
domain String The domain activating the license. https://example.com
  • PHP
  • Ruby
  • Curl
  • Node

   === Validate a License Key For a Product ===
   === Request: ===

  <?php

  $url = 'https://keykit.io/api/v1/licenses/activate';

  $ch = curl_init($url);
  
  $fields = json_encode(
    array(
      'product_ref'=> 'prod_118830f35b2c0779ccac',
      'key'=> 'a9e48217-203c-4c8a-b5cb-933fd4c95e06',
      'domain'=> 'example.com'
    )
  );

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  $result = curl_exec($ch);
  curl_close($ch);

  # === Response: ===
  
  echo $result;  
  
  {
    "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
    "valid": true,
    "status": "active",
    "message": "License key successfully activated!",    
  }


  
  ?>
  

  # === Generate a new License Key For a Product ===
  # === With Ruby: ===
  # === Request: ===

  require 'httparty'

  url = 'https://keykit.io/api/v1/licenses/activate'
  
  body = { 
    product_ref: "prod_118830f35b2c0779ccac",
    key: "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
    domain: "http://example.com"
   }

  response = HTTParty.post(url, body: body)


  # === Response: ===

  puts response.body
  
  {
    "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
    "valid": true,
    "status": "active",
    "message": "License key successfully activated!",    
  }

  if response.body['data']['valid']
    # The key is valid! Do Something
  else
    # The key is invalid! Do Something Else
  else
  

   === Validate a License Key For a Product ===
   === With Curl ===
   === Request: ===

  curl https://keykit.io/api/v1/licenses/activate \
      -F product_ref=prod_118830f35b2c0779ccac \
      -F key=a9e48217-203c-4c8a-b5cb-933fd4c95e06 \
      -F domain=example.com \


   === Response: ===

  {
    "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
    "valid": true,
    "status": "active",
    "message": "License key successfully activated!",    
  }
  

  // === Generate a new License Key For a Product ===
  // === With Node ===
  // === Request: ===

  const request = require('request');

  var options = {
    method: 'POST',
    body: {
      product_ref: 'prod_118830f35b2c0779ccac',
      key: 'a9e48217-203c-4c8a-b5cb-933fd4c95e06',
      domain: 'example.com',      
    },
    json: true,
    url: 'https://keykit.io/api/v1/licenses/activate'
  };

  request(options,
      function (error, response, body) {
        console.log(response.body)
      }
  );


  # === Response: ===
  
  {
    "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
    "valid": true,
    "status": "active",
    "message": "License key successfully activated!",    
  }

  
Licenses
Check/Validate an Existing License Key

You can check a license's status at anytime using the /licenses/check endpoint to see if a license is currently active. This can be handy if, for example, your license keys expire at a future date, or if you have manually updated a license's status from within your KeyKit account.


Note: the license check endpoint does not require your api token. Do not put your personal api token into any client-side or customer facing code.

Product Attributes
Parameter Type Description Example
product_ref String The unique product reference key for your product
key String The license key associated with the license being checked
domain String The domain being checked https://example.com
  • Ruby
  • Curl
  • Node
  • PHP

  # === Check/Validate an Existing License Key ===
  # === With Ruby: ===
  # === Request: ===

  require 'httparty'

  url = 'https://keykit.io/api/v1/licenses/check'
  
  body = { 
    product_ref: "prod_118830f35b2c0779ccac"
    key: "a9e48217-203c-4c8a-b5cb-933fd4c95e06"
   }

  response = HTTParty.post(url, body: body, headers: headers)


  # === Response: ===

  puts response.body
 
  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "active",
        "activated_at": "2019-08-04T00:00:00.000Z",
        "expired": false,
        "valid": true
        "metadata": {
          "message": "License Key Valid",
          "activated": true
        }
      }
    }
  }

  puts response.body['data']['attributes']['valid']
  # => true

  

   === Check/Validate an Existing License Key ===
   === With Curl ===
   === Request: ===

  curl https://keykit.io/api/v1/licenses/check \
      -F product_ref=prod_118830f35b2c0779ccac \
      -F key=a9e48217-203c-4c8a-b5cb-933fd4c95e06 \


   === Response: ===

  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "active",
        "activated_at": "2019-08-04T00:00:00.000Z",
        "expired": false,
        "valid": true
        "metadata": {
          "message": "License Key Valid",
          "activated": true
        }
      }
    }
  }

  

  // === Check/Validate an Existing License Key ===
  // === With Node ===
  // === Request: ===

  const request = require('request');

  var options = {
    method: 'POST',
    body: {
      product_ref: 'prod_118830f35b2c0779ccac',
      key: 'a9e48217-203c-4c8a-b5cb-933fd4c95e06',      
    },
    json: true,
    url: 'https://keykit.io/api/v1/licenses/check'
  };

  request(options,
      function (error, response, body) {
        console.log(response.body)
      }
  );


  # === Response: ===

  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "active",
        "activated_at": "2019-08-04T00:00:00.000Z",
        "expired": false,
        "valid": true
        "metadata": {
          "message": "License Key Valid",
          "activated": true
        }
      }
    }
  }
  

   === Check/Validate an Existing License Key ===
   === Request: ===

  <?php

  $url = 'https://keykit.io/api/v1/licenses/check';

  $ch = curl_init($url);
  
  $fields = json_encode(
    array(
      'product_ref'=> 'prod_118830f35b2c0779ccac',
      'key'=> 'a9e48217-203c-4c8a-b5cb-933fd4c95e06', 
      'domain'=> 'example.com'
    )
  );

  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

  $result = curl_exec($ch);
  curl_close($ch);

  # === Response: ===
  
  echo $result;  
  
  {
    "data": {
      "id": "25",
      "type": "license_key",
      "attributes": {
        "key": "a9e48217-203c-4c8a-b5cb-933fd4c95e06",
        "expired_at": null,
        "status": "active",
        "activated_at": "2019-08-04T00:00:00.000Z",
        "expired": false,
        "valid": true
        "metadata": {
          "message": "License Key Valid",
          "activated": true
        }
      }
    }
  }

  
  ?>
  

Signup and Get Started

Start using KeyKit