MailRent.vn / API Docs
MAILRENT API · V1

Tích hợp thuê mail OTP nhanh chóng

Dùng API key của tài khoản để lấy mailbox, đọc OTP, theo dõi lịch sử thuê.

BASE URLhttp://127.0.0.1:2012

Xác thực

API key

Lấy API key tại Hồ sơ. Gửi key trong header X-API-Key hoặc Authorization: Bearer ở mọi request API V1.

CURL
curl http://127.0.0.1:2012/api/v1/me \ -H "X-API-Key: mrk_your_api_key"
JAVASCRIPT (FETCH)
const response = await fetch( "http://127.0.0.1:2012/api/v1/me", { headers: { "X-API-Key": apiKey } } ); const data = await response.json();
Bảo mật API key. Không đưa key vào frontend công khai, ảnh chụp màn hình hoặc repository. Bấm nút tạo key mới trong Hồ sơ nếu key bị lộ.

API người dùng

Đọc dữ liệu của chính tài khoản
GET/api/v1/me

Thông tin tài khoản

Trả về tên đăng nhập, email, họ tên và số dư xu hiện có.

API KEY
REQUEST
curl http://127.0.0.1:2012/api/v1/me \ -H "X-API-Key: mrk_your_api_key"
RESPONSE · 200
{ "user": { "username": "phatchau036", "email": "user@example.com", "full_name": "Phat Chau", "balance": 5000 } }
GET/api/v1/mail?mailbox=mail@example.com

Đọc mail và OTP

Không truyền mailbox để lấy tóm tắt OTP từ các đơn thuê. Truyền mailbox để đọc nội dung mail từ IMAP.

API KEY
REQUEST
curl "http://127.0.0.1:2012/api/v1/mail?mailbox=mail@example.com" \ -H "Authorization: Bearer mrk_your_api_key"
RESPONSE · 200
{ "mailbox": "mail@example.com", "messages": [{ "uid": "42", "subject": "Your verification code", "otp": "123456", "date": "Fri, 22 Aug 2026 ..." }] }
GET/api/v1/mailboxes

Danh sách mailbox đã được cấp

Lấy các mailbox thuộc tài khoản hiện tại và thông tin dịch vụ đã dùng.

API KEY
REQUEST
curl http://127.0.0.1:2012/api/v1/mailboxes \ -H "X-API-Key: mrk_your_api_key"
RESPONSE · 200
{ "mailboxes": [{ "mailbox": "mail@example.com", "note": "iCloud OTP", "created_at": "22/08/2026 08:23" }] }
GET/api/v1/mail-history?mailbox=mail@example.com

Lịch sử mailbox và dịch vụ

Lọc theo một mailbox bằng query mailbox hoặc bỏ query để lấy toàn bộ lịch sử của tài khoản.

API KEY
REQUEST
curl "http://127.0.0.1:2012/api/v1/mail-history" \ -H "X-API-Key: mrk_your_api_key"
RESPONSE · 200
{ "history": [{ "mailbox": "mail@example.com", "service_name": "Facebook", "status": "completed" }] }
GET/api/v1/rentals

Lịch sử đơn thuê

Trả về các đơn thuê, trạng thái và OTP nếu đã nhận được.

API KEY
REQUEST
curl http://127.0.0.1:2012/api/v1/rentals \ -H "X-API-Key: mrk_your_api_key"
RESPONSE · 200
{ "rentals": [{ "id": 15, "service": "Facebook", "email": "mail@example.com", "otp": "123456", "status": "completed" }] }

Xử lý lỗi

API KEY KHÔNG HỢP LỆ · 401
{ "error": "Valid API key required..." }
MAILBOX KHÔNG TỒN TẠI / CHƯA GÁN IMAP · 404
{ "error": "Mailbox not found or no IMAP source assigned." }