TTempMailREST API
API v1

TempMail API

API JSON ngắn gọn để tạo địa chỉ, đọc thư, lấy OTP và xóa thư.

https://your-domain.com/api/v1
KEYXác thực

Gửi API key trong header sau:

X-API-Key: tm_xxxxxxxxxxxxxxxxx
GET/domainsDomain
curl -H "X-API-Key: $KEY" "$BASE/domains"
{"success":true,"data":[{"name":"mail.example.com","is_default":true}]}
POST/addressesTạo địa chỉ
curl -X POST "$BASE/addresses" -H "X-API-Key: $KEY" -H "Content-Type: application/json" -d '{"username":"demo","domain":"mail.example.com"}'
{"success":true,"data":{"address":"demo@mail.example.com"}}
GET/messagesDanh sách thư

email là bắt buộc. limit mặc định 20.

curl -G "$BASE/messages" -H "X-API-Key: $KEY" --data-urlencode "email=demo@mail.example.com"
{"success":true,"data":{"count":1,"messages":[{"id":184,"subject":"Code 483921","otp_codes":[{"value":"483921"}]}]}}
GET/messages/{id}Đọc thư
curl -G "$BASE/messages/184" -H "X-API-Key: $KEY" --data-urlencode "email=demo@mail.example.com"
{"success":true,"data":{"id":184,"subject":"Code 483921","text_body":"Your code is 483921"}}
GET/otpOTP mới nhất
curl -G "$BASE/otp" -H "X-API-Key: $KEY" --data-urlencode "email=demo@mail.example.com"
{"success":true,"data":{"otp":{"value":"483921"},"message_id":184}}
DELETE/messages/{id}Xóa thư
curl -X DELETE -G "$BASE/messages/184" -H "X-API-Key: $KEY" --data-urlencode "email=demo@mail.example.com"
{"success":true,"data":{"deleted":true,"id":184}}
POST/messages/{id}/deleteXóa thư bằng POST

Dùng endpoint này khi hosting chặn HTTP DELETE.

curl -X POST -G "$BASE/messages/184/delete" -H "X-API-Key: $KEY" --data-urlencode "email=demo@mail.example.com"
{"success":true,"data":{"deleted":true,"id":184}}
Lỗi {"success":false,"error":{"code":"invalid_api_key","message":"..."}}