TempMail Developer API
Tích hợp email tạm thời vào ứng dụng của bạn trong vài phút. Tạo địa chỉ, đọc email, lấy OTP — tất cả qua REST API đơn giản.
Authorization: Bearer <key>https://webmail.loveyuna.todayXác thực
Tất cả endpoint /v1/* yêu cầu API key trong header:
Authorization: Bearer tm_your_api_key_here
Để lấy API key, vào ứng dụng TempMail → nút API trên sidebar.
Lỗi & Mã lỗi
Mọi response lỗi có format:
{
"ok": false,
"error": "Mô tả lỗi",
"code": "ERROR_CODE"
}
| HTTP | Code | Mô tả |
|---|---|---|
| 401 | UNAUTHORIZED |
Thiếu Authorization header |
| 401 | INVALID_KEY |
API key không hợp lệ hoặc đã bị xóa |
| 400 | INVALID_ADDRESS |
Địa chỉ email không hợp lệ |
| 403 | FORBIDDEN |
Email không thuộc địa chỉ yêu cầu |
| 404 | NOT_FOUND |
Email không tồn tại |
| 429 | RATE_LIMITED |
Vượt quá 200 req/giờ |
| 500 | INTERNAL |
Lỗi server |
Rate Limit
Mỗi API key được phép 200 requests/giờ. Thông tin rate limit trả về trong header mỗi response:
X-RateLimit-Limit: 200 X-RateLimit-Remaining: 187 X-RateLimit-Reset: 1746363600
Developer Endpoints
Tất cả cần Authorization: Bearer <key>
Trả về thông tin API key hiện tại và rate limit.
curl -H "Authorization: Bearer tm_your_key" \
https://webmail.loveyuna.today/v1/me
{
"ok": true,
"data": {
"key": "tm_a3f9b2c1...",
"label": "My App",
"createdAt": 1746300000000,
"requestCount": 13,
"rateLimit": {
"limit": 200,
"remaining": 187,
"resetAt": 1746363600
}
}
}
Tạo một địa chỉ email tạm thời mới.
| Param | Type | Mặc định | Mô tả |
|---|---|---|---|
ttl |
integer | 3600 | Thời gian sống (giây): 600, 1800, 3600, 21600, 86400 |
curl -H "Authorization: Bearer tm_your_key" \
"https://webmail.loveyuna.today/v1/address?ttl=1800"
{
"ok": true,
"data": {
"address": "ab3f9c@webmail.loveyuna.today",
"ttl": 1800,
"domain": "webmail.loveyuna.today",
"expiresAt": 1746301800
}
}
Lấy danh sách email trong inbox của địa chỉ. Tự động làm mới TTL.
curl -H "Authorization: Bearer tm_your_key" \
https://webmail.loveyuna.today/v1/inbox/ab3f9c@webmail.loveyuna.today
{
"ok": true,
"data": {
"address": "ab3f9c@webmail.loveyuna.today",
"count": 1,
"emails": [
{
"id": "uuid-...",
"from": "noreply@service.com",
"subject": "Mã xác nhận của bạn",
"date": "2025-05-04T10:00:00Z",
"receivedAt": 1746300000000,
"hasHtml": true,
"otp": "382910",
"attachments": []
}
]
}
}
Lấy nội dung đầy đủ của email (HTML, text, attachments).
| Param | Bắt buộc | Mô tả |
|---|---|---|
address |
✓ | Địa chỉ nhận email (để xác minh ownership) |
curl -H "Authorization: Bearer tm_your_key" \
"https://webmail.loveyuna.today/v1/email/uuid?address=ab3f9c@webmail.loveyuna.today"
{
"ok": true,
"data": {
"email": {
"id": "uuid-...",
"from": "noreply@service.com",
"to": "ab3f9c@webmail.loveyuna.today",
"subject": "Mã xác nhận",
"date": "2025-05-04T10:00:00Z",
"receivedAt": 1746300000000,
"text": "Mã của bạn là: 382910",
"html": "<p>Mã của bạn là: <b>382910</b></p>",
"otp": "382910",
"attachments": []
}
}
}
Xóa email khỏi inbox.
curl -X DELETE \
-H "Authorization: Bearer tm_your_key" \
"https://webmail.loveyuna.today/v1/email/uuid?address=ab3f9c@webmail.loveyuna.today"
{ "ok": true, "data": { "deleted": true, "id": "uuid-..." } }
Key Management
Không cần xác thực — dùng từ trình duyệt
Tạo API key mới. Key được lưu trong Redis.
curl -X POST https://webmail.loveyuna.today/api/keys \
-H "Content-Type: application/json" \
-d '{"label": "My App"}'
{ "key": "tm_a3f9b2c1...", "label": "My App", "createdAt": 1746300000000 }
Lấy thông tin và usage của một API key.
{ "key": "tm_...", "label": "My App", "createdAt": 1746300000000, "requestCount": 42 }
Thu hồi và xóa vĩnh viễn API key. Mọi request dùng key này sau đó sẽ nhận 401.
{ "deleted": true }