DEVELOPER REFERENCE

Mail API

Tài liệu đầy đủ cho API tạo địa chỉ, mở inbox theo email, đọc/xoá mail, quản lý domain và API token legacy.

Quick start

Đọc OTP bằng email

Không cần token cho luồng chính. Mở hoặc tạo inbox bằng địa chỉ đầy đủ, sau đó poll danh sách mail.

curl -X POST https://YOUR_DOMAIN/api/v1/inboxes/open \
  -H 'Content-Type: application/json' \
  -d '{"email":"abc@example.com"}'

curl 'https://YOUR_DOMAIN/api/v1/inboxes/abc%40example.com/emails'
Address inbox

API không token

POST /api/v1/inboxes/open

Mở một email bất kỳ thuộc domain đang bật. Nếu chưa tồn tại, server tạo mailbox 24 giờ.

Body
{ "email": "abc@example.com" }
Response
{ "email", "created_at", "expires_at" }

GET /api/v1/inboxes/{email}/emails

Liệt kê mail mới nhất. Encode @ thành %40.

Query
page, per_page, unread_only, search

GET /api/v1/inboxes/{email}/emails/{email_id}

Đọc nội dung đầy đủ, tự đánh dấu đã đọc.

Query
mark_read=false để không đánh dấu đã đọc.

DELETE /api/v1/inboxes/{email}/emails/{email_id}

Xoá một email và attachment liên quan.

Legacy token API

API đầy đủ cho client cũ

POST /api/v1/addresses

Tạo địa chỉ random hoặc chọn domain. Response có token.

curl -X POST https://YOUR_DOMAIN/api/v1/addresses \
  -H 'Content-Type: application/json' \
  -d '{"domain":"example.com"}'

GET /api/v1/{token}/emails

List mail theo access token, hỗ trợ pagination, unread và search.

GET /api/v1/{token}/emails/{email_id}

Đọc chi tiết email và attachment metadata.

GET /api/v1/{token}/emails/{email_id}/raw

Tải message gốc dạng .eml.

GET /api/v1/{token}/emails/{email_id}/attachments/{attachment_id}

Tải file đính kèm.

DELETE /api/v1/{token}/emails/{email_id}

Xoá email theo token.

Admin domains

Quản lý domain

GET /api/v1/domains

Danh sách domain đang bật cho dropdown tạo mailbox.

GET /api/v1/admin/domains

Danh sách domain trong trang Admin.

POST /api/v1/admin/domains

Thêm domain và ghi vào cấu hình dùng chung.

curl -X POST https://YOUR_DOMAIN/api/v1/admin/domains \
  -H 'Content-Type: application/json' \
  -d '{"domain":"example.com"}'

DELETE /api/v1/admin/domains/{domain}

Xoá domain; không thể xoá domain cuối cùng.

Responses

Lỗi thường gặp

  • 400: email/domain sai hoặc domain chưa bật.
  • 404: inbox/email hết hạn hoặc không tồn tại.
  • 409: domain đã có.
  • 204: xoá thành công, không có response body.

Mailbox và email được cleanup theo ADDRESS_LIFETIME_HOURS, mặc định 24 giờ.