---
title: "change_billing"
canonical_url: "https://tweetstream.io/zh-cn/docs/api/agent-action-change-billing"
last_updated: 2026-11-05
---

# change_billing

准备一项订阅变更：套餐、周期、Instagram 或 Ultra Speed 账号额度、暂停、取消（报价会列出可用的挽留优惠）、挽留优惠、恢复、保留，或关闭自动续费。返回价格和日期；在 confirm_action 用发到对方邮箱的验证码执行之前，不会有任何变化。confirm 级：调用只会暂存并返回这项变更。request_confirmation_code 向对方邮箱发送验证码，对方读出验证码后，confirm_action 才会执行变更。同名 MCP 工具需要 tweetstream:billing 权限范围。

Canonical URL: https://tweetstream.io/zh-cn/docs/api/agent-action-change-billing

## `POST /api/agent/actions/change_billing`

`https://tweetstream.io/api/agent/actions/change_billing`

## 授权

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

## 请求体

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `change` | `object`, 必填 |  |
| `change.billingCycle` | `enum<string>`, 必填 |  |
| `change.kind` | `enum<string>`, 必填 |  |
| `change.plan` | `enum<string>`, 必填 |  |
| `family` | `enum<string>`, 必填 |  |

### 请求体示例

```json
{
  "change": {
    "billingCycle": "MONTHLY",
    "kind": "change_plan",
    "plan": "BASIC"
  },
  "family": "BASE"
}
```

## 响应字段

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `next` | `object`, 必填 |  |
| `next.action` | `enum<string>`, 必填 |  |
| `next.message` | `string`, 必填 |  |
| `next.name` | `string`, 必填 |  |
| `next.who` | `enum<string>`, 必填 |  |
| `pendingAction` | `object`, 必填 |  |
| `pendingAction.action` | `string`, 必填 |  |
| `pendingAction.expiresAt` | `string`, 必填 | a string to be decoded into a Date |
| `pendingAction.id` | `string`, 必填 |  |
| `pendingAction.quote` | `object`, 必填 |  |
| `pendingAction.quote.amountDueCents` | `integer`, 必填 | an integer |
| `pendingAction.quote.effectiveAt` | `string`, 必填 | a string to be decoded into a Date |
| `pendingAction.quote.renewal` | `object`, 必填 |  |
| `pendingAction.quote.renewal.amountCents` | `integer`, 必填 | an integer |
| `pendingAction.quote.renewal.at` | `string`, 必填 | a string to be decoded into a Date |
| `pendingAction.quote.renewal.termMonths` | `integer`, 必填 | an integer |
| `pendingAction.quote.saveOffer` | `object`, 必填 |  |
| `pendingAction.quote.saveOffer.description` | `string`, 必填 |  |
| `pendingAction.quote.saveOffer.offer` | `object`, 必填 |  |
| `pendingAction.summary` | `string`, 必填 |  |
| `status` | `enum<string>`, 必填 |  |

## 响应

| 状态 | 说明 | 请求头 |
| --- | --- | --- |
| `200` | 成功 |  |
| `400` | 输入不符合该操作的 schema（INVALID_REQUEST） |  |
| `401` | API key 缺失或无效 |  |
| `403` | 请求带有外部 Origin |  |
| `409` | 没有需要变更的内容，或不提供该变更（ACTION_REFUSED，附带 reason） |  |
| `429` | 已达到速率限制（RATE_LIMITED），请在 retryAfterSeconds 秒后重试 |  |
| `503` | 暂时不可用，请稍后重试 |  |

### 200

```json
{
  "next": {
    "action": "call_action",
    "message": "Show the person this change. If they want it, call request_confirmation_code to email them a code.",
    "name": "request_confirmation_code",
    "who": "agent"
  },
  "pendingAction": {
    "action": "change_billing",
    "expiresAt": "2026-11-05T12:05:00.000Z",
    "id": "pa_7Rk2mQ9xL4",
    "quote": {
      "amountDueCents": 0,
      "effectiveAt": "2026-11-29T12:00:00.000Z",
      "renewal": {
        "amountCents": 19900,
        "at": "2026-11-29T12:00:00.000Z",
        "termMonths": 1
      },
      "saveOffer": null
    },
    "summary": "Change your plan to Minimum, billed monthly. Takes effect Nov 29, 2026. Nothing is charged now."
  },
  "status": "confirmation_required"
}
```

### 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/actions/change_billing \
  --header "Authorization: Bearer $TWEETSTREAM_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "change": {
    "billingCycle": "MONTHLY",
    "kind": "change_plan",
    "plan": "BASIC"
  },
  "family": "BASE"
}'
```

### JavaScript

```javascript
const response = await fetch("https://tweetstream.io/api/agent/actions/change_billing", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TWEETSTREAM_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "change": {
      "billingCycle": "MONTHLY",
      "kind": "change_plan",
      "plan": "BASIC"
    },
    "family": "BASE"
  }),
});

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

### Python

```python
import os
import requests

response = requests.post(
    "https://tweetstream.io/api/agent/actions/change_billing",
    headers={"Authorization": f"Bearer {os.environ['TWEETSTREAM_API_KEY']}"},
    json={
        "change": {
            "billingCycle": "MONTHLY",
            "kind": "change_plan",
            "plan": "BASIC",
        },
        "family": "BASE",
    },
)

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