## 認證
了解如何獲取和使用API金鑰
## 獲取API金鑰
在開始使用API之前,您需要先獲取API金鑰。您可以在個人中心頁面建立您的API金鑰。
### 使用API金鑰
在所有API請求的請求標頭中包含您的API金鑰:
[Code (bash)]
X-API-Key: YOUR_API_KEY
[/Code]
### 注意事項
- 請妥善保管您的API金鑰,不要在公開場所洩露
- API金鑰具有與您帳戶相同的權限,請謹慎使用
- 如果您的API金鑰洩露,請立即在個人中心重新產生新的金鑰
---
## 電子郵件API
建立和管理電子郵件
## 獲取可用網域清單
獲取系統中所有可用的電子郵件網域。
### 請求
[Code (bash)]
GET /api/email/domains
[/Code]
### 請求範例
[Code (bash)]
curl https://chat-tempmail.com/api/email/domains \
-H "X-API-Key: YOUR_API_KEY"
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
domains | array | 可用的電子郵件網域清單
### 回應範例
[Code (json)]
{
"domains": [
"chat-tempmail.com",
"example.com",
"other-domain.com"
]
}
[/Code]
## 建立電子郵件
建立一個新的臨時電子郵件地址。
### 請求
[Code (bash)]
POST /api/emails/generate
[/Code]
### 請求參數
參數名 | 類型 | 必填 | 說明
-------- | ------ | ------ | ------
name | string | 是 | 電子郵件前綴
expiryTime | number | 是 | 有效期(毫秒)
可選值:
- 3600000 (1小時)
- 86400000 (1天)
- 259200000 (3天)
- 0 (永久)
domain | string | 是 | 電子郵件網域
### 請求範例
[Code (bash)]
curl -X POST https://chat-tempmail.com/api/emails/generate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "test",
"expiryTime": 3600000,
"domain": "chat-tempmail.com"
}'
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
id | string | 電子郵件的唯一識別碼(UUID格式)
email | string | 建立的電子郵件地址(完整的電子郵件地址)
### 回應範例
[Code (json)]
{
"id": "c2c4f894-c672-4d5b-a918-abca95aff1f7",
"email": "test@chat-tempmail.com"
}
[/Code]
## 獲取電子郵件清單
獲取您帳戶下的所有電子郵件清單。
### 請求
[Code (bash)]
GET /api/emails
[/Code]
### 請求參數
參數名 | 類型 | 必填 | 說明
-------- | ------ | ------ | ------
cursor | string | 否 | 分頁游標,從上一次請求的回應中獲取 nextCursor
### 請求範例
[Code (bash)]
curl https://chat-tempmail.com/api/emails \
-H "X-API-Key: YOUR_API_KEY"
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
emails | array | 電子郵件清單(每次最多返回20條資料)
nextCursor | string | 下一頁的游標,用於獲取更多資料
total | number | 電子郵件總數
### emails 陣列中的電子郵件物件
參數名 | 類型 | 說明
-------- | ------ | ------
id | string | 電子郵件的唯一識別碼(UUID格式)
address | string | 電子郵件地址(完整的電子郵件地址)
userId | string | 電子郵件所屬的使用者ID(UUID格式)
createdAt | string | 電子郵件建立時間(ISO 8601格式)
expiresAt | string | 電子郵件過期時間(ISO 8601格式)
### 回應範例
[Code (json)]
{
"emails": [
{
"id": "e4ff5c14-8a72-48c5-bd13-b5347fb944da",
"address": "6Tg3VT@chat-tempmail.com",
"userId": "bd08008d-e944-44b2-a0d0-67f2b528ee6d",
"createdAt": "2025-04-21T08:30:45.084Z",
"expiresAt": "2025-04-22T08:30:45.084Z"
}
],
"nextCursor": "fd13a8df-1465-4fbc-a612-ca7311c31ff2",
"total": 20
}
[/Code]
## 刪除電子郵件
刪除指定的電子郵件地址。
### 請求
[Code (bash)]
DELETE /api/emails/{emailId}
[/Code]
### 請求參數
參數名 | 類型 | 必填 | 說明
-------- | ------ | ------ | ------
emailId | string | 是 | 電子郵件ID(路徑參數)
### 請求範例
[Code (bash)]
curl -X DELETE "https://chat-tempmail.com/api/emails/99fadf12-6826-490a-9c6c-b0b528d4a8e0" \
-H "X-API-Key: YOUR_API_KEY"
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
success | boolean | 是否刪除成功
### 回應範例
[Code (json)]
{
"success": true
}
[/Code]
---
## 電子郵件API
管理電子郵件
## 獲取電子郵件清單
獲取指定電子郵件中的所有郵件清單。
### 請求
[Code (bash)]
GET /api/emails/{emailId}
[/Code]
### 請求參數
參數名 | 類型 | 必填 | 說明
-------- | ------ | ------ | ------
emailId | string | 是 | 電子郵件ID(路徑參數)
cursor | string | 否 | 分頁游標(查詢參數),從上一次請求的回應中獲取 nextCursor
### 請求範例
[Code (bash)]
curl "https://chat-tempmail.com/api/emails/c2c4f894-c672-4d5b-a918-abca95aff1f7" \
-H "X-API-Key: YOUR_API_KEY"
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
messages | array | 郵件清單(每次最多返回20條資料)
nextCursor | string | 下一頁的游標,用於獲取更多資料
total | number | 郵件總數
### messages 陣列中的郵件物件
參數名 | 類型 | 說明
-------- | ------ | ------
id | string | 郵件的唯一識別碼(UUID格式)
from_address | string | 寄件人地址
subject | string | 郵件主旨
received_at | number | 接收時間(Unix時間戳,毫秒)
### 回應範例
[Code (json)]
{
"messages": [
{
"id": "fd13a8df-1465-4fbc-a612-ca7311c31ff2",
"from_address": "sender1@example.com",
"subject": "Test Message 1 - xJOK2h",
"received_at": 1745224245084
}
],
"nextCursor": "eyJ0aW1lc3RhbXAiOjE3NDUxNTU4NDUwODQsImlkIjoiNjNmNzFlODYtOGE1NC00ZDQ0LTk5ZWYtN2QzNTBhMTQ4M2JiIn0=",
"total": 50
}
[/Code]
## 獲取郵件詳情
獲取指定郵件的詳細內容。
### 請求
[Code (bash)]
GET /api/emails/{emailId}/{messageId}
[/Code]
### 請求參數
參數名 | 類型 | 必填 | 說明
-------- | ------ | ------ | ------
emailId | string | 是 | 電子郵件ID(路徑參數)
messageId | string | 是 | 郵件ID(路徑參數)
### 請求範例
[Code (bash)]
curl "https://chat-tempmail.com/api/emails/99fadf12-6826-490a-9c6c-b0b528d4a8e0/fd13a8df-1465-4fbc-a612-ca7311c31ff2" \
-H "X-API-Key: YOUR_API_KEY"
[/Code]
### 回應參數
參數名 | 類型 | 說明
-------- | ------ | ------
message | object | 郵件詳情
### message 物件欄位說明
參數名 | 類型 | 說明
-------- | ------ | ------
id | string | 郵件的唯一識別碼(UUID格式)
from_address | string | 寄件人地址
subject | string | 郵件主旨
content | string | 郵件純文字內容
html | string | 郵件HTML內容(可能為空)
received_at | number | 接收時間(Unix時間戳,毫秒)
### 回應範例
[Code (json)]
{
"message": {
"id": "fd13a8df-1465-4fbc-a612-ca7311c31ff2",
"from_address": "sender1@example.com",
"subject": "Test Message 1 - xJOK2h",
"content": "Test Message 1\n\nThis is test message 1 content.\n\nBest regards,\nSender 1",
"html": "