---
title: "开始 Scale 试用"
canonical_url: "https://tweetstream.io/zh-cn/docs/api/start-agent-scale-trial"
last_updated: 2026-11-05
---

# 开始 Scale 试用

使用 TweetStream 团队提供的代码开始 Scale 试用。

Canonical URL: https://tweetstream.io/zh-cn/docs/api/start-agent-scale-trial

## `POST /api/agent/scale-trial`

`https://tweetstream.io/api/agent/scale-trial`

## 授权

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `Authorization` | `string`, 必填 | 使用 TweetStream API 密钥进行 Bearer 认证：`Bearer <key>`。 |

## 请求头

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `Idempotency-Key` | `string`, 必填 | 必填。每次购买或变更生成一个 key，重试时沿用；相同的 key 返回相同的结果。 |

## 请求体

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `code` | `string`, 必填 | a string at most 128 character(s) long |

### 请求体示例

```json
{
  "code": "SCALE-TRIAL-CODE"
}
```

## 响应字段

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `checkoutId` | `string` | a string matching the pattern ^pl_[a-z0-9]{1,64}$ |
| `family` | `enum<string>`, 必填 |  |
| `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>`, 必填 |  |
| `offer` | `object` |  |
| `offer.amountDueNow` | `object`, 必填 |  |
| `offer.amountDueNow.currency` | `enum<string>`, 必填 |  |
| `offer.amountDueNow.minor` | `string`, 必填 | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `offer.mode` | `enum<string>`, 必填 |  |
| `offer.planName` | `string`, 必填 |  |
| `offer.renewal` | `object`, 必填 |  |
| `offer.renewal.amount` | `object`, 必填 |  |
| `offer.renewal.amount.currency` | `enum<string>`, 必填 |  |
| `offer.renewal.amount.minor` | `string`, 必填 | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `offer.renewal.at` | `string`, 必填 | a string to be decoded into a Date |
| `offer.renewal.billingCycle` | `enum<string>`, 必填 |  |
| `offer.renewal.thenAmount` | `object`, 必填 |  |
| `offer.renewal.thenAmount.currency` | `enum<string>`, 必填 |  |
| `offer.renewal.thenAmount.minor` | `string`, 必填 | a string matching the pattern ^(0\|[1-9][0-9]*)$ |
| `paymentUrl` | `string` | a string matching the pattern ^(https\|wss):\/\/[^\s]+$ |
| `reason` | `enum<string>`, 必填 |  |
| `status` | `enum<string>`, 必填 |  |

## 响应

| 状态 | 说明 | 请求头 |
| --- | --- | --- |
| `200` | 成功 |  |
| `400` | 请求无效、验证码错误，或未接受服务条款 |  |
| `401` | API key 缺失或无效，或 setup proof 缺失或已过期 |  |
| `403` | 账号受到限制，或请求带有外部 Origin |  |
| `409` | 幂等键、结账、优惠或试用冲突 |  |
| `429` | 已达到速率限制或开通额度，请在 retryAfterSeconds 秒后重试 |  |
| `503` | 暂时不可用，请稍后重试 |  |

### 200

```json
{
  "status": "ready",
  "family": "BASE",
  "access": {
    "kind": "trial",
    "through": "2026-11-01T12:00:00.000Z"
  },
  "stream": {
    "url": "wss://ws-global.tweetstream.io/ws",
    "subprotocol": "tweetstream.v1",
    "credentialScope": "STANDARD"
  },
  "next": {
    "action": "select_accounts",
    "who": "agent",
    "method": "POST",
    "url": "https://tweetstream.io/api/add-account"
  },
  "optionalSteps": [
    {
      "action": "issue_discord_link",
      "who": "agent",
      "method": "POST",
      "url": "https://tweetstream.io/api/agent/discord-link"
    }
  ]
}
```

### 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"
  }
}
```

### 401

```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"
  }
}
```

### 409

```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/scale-trial \
  --header "Authorization: Bearer $TWEETSTREAM_API_KEY" \
  --header 'Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7' \
  --header 'Content-Type: application/json' \
  --data '{
  "code": "SCALE-TRIAL-CODE"
}'
```

### JavaScript

```javascript
const response = await fetch("https://tweetstream.io/api/agent/scale-trial", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TWEETSTREAM_API_KEY}`,
    "Idempotency-Key": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "code": "SCALE-TRIAL-CODE"
  }),
});

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

### Python

```python
import os
import requests

response = requests.post(
    "https://tweetstream.io/api/agent/scale-trial",
    headers={"Authorization": f"Bearer {os.environ['TWEETSTREAM_API_KEY']}", "Idempotency-Key": "7c9e6679-7425-40de-944b-e07fc1f90ae7"},
    json={
        "code": "SCALE-TRIAL-CODE",
    },
)

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