## 认证
了解如何获取和使用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": "