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 ธรรมดา

ขั้นตอนใช้งาน

  1. ดึงโดเมนที่ใช้ได้จาก GET /domains
  2. สร้างบัญชีด้วย POST /accounts โดยส่งอีเมลและรหัสผ่าน
  3. ขอโทเค็นจาก POST /token แล้วส่งใน header Authorization: Bearer <token>
  4. อ่านข้อความจาก 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

MethodPathคำอธิบาย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}ลบบัญชีและข้อความทั้งหมด ได้ 204Bearer
GET/messages?page=1รายการข้อความ หน้าละ 30 รายการ เรียงใหม่สุดก่อนBearer
GET/messages/{id}ข้อความเต็ม (text, html[], attachments[])Bearer
PATCH/messages/{id}ตั้งสถานะอ่าน {"seen":true}Bearer
DELETE/messages/{id}ลบข้อความ ได้ 204Bearer
GET/messages/{id}/downloadดาวน์โหลดไฟล์ .emlBearer
GET/messages/{id}/attachment/{attachmentId}ดาวน์โหลดไฟล์แนบBearer
GET/sources/{id}ต้นฉบับ MIME ของข้อความ (data)Bearer
GET/eventsServer-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"
}

ข้อจำกัด