---
title: "申请邮箱验证码"
canonical_url: "https://tweetstream.io/zh-cn/docs/api/request-agent-email-code"
last_updated: 2026-11-05
---

# 申请邮箱验证码

向对方邮箱发送 6 位验证码。新账号和已有账号收到的响应相同。请向对方索取验证码，智能体无法通过其他途径获得。

Canonical URL: https://tweetstream.io/zh-cn/docs/api/request-agent-email-code

## `POST /api/agent/email-code/request`

`https://tweetstream.io/api/agent/email-code/request`

## 请求体

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `email` | `string`, 必填 | a string that will be trimmed |

### 请求体示例

```json
{
  "email": "person@example.com"
}
```

## 响应字段

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `challengeId` | `string`, 必填 | a string matching the pattern ^[0-9a-f]{64}$ |
| `expiresAt` | `string`, 必填 | a string to be decoded into a Date |
| `next` | `object`, 必填 |  |
| `next.message` | `string` | a string at most 500 character(s) long |
| `next.action` | `enum<string>`, 必填 |  |
| `next.method` | `enum<string>`, 必填 |  |
| `next.url` | `string`, 必填 | a string matching the pattern ^(https\|wss):\/\/[^\s]+$ |
| `next.who` | `enum<string>`, 必填 |  |
| `resendAt` | `string`, 必填 | a string to be decoded into a Date |
| `status` | `enum<string>`, 必填 |  |

## 响应

| 状态 | 说明 | 请求头 |
| --- | --- | --- |
| `202` | 成功 |  |
| `400` | 请求无效、验证码错误，或未接受服务条款 |  |
| `403` | 账号受到限制，或请求带有外部 Origin |  |
| `429` | 已达到速率限制或开通额度，请在 retryAfterSeconds 秒后重试 |  |
| `503` | 暂时不可用，请稍后重试 |  |

### 202

```json
{
  "status": "awaiting_email",
  "challengeId": "4f1c9e2a7b3d8065c1e4a9f27d3b5c8e0a6f1d2b9c4e7a3f5d8b0c6e2a9f1d47",
  "expiresAt": "2026-10-29T12:10:00.000Z",
  "resendAt": "2026-10-29T12:01:00.000Z",
  "next": {
    "action": "verify_email",
    "who": "human_then_agent",
    "method": "POST",
    "url": "https://tweetstream.io/api/agent/email-code/verify"
  }
}
```

### 400

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 403

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 429

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

### 503

```json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "<string>",
    "reason": "not_offered",
    "retryAfterSeconds": 123
  },
  "next": {
    "message": "<string>",
    "action": "call_action",
    "method": "POST",
    "name": "<string>",
    "url": "<string>",
    "who": "agent"
  }
}
```

## 代码示例

### cURL

```bash
curl --request POST \
  --url https://tweetstream.io/api/agent/email-code/request \
  --header 'Content-Type: application/json' \
  --data '{
  "email": "person@example.com"
}'
```

### JavaScript

```javascript
const response = await fetch("https://tweetstream.io/api/agent/email-code/request", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "email": "person@example.com"
  }),
});

console.log(response.status, await response.json());
```

### Python

```python
import requests

response = requests.post(
    "https://tweetstream.io/api/agent/email-code/request",
    json={
        "email": "person@example.com",
    },
)

print(response.status_code, response.json())
```
