🔐 Xác thực: Hầu hết endpoint không cần xác thực. Chỉ riêng /api/all-domains/ cần header X-Domain-Token.

GET/api/email/{domain}/{user}/

Lấy danh sách email của một user, có phân trang. Phản hồi danh sách chỉ gồm metadata (không có body / html_body).

Tham sốVị tríMô tả
domainpathTên miền email, vd example.com
userpathTên người dùng, vd testuser
pagequery, tùy chọnSố trang (mặc định 1)
limitquery, tùy chọnSố item/trang (mặc định 20, tối đa 100)
curl -X GET "https://BASE_URL/api/email/example.com/testuser/?page=1&limit=20"
{
  "emails": [
    {
      "id": 123,
      "subject": "Welcome",
      "sender": "[email protected]",
      "date": "2026-09-30T10:30:00.000Z",
      "has_attachments": false,
      "size": 1234
    }
  ],
  "total": 5,
  "page": 1,
  "limit": 20,
  "has_more": false
}

GET/api/email/{domain}/{user}/{email_id}

Lấy nội dung chi tiết một email.

curl -X GET "https://BASE_URL/api/email/example.com/testuser/123"

DELETE/api/email/{domain}/{user}/{email_id}

Xóa một email cụ thể.

curl -X DELETE "https://BASE_URL/api/email/example.com/testuser/123"
{ "status": "deleted" }

POST/api/add-domain/{domain}

Thêm domain mới hoặc cập nhật trạng thái online của domain đã có. Domain phải có MX record trỏ đúng về hostname của hệ thống mới được chấp nhận (status added, is_online: true).

curl -X POST "https://BASE_URL/api/add-domain/newdomain.com"
// Khi thêm thành công
{ "status": "added", "domain": "newdomain.com", "is_online": true }

// Khi domain đã tồn tại, cập nhật lại trạng thái
{ "status": "updated", "domain": "newdomain.com", "is_online": false }
⚠️ Nếu MX chưa trỏ đúng, API trả về lỗi 400 với thông báo hướng dẫn.

GET/api/all-domains/ & /api/random-domains/

Toàn bộ domain online (riêng tư, cần token):

curl -X GET "https://BASE_URL/api/all-domains/" \
  -H "X-Domain-Token: YOUR_TOKEN"

Domain online ngẫu nhiên (công khai):

curl -X GET "https://BASE_URL/api/random-domains/?limit=10"
{ "domains": ["domain1.com", "domain2.com"], "total": 2 }

GET/api/check-mx/{domain}

Kiểm tra domain đã có MX record hợp lệ trỏ về hệ thống chưa.

curl -X GET "https://BASE_URL/api/check-mx/example.com"
{ "result": "online" }   // hoặc "offline"

Xử lý lỗi

MãÝ nghĩa
200Thành công
400Request không hợp lệ (vd sai định dạng domain/email)
401Thiếu/sai token cho endpoint riêng tư
404Không tìm thấy email
429Vượt rate-limit
{ "detail": "Domain not found" }

Lưu ý quan trọng