Tạo Key nhiều lần

API tạo key kích hoạt nhiều lần.

Tạo key kích hoạt nhiều lần (Multi-use)

API này cho phép tạo key có thể kích hoạt nhiều lần trên nhiều thiết bị khác nhau (giới hạn bởi activateCount).

POST /public/v1/key/multiple-activate
Content-Type: application/json
X-API-Key: YOUR_API_KEY

Tham số (Request Body)

TrườngKiểuBắt buộcMô tả
quantityIntSố lượng key cần tạo (1 - 100).
packageIdsArrayMảng ID các package.
durationIntThời hạn (ví dụ: 30).
unitStringhour, day, week, month, year.
activateCountIntSố lượng thiết bị tối đa được dùng chung 1 key này.
aliasStringPrefix cho key.

Ví dụ Response

201 Created - Thành công

json
{
  "message": "Create key successfully",
  "data": [
    "DEMO-30D-XYZ789..."
  ]
}

401 Unauthorized - Sai / Thiếu API Key

json
{
  "message": "API key is required"
}

Ví dụ PHP (cURL)

php
<?php
$apiKey = 'YOUR_API_KEY';
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/public/v1/key/multiple-activate';
$data = [
    'quantity' => 1,
    'packageIds' => [5],
    'duration' => 6,
    'unit' => 'month',
    'activateCount' => 10,
    'alias' => 'vip-group'
];

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => $url,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-API-Key: ' . $apiKey
    ],
]);

$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

echo "HTTP Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
?>

© 2026 CTDOAPIKEY Documentation