---
title: "Create Plan"
method: POST
path: "/admin/plans"
---

# Create Plan

`POST /admin/plans`

## Request

- Base URL: `https://api.twtapi.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.twtapi.com/admin/plans`
- Auth: none declared

Create a new plan.

注意：credits 不接受请求传入，而是由 monthly_limit 反推（见
internal_plan_credits），保证"额度"与"积分"不会被人为配歪。
features 以 JSON 文本落库，ensure_ascii=False 是为了让中文特性名在库里可读。

副作用：写库 + 清套餐缓存（含 C 端公开套餐列表）。

## Request body

- AdminPlanUpsert: Create or update a plan row. 中文：后台套餐的新增/编辑入参（同一模型服务两个动作）。 注意这里没有 ``id``：更新时由路径参数指定目标，新增时不带 id。 字段与 models.Plan 一一对应，改动需两侧同步。
  - `plan_type` string
  - `name` string, required
  - `price` number
  - `subscription_price` number
  - `currency` string
  - `monthly_limit` integer
  - `rate_limit_per_second` integer, nullable
  - `rate_limit_per_hour` integer, nullable
  - `features` string[]
  - `is_popular` boolean
  - `button_text` string
  - `button_style` string
  - `billing_mode` string
  - `trial_period` string, nullable
  - `validity_period` string
  - `overage_price_per_call` number, nullable
  - `sort_order` integer
  - `is_active` boolean

## Response `200`

Successful Response

- unknown

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/twtapi/apis/twtapi-backend.md) · [All operations](https://skmtc.dev/twtapi/apis/twtapi-backend/llms.txt) · [OpenAPI document](https://skmtc.dev/twtapi/apis/twtapi-backend/revisions/5295976febaf?raw)
