Quy Chuẩn Xác Thực & HTTP Headers
Mọi request tương tác với hệ sinh thái Cloud VPS qua chuẩn Agency cần bộ 3 thông số định danh tài khoản kết nối:
| Header / Field | Loại | Ý nghĩa | Ví dụ |
|---|---|---|---|
| api-username | String | Tên tài khoản đại lý | user_1_7b89f2a |
| api-app | String | Mã ứng dụng (App Key) | app_9d28e71c03... |
| api-secret | String | Mã bí mật (Secret Key) | sec_4f910a28b6... |
| api-token | String | Token xác thực nhận được từ endpoint get-token (Hạn 24h) | eyJhbGciOi... |
api-secret trên frontend HTML/JS. Tất cả request tạo đơn hoặc thao tác VPS cần gọi từ Server-to-Server.
Lấy Auth Token
POSThttps://www.host.tunthui.shop/api/agency/get-token
Request Body (JSON hoặc Form URL-encoded):
{
"api-username": "your_agency_user",
"api-app": "app_xxxxxxxxxxxxxxxx",
"api-secret": "sec_yyyyyyyyyyyyyyyy"
}
Response mẫu:
{
"status": true,
"code": 200,
"message": "Xác thực tài khoản thành công!",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expire_at": 1735689600
}
Thông Tin Đại Lý & Số Dư
GEThttps://www.host.tunthui.shop/api/agency/get-info
HTTP Headers yêu cầu:
api-username: your_agency_user api-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Response mẫu:
{
"status": true,
"code": 200,
"data": {
"username": "reseller_pro",
"balance": 5250000,
"discount": 10,
"rank": "Đại lý Gold",
"total_vps_active": 18
}
}
Danh Sách Gói Cước, OS & Chu Kỳ
GET| Gói VPS | Cấu hình chuẩn | Giá gốc / Tháng | Chiết khấu Đại lý |
|---|---|---|---|
| Cloud VPS 1 | 2 vCPU, 2GB RAM, 30GB SSD NVMe | 120.000 VNĐ | Tự động áp dụng theo cấp bậc |
| Cloud VPS 2 | 2 vCPU, 4GB RAM, 40GB SSD NVMe | 190.000 VNĐ | Tự động áp dụng theo cấp bậc |
| Cloud VPS 3 | 4 vCPU, 4GB RAM, 50GB SSD NVMe | 250.000 VNĐ | Tự động áp dụng theo cấp bậc |
| Cloud VPS 4 | 4 vCPU, 8GB RAM, 70GB SSD NVMe | 370.000 VNĐ | Tự động áp dụng theo cấp bậc |
| Cloud VPS 5 | 6 vCPU, 12GB RAM, 90GB SSD NVMe | 550.000 VNĐ | Tự động áp dụng theo cấp bậc |
| Cloud VPS 6 | 8 vCPU, 16GB RAM, 120GB SSD NVMe | 750.000 VNĐ | Tự động áp dụng theo cấp bậc |
Tạo Đơn Hàng Đặt Mua Cloud VPS
POSThttps://www.host.tunthui.shop/api/agency/order/create-order
| Tham số | Kiểu | Bắt buộc | Ý nghĩa & Giá trị |
|---|---|---|---|
| product_id | Int | Có | ID gói Cloud VPS (1, 2, 3, 4, 5, 6) |
| os_id | Int / String | Có | Mã OS (Windows 10, Server 2012/2016/2019/2022, Ubuntu 20/22) |
| billing_cycle | Int | Có | Chu kỳ: 1 (1 tháng), 3, 6 hoặc 12 |
| cpu_more | Int | Không | Số vCPU mua thêm (1 ĐV = 1 Core) |
| ram_more | Int | Không | Số GB RAM mua thêm (1 ĐV = 1 GB) |
| disk_more | Int | Không | Số GB NVMe mua thêm (1 ĐV = 10 GB) |
Response khởi tạo thành công:
{
"status": true,
"code": 200,
"message": "Khởi tạo Cloud VPS thành công!",
"data": {
"vps_id": 10842,
"ip_address": "103.179.189.45",
"username": "Administrator",
"password": "VpsPassword#9821",
"os": "Windows Server 2019 Datacenter",
"specs": "2 vCPU / 4GB RAM / 40GB SSD NVMe",
"expire_date": "2026-10-30 17:00:00",
"total_paid": 171000
}
}
Thao Tác & Điều Khiển VPS
POSThttps://www.host.tunthui.shop/api/agency/vps/action-vps
Tất cả hành động điều khiển máy chủ được gom vào endpoint trên với tham số action:
Gửi lệnh bật máy chủ VPS khi đang ở trạng thái tắt.
Gửi lệnh Shutdown máy chủ VPS an toàn.
Reboot hệ thống VPS tức thì trong 15-30 giây.
Cài lại trắng hệ điều hành (yêu cầu thêm tham số os_id).
Gia hạn thời gian sử dụng VPS (yêu cầu billing_cycle).
Áp dụng trong vòng 24 giờ đầu kể từ khi khởi tạo gói.
Mở Nested Virtualization hỗ trợ chạy giả lập Android, Docker, WSL.
Chuyển sang cụm máy chủ chuyên dụng chip Intel Xeon Platinum.
Ví dụ payload khởi động lại:
{
"vps_id": 10842,
"action": "restart"
}
Quản Lý & Giám Sát VPS
GETCode Mẫu Tích Hợp Hoàn Chỉnh (PHP SDK)
Ví dụ Class PHP chuẩn cURL kết nối tự động mua VPS và xử lý kết quả:
<?php
class DichVuDarkAgency {
private $baseUrl = "https://www.host.tunthui.shop";
private $username;
private $appKey;
private $secretKey;
private $token = null;
public function __construct($username, $appKey, $secretKey) {
$this->username = $username;
$this->appKey = $appKey;
$this->secretKey = $secretKey;
}
public function getToken() {
$ch = curl_init("{$this->baseUrl}/api/agency/get-token");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
"api-username" => $this->username,
"api-app" => $this->appKey,
"api-secret" => $this->secretKey
]),
CURLOPT_HTTPHEADER => ["Content-Type: application/json"]
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
if (@$res['status'] && !empty($res['token'])) {
$this->token = $res['token'];
return $this->token;
}
throw new Exception($res['message'] ?? 'Không lấy được Token');
}
public function createOrder($productId, $osId, $cycle = 1) {
if (!$this->token) $this->getToken();
$ch = curl_init("{$this->baseUrl}/api/agency/order/create-order");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
"product_id" => $productId,
"os_id" => $osId,
"billing_cycle" => $cycle
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api-username: {$this->username}",
"api-token: {$this->token}"
]
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
return $res;
}
}
// Khởi tạo
$client = new DichVuDarkAgency("user_agency", "app_xxx", "sec_yyy");
$order = $client->createOrder(1, "Windows Server 2019", 1);
print_r($order);
?>