API Reference

Tích hợp ZuckMails vào ứng dụng của bạn. Tạo email tạm, nhận OTP tự động qua REST API.

Base URL
Authentication
POST /api/auth/register Đăng ký tài khoản mới Public

Body

ParameterTypeDescription
usernamestring3-30 ký tự (a-z, 0-9, _)
passwordstringTối thiểu 6 ký tự
emailstring optionalEmail liên hệ

Response

// 201 Created { "success": true, "data": { "id": 1, "username": "myuser", "role": "user", "credits": 10, "token": "eyJhbG..." } }
POST /api/auth/login Đăng nhập, nhận JWT token Public

Body

ParameterTypeDescription
usernamestringTên đăng nhập
passwordstringMật khẩu

Response

{ "success": true, "data": { "username": "myuser", "role": "user", "credits": 10, "token": "eyJhbGciOi..." } }

Sử dụng Token

// Header Authorization: Bearer eyJhbGciOi... // Hoặc Cookie (tự động set khi login qua web) Cookie: token=eyJhbGciOi...
Domains
GET /api/domains Danh sách domain khả dụng Public

Response

{ "success": true, "data": [ { "id": 1, "domain": "example.com", "created_at": "2026-03-20T00:00:00Z" } ] }
Emails
POST /api/emails/generate Tạo email tạm (-1 credit) Public

Body

ParameterTypeDescription
domainstring optionalChọn domain, bỏ trống = ngẫu nhiên

Response

{ "success": true, "data": { "address": "[email protected]", "domain": "example.com", "expires_at": "2026-03-21T00:00:00Z", "credits_remaining": 9 } }
POST /api/emails/rent Thuê email tùy chỉnh API Key

Headers

X-Api-Key: tm_your_api_key

Body

ParameterTypeDescription
domainstring optionalChọn domain
usernamestring optionalTên email tùy chỉnh
expiry_hoursnumber optionalThời gian tồn tại (mặc định 24h)

Response

{ "success": true, "data": { "address": "[email protected]", "credits_remaining": 99 } }
GET /api/emails/:address/inbox Đọc hộp thư Public

Query Parameters

ParameterTypeDescription
limitnumber optionalSố tin nhắn tối đa (mặc định 50)

Response

{ "success": true, "data": { "address": "[email protected]", "message_count": 2, "messages": [{ "id": 1, "sender": "[email protected]", "subject": "Your verification code", "body_text": "Your code is 123456", "received_at": "2026-03-20T12:00:00Z" }] } }
DELETE /api/emails/:address Xóa email Public

Response

{ "success": true }
OTP Extraction
GET /api/emails/:address/otp Trích xuất OTP Public

Query Parameters

ParameterTypeDescription
providerstring optionalLọc theo nhà cung cấp

Supported Providers

facebook google instagram tiktok twitter telegram microsoft apple whatsapp discord linkedin snapchat

Response

{ "success": true, "data": { "provider": "Facebook", "otp_code": "123456", "source": "body", "sender": "[email protected]" } }
GET /api/emails/:address/otp/wait Chờ OTP (long polling) Public

Query Parameters

ParameterTypeDescription
providerstring optionalLọc theo provider
timeoutnumber optionalThời gian chờ tối đa, giây (mặc định 60, max 120)

Server sẽ giữ kết nối mở cho đến khi nhận OTP hoặc hết timeout.

Real-time (SSE)
GET /api/emails/:address/stream Real-time inbox (Server-Sent Events) Public

Events

// Connected data: {"type":"connected","address":"[email protected]"} // New message received data: {"type":"new_message","message":{"id":1,"sender":"...","subject":"...","otp":{"provider":"Facebook","otp_code":"123456"}}}

JavaScript Example

const source = new EventSource('/api/emails/[email protected]/stream'); source.onmessage = (event) => { const data = JSON.parse(event.data); if (data.type === 'new_message') { console.log('New email from:', data.message.sender); if (data.message.otp) { console.log('OTP:', data.message.otp.otp_code); } } };
API Keys
GET /api/keys/check Kiểm tra API key API Key

Headers

X-Api-Key: tm_your_api_key
Full Examples
cURL Complete Flow Generate email → Wait OTP → Read inbox
# Your Bearer Token (from Dashboard or API Keys page) TOKEN="eyJ...your_token_here" # 1. Generate temporary email curl -s -X POST https://zuckmails.com/api/emails/generate \ -H "Authorization: Bearer $TOKEN" # Response: {"success":true,"data":{"address":"[email protected]","expires_at":"..."}} # 2. Wait for OTP (blocks up to 60s) curl -s "https://zuckmails.com/api/emails/[email protected]/otp/wait?timeout=60" # 3. Read full inbox curl -s https://zuckmails.com/api/emails/[email protected]/inbox
JS JavaScript / Node.js Fetch API + async/await
const API = 'https://zuckmails.com'; const TOKEN = 'eyJ...your_token_here'; // from Dashboard async function getOTP() { // 1. Generate email const res = await fetch(`${API}/api/emails/generate`, { method: 'POST', headers: { 'Authorization': `Bearer ${TOKEN}` } }).then(r => r.json()); const addr = res.data.address; console.log('Email:', addr); // 2. Wait for OTP (max 60s) const otp = await fetch( `${API}/api/emails/${addr}/otp/wait?timeout=60` ).then(r => r.json()); if (otp.data) { console.log('OTP:', otp.data.otp_code); } else { console.log('No OTP received'); } } getOTP();
PY Python requests library
import requests API = "https://zuckmails.com" TOKEN = "eyJ...your_token_here" # from Dashboard headers = {"Authorization": f"Bearer {TOKEN}"} # 1. Generate email res = requests.post(f"{API}/api/emails/generate", headers=headers ).json() addr = res["data"]["address"] print(f"Email: {addr}") # 2. Wait for OTP otp = requests.get( f"{API}/api/emails/{addr}/otp/wait", params={"timeout": 60} ).json() if otp["data"]: print(f"OTP: {otp['data']['otp_code']}") else: print("No OTP received")
C# C# / .NET HttpClient + System.Text.Json
using System.Net.Http; using System.Net.Http.Json; using System.Text.Json; var client = new HttpClient(); var api = "https://zuckmails.com"; var token = "eyJ...your_token_here"; // from Dashboard client.DefaultRequestHeaders.Add( "Authorization", $"Bearer {token}"); // 1. Generate email var genRes = await client.PostAsync( $"{api}/api/emails/generate", null); var genData = await genRes.Content .ReadFromJsonAsync<JsonElement>(); var addr = genData .GetProperty("data") .GetProperty("address").GetString(); Console.WriteLine($"Email: {addr}"); // 2. Wait for OTP var otpRes = await client.GetFromJsonAsync<JsonElement>( $"{api}/api/emails/{addr}/otp/wait?timeout=60"); if (otpRes.GetProperty("data") .ValueKind != JsonValueKind.Null) { var code = otpRes.GetProperty("data") .GetProperty("otp_code").GetString(); Console.WriteLine($"OTP: {code}"); }