Đang tải…
Đang tải…
Dùng JWT trong header: Authorization: Bearer <token>
Khi lỗi (JSON), response thường có dạng:
{
"error": "Message from server (localized, e.g. 400/401/404/409/500)"
}/healthKhông cần JWTKiểm tra dịch vụ (public)
Response JSON mẫu
{
"ok": true
}/api/auth/registerKhông cần JWTĐăng ký tài khoản
Body JSON mẫu
{
"email": "[email protected]",
"password": "matkhau_toi_thieu_8_ky_tu"
}Response JSON mẫu
HTTP 201
{
"token": "eyJhbGciOiJIUzI1NiJ9...",
"user": {
"id": "usr_01ABCDEF",
"email": "[email protected]",
"plan": "free"
},
"domainCount": 0,
"domainLimit": 5
}/api/auth/loginKhông cần JWTĐăng nhập và lấy token
Body JSON mẫu
{
"email": "[email protected]",
"password": "matkhau_cua_ban"
}Response JSON mẫu
HTTP 200
{
"token": "eyJhbGciOiJIUzI1NiJ9...",
"user": {
"id": "usr_01ABCDEF",
"email": "[email protected]",
"plan": "free"
},
"domainCount": 2,
"domainLimit": 5
}/api/meCần JWTThông tin tài khoản và gói hiện tại
Response JSON mẫu
{
"user": {
"id": "usr_01ABCDEF",
"email": "[email protected]",
"plan": "premium"
},
"plan": "premium",
"domainCount": 3,
"domainLimit": 50
}/api/plan/redeemCần JWTKích hoạt gói Premium hoặc Creator bằng mã
Body JSON mẫu
{
"code": "your-secret-code",
"tier": "premium"
}Response JSON mẫu
{
"plan": "premium",
"domainCount": 3,
"domainLimit": 50,
"message": "Da kich hoat goi Premium"
}/api/domainsCần JWTLấy danh sách tên miền của người dùng
Response JSON mẫu
{
"domains": [
{
"id": "dom_01ABCDEF",
"name": "example.com",
"status": "verified",
"verified_at": "2025-03-19T10:00:00.000Z",
"verification_token": "a1b2c3...",
"created_at": "2025-03-19T09:00:00.000Z"
},
{
"id": "dom_02FEDCBA",
"name": "pending.example.com",
"status": "pending",
"verified_at": null,
"verification_token": "d4e5f6...",
"created_at": "2025-03-19T08:00:00.000Z"
}
]
}/api/domainsCần JWTThêm tên miền mới (ví dụ example.com)
Body JSON mẫu
{
"name": "example.com"
}Response JSON mẫu
HTTP 201
{
"id": "dom_01ABCDEF",
"name": "example.com",
"status": "pending",
"verificationToken": "a1b2c3d4e5f6...",
"dnsGuide": {
"mx": "route1.mx.cloudflare.net",
"mxCloudflare": "route1.mx.cloudflare.net",
"mxSmtp": "mail.khomail.org",
"txt": "tempmail-verification=a1b2c3d4e5f6..."
}
}/api/domains/:idCần JWTXóa tên miền (đã hoặc chưa xác minh), xóa luôn thư và địa chỉ liên quan
Response JSON mẫu
{
"ok": true
}/api/domains/:id/verifyCần JWTKiểm tra MX/TXT và xác minh tên miền
Response JSON mẫu
{
"verified": true,
"checks": {
"hasExpectedMx": true,
"hasExpectedTxt": true,
"txtRecords": [
"tempmail-verification=a1b2c3..."
],
"mxRecords": [
"10 route1.mx.cloudflare.net."
]
},
"expected": {
"mx": "route1.mx.cloudflare.net",
"mxCloudflare": "route1.mx.cloudflare.net",
"mxSmtp": "mail.khomail.org",
"mxHosts": [
"route1.mx.cloudflare.net",
"mail.khomail.org"
],
"txt": "tempmail-verification=a1b2c3..."
}
}/api/domains/:id/addressesCần JWTDanh sách địa chỉ của một tên miền
Response JSON mẫu
{
"domain": "example.com",
"addresses": [
{
"id": "adr_01ABCDEF",
"local_part": "tmpa1b2c3d4e",
"is_active": 1,
"created_at": "2025-03-19T11:00:00.000Z",
"address": "[email protected]"
}
]
}/api/domains/:id/addresses/generateCần JWTTạo địa chỉ mới trên tên miền
Response JSON mẫu
{
"id": "adr_01ABCDEF",
"localPart": "tmpa1b2c3d4e",
"address": "[email protected]"
}/api/inboxCần JWTLấy danh sách thư (polling)
URL mẫu (query)
Tất cả tham số đều tùy chọn: domainId, address, since (ISO 8601).
https://tempmail-worker.mailnhanh.workers.dev/api/inbox?domainId=dom_01ABCDEF&[email protected]&since=2025-03-19T00:00:00.000Z
Response JSON mẫu
{
"emails": [
{
"id": "eml_01ABCDEF",
"sender": "[email protected]",
"recipient": "[email protected]",
"subject": "Xin chào",
"created_at": "2025-03-19T12:00:00.000Z",
"domain_name": "example.com"
}
]
}/api/emails/:idCần JWTChi tiết thư và đính kèm
Response JSON mẫu
{
"email": {
"id": "eml_01ABCDEF",
"sender": "[email protected]",
"recipient": "[email protected]",
"subject": "Tiêu đề",
"bodyHtml": "<p>Nội dung</p>",
"bodyText": "Nội dung",
"createdAt": "2025-03-19T12:00:00.000Z"
},
"attachments": [
{
"id": "att_01ABCDEF",
"file_name": "file.pdf",
"file_size": 102400
}
]
}/api/emails/:id/downloadCần JWTTải tệp .eml
Response mẫu (không phải JSON)
Thân response là nội dung nhị phân hoặc văn bản RFC 822, không phải object JSON.
HTTP 200 Content-Type: message/rfc822 Content-Disposition: attachment; filename="email-eml_01ABCDEF.eml" From: [email protected] To: [email protected] Subject: Tiêu đề Date: 2025-03-19T12:00:00.000Z Content-Type: text/plain; charset=utf-8 Nội dung thư (hoặc toàn bộ .eml gốc nếu có raw_eml trong DB).
/api/attachments/:idCần JWTTải tệp đính kèm
Response mẫu (không phải JSON)
Thân response là nội dung nhị phân hoặc văn bản RFC 822, không phải object JSON.
HTTP 200 Content-Type: application/pdf (hoặc loại MIME đã lưu trên R2) Content-Disposition: attachment; filename="file.pdf" <Nội dung nhị phân của tệp đính kèm>
Ví dụ gọi API
curl -X POST "https://tempmail-worker.mailnhanh.workers.dev/api/domains" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"example.com"}'