API Reference

Automate your license management - create clients, licenses and products, and search your entire database programmatically

Overview

LicenTra provides a REST-like API for complete automation of your license management workflow. The API allows you to add and edit banned hosts, clients, installations, licenses and products, and to search across all record types - all from your own external tools, scripts or websites.

The API is disabled by default and can be turned on in Settings » Security (API_STATUS in the database). It is also possible to enable whitelisted access, which only allows API calls coming from whitelisted IP addresses (Settings » Advanced).

All requests are made with HTTP POST to the central entry point. Requests are only accepted from automated User-Agents (LicenTra Custom Post or LicenTra cURL) - browsers are not able to call the API directly.

Authentication

Every API request must include a valid API key secret. API keys are created and managed in the administration dashboard under API Keys:

Request Format

Send an HTTP POST request to the central API entry point:

https://www.yourdomain.com/apl_api/api.php

Every request requires these common parameters:

Parameter Description
api_key_secret* Your API key secret (created in API Keys section of the dashboard).
api_function* Name of the API function to execute. Must match one of the available endpoints.
submit_ok* Must equal Submit.
...data fields Function-specific fields documented for each endpoint below.

Fields marked by * are required. The api_post_key, referer and User-Agent checks are added automatically by the /apl_api/api.php proxy itself - you only need to submit the parameters above.

Important!

The API is a proxy. It validates your API key and re-sends the request to the function-specific file (clients_add.php, licenses_add.php, etc.). Always target the proxy at /apl_api/api.php - do not call the individual function files directly.

Response Format

Every API call returns a JSON-encoded object:

{
    "api_action_success": 1,
    "api_error_detected": 0,
    "action_success": 1,
    "error_detected": 0,
    "page_message": "Client John Doe (john@example.com) added."
}

Response keys:

Key Description
api_action_success 1 when the API key was validated and the request was forwarded, 0 otherwise.
api_error_detected 1 when authentication failed (invalid API key, IP not allowed, missing permissions, API disabled).
action_success 1 when the actual operation (add/edit/search) succeeded, 0 otherwise.
error_detected 1 when the operation failed (validation error, duplicate record, database error, no results).
page_message Result message. Contains a human-readable success text, or the list of errors. For the search function it contains the result array (see Search).

Endpoints

All endpoints are called through the proxy /apl_api/api.php with api_function set to the endpoint name.

clients_add, clients_edit

Parameter Required Description
client_fname Yes Client first name.
client_lname Yes Client last name.
client_email Yes Client email address (must be unique - personal licenses are linked to it).
client_status Yes Client status: 0 inactive, 1 active, 2 unknown.
client_id For clients_edit ID of the client to edit.

licenses_add, licenses_edit

Parameter Required Description
product_id Yes ID of the product the license belongs to.
client_id For personal licenses ID of the client. Must be empty for anonymous (code-based) licenses.
license_code For anonymous licenses License code. Must be empty for personal (email-based) licenses.
license_require_domain Yes Whether the license is bound to a domain: 0 or 1.
license_status Yes License status: 0 cancelled, 1 active, 2 suspended.
license_id For licenses_edit ID of the license to edit.
license_order_number No Order number.
license_ip No Comma-separated list of allowed IP addresses.
license_domain No Comma-separated list of allowed domains.
license_limit No Maximum number of concurrent installations (defaults to 0 = unlimited).
license_expire_date No License expiration date in Y-m-d format. Empty for lifetime licenses.
license_updates_date No Updates expiration date in Y-m-d format.
license_support_date No Support expiration date in Y-m-d format.
license_comments No Additional comments.

products_add, products_edit

Parameter Required Description
product_title Yes Product title (must be unique).
product_sku Yes Product SKU (must be unique).
product_status Yes Product status: 0 inactive, 1 active, 2 unknown.
product_id For products_edit ID of the product to edit.
product_description No Product description.
product_url_homepage No Homepage URL (used for version check reports).
product_url_download No Download URL (returned to clients with the latest version by version check).
product_version No Current product version (returned by version check).
product_envato_id No Envato item ID used by the Envato Purchase Verification plugin.

installations_edit

Parameter Required Description
installation_id Yes ID of the installation to edit.
installation_status Yes Installation status: 0 inactive, 1 active, 2 unknown.

banned_hosts_add, banned_hosts_edit

Parameter Required Description
banned_host_ip Yes IP address to ban (must be unique).
banned_host_id For banned_hosts_edit ID of the banned host to edit.
banned_host_comments No Reason or notes.

Examples

Add a client

curl -X POST https://www.yourdomain.com/apl_api/api.php \
  -d "api_key_secret=YOUR_API_KEY_SECRET" \
  -d "api_function=clients_add" \
  -d "submit_ok=Submit" \
  -d "client_fname=John" \
  -d "client_lname=Doe" \
  -d "client_email=john@example.com" \
  -d "client_status=1"
{"api_action_success":1,"api_error_detected":0,"action_success":1,"error_detected":0,"page_message":"Client John Doe (john@example.com) added."}

Add an anonymous (code-based) license

curl -X POST https://www.yourdomain.com/apl_api/api.php \
  -d "api_key_secret=YOUR_API_KEY_SECRET" \
  -d "api_function=licenses_add" \
  -d "submit_ok=Submit" \
  -d "product_id=1" \
  -d "license_code=ABC123XYZ" \
  -d "license_require_domain=0" \
  -d "license_status=1" \
  -d "license_limit=3" \
  -d "license_expire_date=2027-01-01" \
  -d "license_updates_date=2027-01-01" \
  -d "license_support_date=2027-01-01"

Search for a license

curl -X POST https://www.yourdomain.com/apl_api/api.php \
  -d "api_key_secret=YOUR_API_KEY_SECRET" \
  -d "api_function=search" \
  -d "submit_ok=Submit" \
  -d "search_type=license" \
  -d "search_keyword=ABC123"

PHP example

//example API call using cURL in PHP
$api_url="https://www.yourdomain.com/apl_api/api.php";
$post_data=array(
    "api_key_secret"=>"YOUR_API_KEY_SECRET",
    "api_function"=>"clients_add",
    "submit_ok"=>"Submit",
    "client_fname"=>"Jane",
    "client_lname"=>"Smith",
    "client_email"=>"jane@example.com",
    "client_status"=>1
    );

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_USERAGENT, "LicenTra Custom Post"); //API only accepts automated user agents
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response=curl_exec($ch);
curl_close($ch);

$result_array=json_decode($response, true);
if (!empty($result_array['action_success'])) //operation succeeded
    {
    echo $result_array['page_message'];
    }
else
    {
    echo "Error: " . $result_array['page_message'];
    }