# Promo Livestream Affiliate (/zh/growseller/docs/developers/live-promos)

用一个 template 为 creator 的 Shopee LIVE 设置促销价，每个 creator 一个促销。

**用途：** 在你设定的时间段内，为部分 Shopee 商品设置只有某一位 creator 的 LIVE 观众才能享受的促销价和促销库存（Shopee 的 **Promo Livestream Affiliate**，即 Exclusive Streamer Price）。仅限 Shopee 店铺。

一个 Shopee 促销只能有一位主播。GrowSeller 保存一个 template（名称、描述、时间段、购买限制、商品及每个规格的促销价和促销库存）并加入 creator，**Publish** 会据此在 Shopee 上为每位 creator 各创建一个促销。时间为 unix 秒，价格为店铺货币（Rp）。

## 1. 创建 template [#1-创建-template]

用 [`GET /shopee/live-promos/products`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate) 选择商品，再用 `GET /shopee/live-promos/products/models?ids=…` 读取其规格、价格和库存。然后：

```bash
curl -X POST "https://seller.growpaces.com/api/v1/shopee/live-promos/templates" \
  -H "Authorization: Bearer gsk_..." \
  -H "Content-Type: application/json" \
  -d '{"shop_id":"SHOP_ID",
       "promo":{"title":"Flash LIVE Friday","description":"","start":1795483800,"end":1795491000,"purchase_limit":0},
       "products":[{"id":"23736676847","purchase_limit":2,"custom_title":"Boxer LIVE price",
                    "models":[{"model_id":"108042958718","promo_price":13999,"promo_stock":10}]}]}'
```

保存 template 时会检查 Shopee 的规则（每 50 个商品调用一次 Shopee）：名称最多 150 个字符，描述最多 200 个；促销的结束时间晚于开始时间；最多 100 个商品；每个规格的 `promo_price` 低于其价格，`promo_stock` 不超过其库存；`purchase_limit` 按每位买家计，`0` = 不限（促销最多 999,999,999，商品最多 999,999）。不符合时返回 `422` 并指出商品。`custom_title` 和 `custom_image_url`（商品自己的图片之一）是主播展示商品时使用的名称和图片，均为可选。

## 2. 添加 creator [#2-添加-creator]

[`POST /shopee/live-promos/templates/{template_id}/creators`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate) 传入 `creator_account_ids`，或某个列表（如 `GET /shopee/creators`）的 `selection`，每次最多 10,000 个；`dry_run: true` 会告诉你将发生什么。被屏蔽的 creator 不会加入。Shopee 尚未提供 user id 的 creator 为 `SKIP`：促销通过该 id 指定主播。

## 3. Publish [#3-publish]

[`POST /shopee/live-promos/templates/bulk`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate) 传入 `action: "start"` 和 template 的 `ids`，在后台创建促销（`SHOPEE_LIVE_PROMO_BROADCAST` job；`scheduled_at` 稍后发布，`action: "retry"` 重试 `FAILED` 的 creator，`action: "delete"` 删除 template）。时间段必须晚于现在开始。

为 N 个 creator 发布会调用 Shopee 2 + 2N 次：店铺进行中的促销数与 Shopee 上限（1,000）、商品能否在该时间段内促销，然后为每个 creator 创建促销及其商品。被 Shopee 拒绝的 creator 为 `FAILED`，附 Shopee 的原因（[`GET /shopee/live-promos/templates/{template_id}/creators?status=FAILED`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate)，`last_error`）；成功的为 `SUCCESS`，附其 `live_promo_id`。Shopee 接受同一 creator 时间段重叠的促销。可通过 [`GET /jobs`](/zh/growseller/docs/api-reference/jobs/get-jobs) 或 `job.completed` [webhook](/zh/growseller/docs/developers/webhooks) 跟进。

## 已发布的促销 [#已发布的促销]

[`GET /shopee/live-promos?tab=upcoming|ongoing|ended`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate) 列出 GrowSeller 保存的店铺促销；[`POST /shopee/live-promos/sync`](/zh/growseller/docs/api-reference/shopee-promo-livestream-affiliate) 从 Shopee 重新读取（`SHOPEE_LIVE_PROMO_SYNC` job；在 Shopee 自己页面创建的促销也会进来）。`GET /shopee/live-promos/{promo_id}` 从 Shopee 读取一个促销及其主播和每个规格的商品。

| 修改 | Route | 何时 |
| --- | --- | --- |
| 名称、描述、时间段、购买限制、商品 | `PATCH /shopee/live-promos/{promo_id}` | 即将开始或进行中；未传的字段保持不变 |
| 立即结束 | `POST /shopee/live-promos/{promo_id}/end` | 仅进行中 |
| 删除 | `DELETE /shopee/live-promos/{promo_id}` | 仅即将开始；已结束的促销 Shopee 会保留 |

商品在促销中通过审核后，Shopee 会拒绝修改该商品的购买限制；原因会作为 `422` 消息返回。