REST API
API รูปแบบเดียวกับ mail.tm ใช้กับไลบรารีของ mail.tm ได้โดยเปลี่ยน base URL เป็น
https://tm.itgenius.co.th (หรือ https://tm.itgenius.co.th/api) ตอบกลับเป็น JSON-LD (Hydra) โดยค่าเริ่มต้น
ส่ง Accept: application/json เพื่อรับเป็นอาร์เรย์ JSON ธรรมดา
ขั้นตอนใช้งาน
- ดึงโดเมนที่ใช้ได้จาก
GET /domains - สร้างบัญชีด้วย
POST /accountsโดยส่งอีเมลและรหัสผ่าน - ขอโทเค็นจาก
POST /tokenแล้วส่งใน headerAuthorization: Bearer <token> - อ่านข้อความจาก
GET /messagesหรือรับแบบเรียลไทม์จากGET /events
BASE=https://tm.itgenius.co.th
curl -s $BASE/domains -H 'Accept: application/json'
curl -s -X POST $BASE/accounts -H 'Content-Type: application/json' \
-d '{"address":"demo123@tm.itgenius.co.th","password":"secret-pass"}'
TOKEN=$(curl -s -X POST $BASE/token -H 'Content-Type: application/json' \
-d '{"address":"demo123@tm.itgenius.co.th","password":"secret-pass"}' | jq -r .token)
curl -s $BASE/messages -H "Authorization: Bearer $TOKEN"
Endpoints
| Method | Path | คำอธิบาย | Auth |
|---|---|---|---|
| GET | /domains | รายการโดเมนที่รับอีเมล | - |
| GET | /domains/{id} | ข้อมูลโดเมน | - |
| POST | /accounts | สร้างบัญชี {"address","password"} ได้ 201 หรือ 422 เมื่อชื่อซ้ำ/ไม่ถูกต้อง | - |
| POST | /token | เข้าสู่ระบบ ได้ {"id","token"} | - |
| GET | /me | ข้อมูลบัญชีปัจจุบัน (quota, used) | Bearer |
| GET | /accounts/{id} | ข้อมูลบัญชี | Bearer |
| DELETE | /accounts/{id} | ลบบัญชีและข้อความทั้งหมด ได้ 204 | Bearer |
| GET | /messages?page=1 | รายการข้อความ หน้าละ 30 รายการ เรียงใหม่สุดก่อน | Bearer |
| GET | /messages/{id} | ข้อความเต็ม (text, html[], attachments[]) | Bearer |
| PATCH | /messages/{id} | ตั้งสถานะอ่าน {"seen":true} | Bearer |
| DELETE | /messages/{id} | ลบข้อความ ได้ 204 | Bearer |
| GET | /messages/{id}/download | ดาวน์โหลดไฟล์ .eml | Bearer |
| GET | /messages/{id}/attachment/{attachmentId} | ดาวน์โหลดไฟล์แนบ | Bearer |
| GET | /sources/{id} | ต้นฉบับ MIME ของข้อความ (data) | Bearer |
| GET | /events | Server-Sent Events เมื่อมีข้อความใหม่ (event: message) รองรับ /.well-known/mercure?topic=/accounts/{id} ด้วย | Bearer |
ตัวอย่างข้อความ
{
"id": "6740c1f2a9e3b4d5c6e7f801",
"accountId": "/accounts/6740c1d0a9e3b4d5c6e7f800",
"msgid": "<abc@example.com>",
"from": { "address": "noreply@example.com", "name": "Example" },
"to": [{ "address": "demo123@tm.itgenius.co.th", "name": "" }],
"subject": "Your verification code",
"intro": "Your code is 123456",
"seen": false,
"hasAttachments": false,
"size": 2048,
"downloadUrl": "/messages/6740c1f2a9e3b4d5c6e7f801/download",
"createdAt": "2026-11-19T12:00:00.000Z"
}
ข้อจำกัด
- รับอีเมลอย่างเดียว ไม่รองรับการส่งออก
- จำกัด 40 คำขอต่อ 5 วินาทีต่อ IP สร้างบัญชีได้ 20 บัญชีต่อ 10 นาทีต่อ IP เกินจะได้
429 - ขนาดอีเมลสูงสุด 10 MiB ต่อฉบับ พื้นที่ 40 MiB ต่อบัญชี
- ข้อความถูกลบอัตโนมัติหลัง 7 วัน บัญชีที่ไม่ได้ใช้งาน 30 วันจะถูกลบ
- ชื่อผู้ใช้ 3–64 ตัว ใช้ a-z 0-9 . _ - รหัสผ่าน 6–128 ตัว