Create

This endpoint can be used to create License records in the database. List of parameters and example responses can be found below.

Note: The status column accepts the following values:

NumberMeaning
1Sold
2Delivered
3Active
4Inactive
5Disabled

Endpoint

POST
/wp-json/dlm/v1/licenses

Parameters

Name Type Default Is required
license_key string Yes
valid_for number Yes
status number Yes
activations_limit number Yes
order_id number No
user_id number No
product_id number No

Responses

{
    "success": true,
    "data": {
        "id": 28,
        "order_id": 39,
        "product_id": 12,
        "user_id": 1,
        "license_key": "DASK-1281-JCAJ-KMAP",
        "expires_at": "2022-07-09 21:52:17",
        "valid_for": 365,
        "source": 3,
        "status": 1,
        "times_activated": 0,
        "activations_limit": 2,
        "is_expired": false,
        "created_at": "2021-07-09 21:52:17",
        "created_by": 1,
        "updated_at": null,
        "updated_by": null
    }
}
{
    "code": "data_error",
    "message": "The license key 'DASK-1281-JCAJ-KMAP' already exists",
    "data": {
        "code": 409
    }
}

Examples

Example
use IdeoLogix\DigitalLicenseManagerClient\Service;

$api = new Service( 'http://site.com', 'ck_XXXX', 'cs_XXXX' );

$response = $api->licenses()->create([
    'order_id'          => 39,
    'product_id'        => 12,
    'user_id'           => 1,
    'license_key'       => 'DASK-1281-JCAJ-8888',
    'expires_at'        => '2022-04-05 11:00:00',
    'activations_limit' => '3',
    'status'            => 1
]);

print_r($response->get_data());
Response
Array
(
    [id] => 35
    [order_id] => 39
    [product_id] => 12
    [user_id] => 1
    [license_key] => DASK-1281-JCAJ-8888
    [expires_at] => 2022-08-28 07:00:46
    [valid_for] => 365
    [source] => 3
    [status] => 1
    [times_activated] => 0
    [activations_limit] => 3
    [is_expired] => false
    [created_at] => 2021-08-28 07:00:46
    [created_by] => 1
    [updated_at] => NULL
)
For more details please click here.