POST /apiv2/address/rotate
ส่งคำขอเปลี่ยนที่อยู่สำหรับการฝาก ที่อยู่สำหรับการฝากปัจจุบันจะถูกแทนที่ด้วยที่อยู่ใหม่ คำขอจะถูกจัดเข้าคิวประมวลผลและเสร็จสมบูรณ์โดยอัตโนมัติภายใน 5 นาที
URL ของ Endpoint
POST https://netts.io/apiv2/address/rotateHeaders ของคำขอ
| ส่วนหัว | จำเป็น | คำอธิบาย |
|---|---|---|
| Content-Type | ใช่ | application/json |
| X-API-KEY | ใช่ | คีย์ API ของคุณจากแดชบอร์ด Netts |
| X-Real-IP | ใช่ | ที่อยู่ IP จากรายการที่อนุญาต (whitelist) ของคุณ |
เนื้อหาคำขอ
json
{
"user_id": 1234,
"address_type": "web"
}พารามิเตอร์
| พารามิเตอร์ | ชนิด | จำเป็น | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|---|
| user_id | integer | ไม่ | ผู้ใช้ที่ยืนยันตัวตนแล้ว | ID ผู้ใช้เป้าหมาย เว้นว่างไว้เพื่อเปลี่ยนที่อยู่ของตัวคุณเอง ผู้ใช้หลัก (Parent user) สามารถระบุ ID ของผู้ใช้ย่อย (SUB-user) ได้ |
| address_type | string | ไม่ | "web" | ประเภทที่อยู่ที่จะเปลี่ยน: web หรือ tg |
การยืนยันตัวตนและการอนุญาตสิทธิ์
Endpoint นี้ต้องการทั้ง การยืนยันตัวตน (authentication) และ การอนุญาตสิทธิ์ (authorization):
- การยืนยันตัวตน: คีย์ API ที่ถูกต้อง + IP จากรายการที่อนุญาต (เหมือนกับ Endpoint อื่นๆ)
- การอนุญาตสิทธิ์:
- เปลี่ยนที่อยู่ของ ตัวคุณเอง — ได้รับอนุญาตเสมอ
- เปลี่ยนที่อยู่ของ ผู้ใช้ย่อย (SUB-user) ของคุณ — อนุญาตสำหรับผู้ใช้หลัก
- เปลี่ยนที่อยู่ของผู้ใช้อื่น — จะถูกปฏิเสธด้วย
403 Forbidden
ตัวอย่างคำขอ
cURL
bash
# เปลี่ยนที่อยู่ของตนเอง
curl -X POST https://netts.io/apiv2/address/rotate \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip" \
-d '{"address_type": "web"}'bash
# เปลี่ยนที่อยู่ของผู้ใช้ย่อย (SUB-user) (เฉพาะผู้ใช้หลักเท่านั้น)
curl -X POST https://netts.io/apiv2/address/rotate \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip" \
-d '{"user_id": 1234, "address_type": "web"}'Python
python
import requests
url = "https://netts.io/apiv2/address/rotate"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "your_api_key",
"X-Real-IP": "your_whitelisted_ip"
}
# เปลี่ยนที่อยู่ของตนเอง
response = requests.post(url, headers=headers, json={"address_type": "web"})
data = response.json()
if response.status_code == 200:
print(f"Rotation ID: {data['rotation_id']}")
print(f"Old Address: {data['old_address']}")
print(f"Status: {data['status']}")
print(f"Estimated Completion: {data['estimated_completion']}")
else:
print(f"Error: {data.get('detail', 'Unknown error')}")Node.js
javascript
const axios = require('axios');
async function rotateAddress(apiKey, whitelistedIp, addressType = 'web', userId = null) {
const url = 'https://netts.io/apiv2/address/rotate';
const body = { address_type: addressType };
if (userId) body.user_id = userId;
const response = await axios.post(url, body, {
headers: {
'Content-Type': 'application/json',
'X-API-KEY': apiKey,
'X-Real-IP': whitelistedIp
},
timeout: 30000
});
const data = response.data;
console.log(`Rotation ID: ${data.rotation_id}`);
console.log(`Status: ${data.status}`);
console.log(`Old Address: ${data.old_address}`);
return data;
}
// เปลี่ยนที่อยู่ของตนเอง
rotateAddress('your_api_key', 'your_whitelisted_ip')
.then(result => console.log('Submitted:', result.message))
.catch(err => console.error('Error:', err.response?.data || err.message));PHP
php
<?php
$url = 'https://netts.io/apiv2/address/rotate';
$data = json_encode([
'address_type' => 'web'
]);
$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' => $data,
'timeout' => 30
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$result = json_decode($response, true);
echo "Rotation ID: {$result['rotation_id']}\n";
echo "Old Address: {$result['old_address']}\n";
echo "Status: {$result['status']}\n";
echo "Message: {$result['message']}\n";
?>การตอบกลับ
การตอบกลับเมื่อสำเร็จ (200 OK)
json
{
"rotation_id": 42,
"user_id": 1234,
"address_type": "web",
"old_address": "TCurrentAddress1234567890123456789",
"status": "pending",
"message": "Address rotation request submitted. New address will be assigned within 5 minutes.",
"estimated_completion": "2026-03-14T12:35:00Z"
}ฟิลด์การตอบกลับ
| ฟิลด์ | ชนิด | คำอธิบาย |
|---|---|---|
| rotation_id | integer | ID คำขอเปลี่ยนที่อยู่ที่ไม่ซ้ำกัน (ใช้สำหรับการตรวจสอบสถานะ) |
| user_id | integer | ผู้ใช้ที่กำลังถูกเปลี่ยนที่อยู่ |
| address_type | string | ประเภทที่อยู่ที่จะเปลี่ยน (web หรือ tg) |
| old_address | string | ที่อยู่การฝาก TRON ปัจจุบันก่อนที่จะทำการเปลี่ยน |
| status | string | สถานะคำขอ: pending |
| message | string | ข้อความสถานะที่มนุษย์สามารถอ่านเข้าใจได้ |
| estimated_completion | string | เวลาที่คาดว่าจะเสร็จสมบูรณ์ในรูปแบบ ISO 8601 |
ตรวจสอบสถานะการเปลี่ยนที่อยู่
GET /apiv2/address/rotate/status/
ตรวจสอบสถานะของคำขอเปลี่ยนที่อยู่ที่ส่งไปก่อนหน้านี้
bash
curl https://netts.io/apiv2/address/rotate/status/42 \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip"การตอบกลับ:
json
{
"rotation_id": 42,
"user_id": 1234,
"address_type": "web",
"status": "completed",
"old_address": "TOldAddress1234567890123456789012",
"new_address": "TNewAddress1234567890123456789012",
"created_at": "2026-03-14T12:30:00Z",
"completed_at": "2026-03-14T12:34:15Z"
}ค่าสถานะ
| สถานะ | คำอธิบาย |
|---|---|
pending | ส่งคำขอแล้ว กำลังรอการประมวลผล |
processing | กำลังดำเนินการประมวลผล |
completed | กำหนดที่อยู่ใหม่สำเร็จเรียบร้อยแล้ว |
failed | เกิดข้อผิดพลาดระหว่างการเปลี่ยนที่อยู่ |
ตรวจสอบการเปลี่ยนที่อยู่ที่รอดำเนินการ
GET /apiv2/address/rotate/pending
ตรวจสอบว่าผู้ใช้มีคำขอเปลี่ยนที่อยู่ซึ่งยังรอดำเนินการอยู่หรือไม่ (มีประโยชน์สำหรับการปิดการใช้งานปุ่มเปลี่ยนที่อยู่)
bash
curl "https://netts.io/apiv2/address/rotate/pending?address_type=web" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip"การตอบกลับ:
json
{
"user_id": 1234,
"address_type": "web",
"has_pending": true,
"pending_rotation": {
"rotation_id": 42,
"status": "pending",
"created_at": "2026-03-14T12:30:00Z"
}
}หมายเหตุสำคัญ
การเปลี่ยนแปลงที่อยู่
หลังจากการเปลี่ยนที่อยู่เสร็จสมบูรณ์ ที่อยู่การฝากปัจจุบันของคุณจะไม่ยอมรับการฝากอีกต่อไป โปรดตรวจสอบให้แน่ใจว่า:
- ถอนยอดคงเหลือที่เหลืออยู่ทั้งหมดออกจากที่อยู่ปัจจุบันก่อนที่จะส่งคำขอเปลี่ยนที่อยู่
- อัปเดตระบบภายนอกใดๆ ที่อ้างอิงถึงที่อยู่การฝากเดิมของคุณ
- ใช้ที่อยู่ใหม่สำหรับการฝากเงินทั้งหมดในอนาคต
ระยะเวลาการประมวลผล
คำขอเปลี่ยนที่อยู่จะได้รับการประมวลผลโดยอัตโนมัติ โดยทั่วไปที่อยู่ใหม่จะได้รับการกำหนดภายใน 5 นาที หลังจากการส่งคำขอ
- อนุญาตให้มี คำขอเปลี่ยนที่อยู่ที่รอดำเนินการได้เพียงหนึ่งรายการ ต่อผู้ใช้ต่อประเภทที่อยู่ภายในกรอบเวลา 7 วัน
- หากคุณมีคำขอเปลี่ยนที่อยู่ที่รอดำเนินการอยู่แล้ว คำขอจะถูกปฏิเสธด้วย
409 Conflict - สามารถเปลี่ยนที่อยู่ทั้ง
webและtgได้อย่างอิสระแยกจากกัน - ผู้ใช้หลักสามารถเปลี่ยนที่อยู่ของผู้ใช้ย่อยได้โดยระบุพารามิเตอร์
user_id
การตอบกลับข้อผิดพลาด
ขัดแย้ง (409)
json
{
"detail": "User 1234 already has a pending web address rotation request"
}คำขอไม่ถูกต้อง (400)
json
{
"detail": "User 1234 has no web deposit address"
}json
{
"detail": "address_type must be 'web' or 'tg'"
}ไม่พบข้อมูล (404)
json
{
"detail": "User 9999 not found"
}ไม่ได้รับอนุญาต (403)
json
{
"detail": "Not authorized to rotate this user's address"
}ข้อผิดพลาดในการยืนยันตัวตน (401)
json
{
"detail": "X-API-KEY header required"
}อ้างอิงรหัสข้อผิดพลาด
| รหัสสถานะ HTTP | คำอธิบาย |
|---|---|
200 | ส่งคำขอเปลี่ยนที่อยู่สำเร็จเรียบร้อยแล้ว |
400 | คำขอไม่ถูกต้อง (ไม่มีที่อยู่, ประเภทไม่ถูกต้อง) |
401 | ส่วนหัวคีย์ API ขาดหายไป |
403 | ไม่ได้รับอนุญาต / คีย์ API หรือ IP ไม่ถูกต้อง |
404 | ไม่พบผู้ใช้ / ไม่พบข้อมูลการเปลี่ยนที่อยู่ |
409 | มีคำขอเปลี่ยนที่อยู่ที่รอดำเนินการอยู่แล้ว |
500 | ข้อผิดพลาดภายในเซิร์ฟเวอร์ |
Endpoint ที่เกี่ยวข้อง
- POST /apiv2/subusergen — สร้างผู้ใช้ย่อย (SUB-user) ใหม่
- DELETE /apiv2/subuserdel — ลบผู้ใช้ย่อย (SUB-user)
- GET /apiv2/userinfo — รับข้อมูลผู้ใช้