Đổi trạng thái Key
Bật/Tắt key thông qua API.
Thay đổi trạng thái Key
Sử dụng API này để Khóa hoặc Mở khóa lại key bản quyền.
PATCH /public/v1/key/{key}/status
Content-Type: application/json X-API-Key: YOUR_API_KEY
Tham số Truyền Vào
Path Parameters
| Tham số | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
key | String | ✅ | Key cần đổi trạng thái. |
Body (JSON)
| Trường | Kiểu | Bắt buộc | Mô tả |
|---|---|---|---|
status | Int | ✅ | 0 (Chưa dùng), 1 (Đang dùng), 2 (Hết hạn), 3 (Khóa key tĩnh), 4 (Khóa key động). |
Ví dụ Response
200 OK - Thành công
json
{
"message": "Key status changed successfully"
}
422 Unprocessable Entity - Status không hợp lệ
json
{
"message": "status không hợp lệ. Dùng: 0 (chưa dùng), 1 (đang dùng), 2 (hết hạn), 3/4 (khóa)"
}
403 Forbidden - Không có quyền
json
{
"message": "You don't have permission to change this key's status"
}
Ví dụ PHP (cURL)
php
<?php
$apiKey = 'YOUR_API_KEY';
$key = 'DEMO-ONCE-30D-ABCD';
$url = 'http://' . $_SERVER['HTTP_HOST'] . "/public/v1/key/{$key}/status";
$data = ["status" => 3]; // Tiến hành KHÓA key
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"X-API-Key: {$apiKey}"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
© 2026 CTDOAPIKEY Documentation