Skip to content
Translated page. The English version is the source of truth.

POST /apiv2/subusergen

Tạo một người dùng phụ (SUB-user / sub-account) mới được liên kết với tài khoản chính của bạn. Các SUB-user có API key riêng, địa chỉ nạp tiền riêng và số dư tách biệt cho các hoạt động energy độc lập.

URL Endpoint

POST https://netts.io/apiv2/subusergen

Header yêu cầu

HeaderBắt buộcMô tả
Content-Typeapplication/json
X-API-KEYAPI key của bạn từ bảng điều khiển Netts
X-Real-IPĐịa chỉ IP từ danh sách trắng (whitelist) của bạn

Body yêu cầu

json
{}

Không yêu cầu tham số. SUB-user sẽ tự động được liên kết với tài khoản được xác định bởi API key.

Ví dụ yêu cầu

cURL

bash
curl -X POST https://netts.io/apiv2/subusergen \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: your_api_key" \
  -H "X-Real-IP: your_whitelisted_ip" \
  -d '{}'

Python

python
import requests

url = "https://netts.io/apiv2/subusergen"
headers = {
    "Content-Type": "application/json",
    "X-API-KEY": "your_api_key",
    "X-Real-IP": "your_whitelisted_ip"
}

response = requests.post(url, headers=headers, json={})
data = response.json()

if response.status_code == 200:
    print(f"SUB User ID: {data['user_id']}")
    print(f"Google ID: {data['google_id']}")
    print(f"Email: {data['email']}")
    print(f"Deposit Address: {data['deposit_address']}")
    print(f"API Key: {data['api_key']}")
    print(f"Referral Code: {data['referral_code']}")
    print(f"Parent User ID: {data['referrer_user_id']}")
else:
    print(f"Error: {data.get('detail', 'Unknown error')}")

Node.js

javascript
const axios = require('axios');

async function createSubUser(apiKey, whitelistedIp) {
    const url = 'https://netts.io/apiv2/subusergen';

    const response = await axios.post(url, {}, {
        headers: {
            'Content-Type': 'application/json',
            'X-API-KEY': apiKey,
            'X-Real-IP': whitelistedIp
        },
        timeout: 30000
    });

    const data = response.data;
    console.log(`SUB User ID: ${data.user_id}`);
    console.log(`API Key: ${data.api_key}`);
    console.log(`Deposit Address: ${data.deposit_address}`);
    return data;
}

// Usage
createSubUser('your_api_key', 'your_whitelisted_ip')
    .then(result => console.log('Created:', result))
    .catch(err => console.error('Error:', err.response?.data || err.message));

PHP

php
<?php
$url = 'https://netts.io/apiv2/subusergen';

$options = [
    'http' => [
        'header' => implode("\r\n", [
            "Content-Type: application/json",
            "X-API-KEY: your_api_key",
            "X-Real-IP: your_whitelisted_ip"
        ]),
        'method' => 'POST',
        'content' => '{}',
        'timeout' => 30
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$data = json_decode($response, true);

echo "SUB User ID: {$data['user_id']}\n";
echo "API Key: {$data['api_key']}\n";
echo "Deposit Address: {$data['deposit_address']}\n";
?>

Phản hồi

Phản hồi thành công (200 OK)

json
{
    "user_id": 1379,
    "google_id": "SUB123456789012345678",
    "email": "[email protected]",
    "name": "SUB123456789012345678",
    "deposit_address": "TExampleAddress1234567890123456789",
    "api_key": "mock1234567890abcdef1234567890ab",
    "referral_code": "A2B4K9",
    "created_at": "2026-03-14T12:00:00",
    "referrer_user_id": 42,
    "comment": "SUB user linked to main user (referrer_user_id). Google ID, Email and Name are mock data (not real) that can be updated via separate endpoint. For API services usage, requests must include this SUB user's API key and IP from main user's whitelist. Calculations use SUB user's balance. Generated deposit address is not active."
}

Các trường phản hồi

TrườngLoạiMô tả
user_idintegerID duy nhất của SUB-user được tạo
google_idstringĐịnh danh giả (định dạng: SUB + 18 chữ số). Không phải là tài khoản Google thật — chỉ dùng để nhận diện nội bộ SUB-user
emailstringEmail giả (google_id + @gmail.com). Không phải là địa chỉ email thật — chỉ dùng để nhận diện nội bộ
namestringTên hiển thị (mặc định là google_id). Có thể thay đổi trong bảng điều khiển
deposit_addressstringĐịa chỉ nạp tiền TRON được tạo (mặc định chưa kích hoạt)
api_keystringAPI key cho SUB-user (tiền tố: mock)
referral_codestringMã giới thiệu được tạo (6 ký tự)
created_atstringDấu thời gian tạo theo định dạng ISO 8601
referrer_user_idintegerID người dùng cha (tài khoản đã tạo SUB-user này)
commentstringHướng dẫn sử dụng và ghi chú

Dữ liệu Google giả lập

Các trường google_id, emailnamedữ liệu giả lập — chúng không phải là tài khoản Google hay địa chỉ email thật. Các trường này chỉ tồn tại phục vụ mục đích nhận diện nội bộ SUB-user trong hệ thống. Tênthẻ (tag) của SUB-user có thể được thay đổi trong bảng điều khiển.

Cách thức hoạt động của SUB-User

Các khái niệm chính

  • Số dư tách biệt: Mỗi SUB-user có số dư TRX riêng biệt, độc lập với tài khoản cha
  • Chia sẻ danh sách trắng IP: Các yêu cầu API của SUB-user được xác thực dựa trên danh sách trắng IP của tài khoản cha
  • API key riêng: Mỗi SUB-user nhận một API key duy nhất để xác thực
  • Liên kết tài khoản cha: SUB-user được liên kết vĩnh viễn với tài khoản tạo thông qua hệ thống giới thiệu
  • Tất cả các endpoint API: SUB-user có thể sử dụng tất cả các endpoint API (order1h, time/order, v.v.) bằng API key và số dư của chính họ

Quy trình sử dụng

  1. Tạo SUB-user thông qua endpoint này
  2. Nạp tiền cho SUB-user bằng cách chuyển TRX đến địa chỉ nạp tiền của họ hoặc chuyển số dư
  3. Sử dụng API key của SUB-user trong các yêu cầu API tiếp theo (order1h, time/order, v.v.)
  4. Theo dõi qua endpoint userinfo bằng cách sử dụng API key của SUB-user

Các phản hồi lỗi

Lỗi xác thực (401)

json
{
    "detail": "X-API-KEY header required"
}

Bị từ chối truy cập (403)

json
{
    "detail": "Invalid API key or IP not whitelisted"
}

Lỗi xác thực dữ liệu (422)

json
{
    "detail": [...],
    "body": {...}
}

Lỗi máy chủ nội bộ (500)

json
{
    "detail": "Failed to create mock user: ..."
}

Bảng mã lỗi tham chiếu

Mã trạng thái HTTPMô tả
200SUB-user đã được tạo thành công
401Thiếu header API key
403API key không hợp lệ hoặc IP không nằm trong whitelist
422Lỗi xác thực yêu cầu
500Lỗi máy chủ nội bộ

Ghi chú

  • Bắt buộc phải có phần thân yêu cầu rỗng {} (Content-Type phải là application/json)
  • Địa chỉ nạp tiền được tạo chưa kích hoạt theo mặc định
  • google_idemail của SUB-user là dữ liệu giả lập (không phải tài khoản Google thật), chỉ dùng để nhận diện nội bộ
  • Tên và thẻ (tag) của SUB-user có thể được thay đổi trong bảng điều khiển
  • API key của SUB-user bắt đầu bằng tiền tố mock
  • Việc xác thực danh sách trắng IP sử dụng danh sách trắng của người dùng cha
  • Mỗi SUB-user có số dư riêng, tách biệt với tài khoản cha
  • SUB-user có thể bị xóa thông qua endpoint DELETE /apiv2/subuserdel
  • Địa chỉ nạp tiền có thể được xoay vòng thông qua endpoint POST /apiv2/address/rotate