跳转到主要内容
更新产品组的名称、描述、规则或商品列表。
POST /v1/actions/subscription-product-group/update-group
认证方式: API Key

请求体

字段类型必需说明
idstring产品组 ID(UUID 格式)
namestring更新后的组名称
descriptionstring更新后的描述
rulesobject更新后的规则({ sharedTrial: boolean }
productIdsstring[]更新后的商品列表(PROD_xxx 格式)。替换整个列表。

请求示例

const { group } = await client.subscriptionProductGroups.update({
  id: "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
  name: "Updated Pricing Plans",
  productIds: [
    "PROD_3F7H2J5L8N1Q4S6U",
    "PROD_8B4D6F9H2K5M7P1R",
  ],
});
// Uses callApi() helper from authentication.mdx
const result = await callApi("POST", "/v1/actions/subscription-product-group/update-group", {
  id: "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
  name: "Updated Pricing Plans",
  productIds: [
    "PROD_3F7H2J5L8N1Q4S6U",
    "PROD_8B4D6F9H2K5M7P1R",
  ],
});
console.log(result.data);
// Uses callApi() helper from authentication.mdx
String body = """
    {"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a","name":"Updated Pricing Plans","productIds":["PROD_3F7H2J5L8N1Q4S6U","PROD_8B4D6F9H2K5M7P1R"]}""";

String response = callApi("POST", "/v1/actions/subscription-product-group/update-group", body);
System.out.println(response);
# Uses call_api() helper from authentication.mdx
result = call_api("POST", "/v1/actions/subscription-product-group/update-group", {
    "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
    "name": "Updated Pricing Plans",
    "productIds": [
        "PROD_3F7H2J5L8N1Q4S6U",
        "PROD_8B4D6F9H2K5M7P1R",
    ],
})
print(result["data"])
// Uses callAPI() helper from authentication.mdx
body := map[string]interface{}{
    "id":   "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
    "name": "Updated Pricing Plans",
    "productIds": []string{
        "PROD_3F7H2J5L8N1Q4S6U",
        "PROD_8B4D6F9H2K5M7P1R",
    },
}
result, err := callAPI("POST", "/v1/actions/subscription-product-group/update-group", body)
if err != nil {
    log.Fatal(err)
}
fmt.Println(string(result))
// Uses call_api() helper from authentication.mdx
let body = serde_json::json!({
    "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
    "name": "Updated Pricing Plans",
    "productIds": [
        "PROD_3F7H2J5L8N1Q4S6U",
        "PROD_8B4D6F9H2K5M7P1R"
    ]
});
let result = call_api("POST", "/v1/actions/subscription-product-group/update-group", &body).await?;
println!("{}", result);
/* Uses call_api() helper from authentication.mdx */
const char *body = "{\"id\":\"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a\",\"name\":\"Updated Pricing Plans\",\"productIds\":[\"PROD_3F7H2J5L8N1Q4S6U\",\"PROD_8B4D6F9H2K5M7P1R\"]}";
char *response = call_api("POST", "/v1/actions/subscription-product-group/update-group", body);
printf("%s\n", response);
free(response);
// Uses callApi() helper from authentication.mdx
std::string body = R"({"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a","name":"Updated Pricing Plans","productIds":["PROD_3F7H2J5L8N1Q4S6U","PROD_8B4D6F9H2K5M7P1R"]})";
std::string response = callApi("POST", "/v1/actions/subscription-product-group/update-group", body);
std::cout << response << std::endl;
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{
  "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
  "name": "Updated Pricing Plans",
  "productIds": [
    "PROD_3F7H2J5L8N1Q4S6U",
    "PROD_8B4D6F9H2K5M7P1R"
  ]
}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/subscription-product-group/update-group
$TIMESTAMP
$BODY_HASH"

SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

curl -X POST "https://api.waffo.ai/v1/actions/subscription-product-group/update-group" \
  -H "Content-Type: application/json" \
  -H "X-Merchant-Id: $MERCHANT_ID" \
  -H "X-Timestamp: $TIMESTAMP" \
  -H "X-Signature: $SIGNATURE" \
  -d "$BODY"
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{
  "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
  "name": "Updated Pricing Plans",
  "productIds": [
    "PROD_3F7H2J5L8N1Q4S6U",
    "PROD_8B4D6F9H2K5M7P1R"
  ]
}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/subscription-product-group/update-group
$TIMESTAMP
$BODY_HASH"

SIGNATURE=$(echo -n "$CANONICAL_REQUEST" | openssl dgst -sha256 -sign private_key.pem | base64 -w 0)

wget -qO- "https://api.waffo.ai/v1/actions/subscription-product-group/update-group" \
  --header="Content-Type: application/json" \
  --header="X-Merchant-Id: $MERCHANT_ID" \
  --header="X-Timestamp: $TIMESTAMP" \
  --header="X-Signature: $SIGNATURE" \
  --post-data="$BODY"
productIds 字段替换整个商品列表。要添加商品,请包含所有现有商品 ID 加上新的。要移除商品,从列表中省略即可。

错误响应

重试策略:4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试(起步 5s,最多 3 次)。
状态码errors[0].message含义推荐处理
400Missing required field: id请求体缺少 id补齐 id 后重发
400Expected format: PROD_xxx, got "..."productIds 中的 Short ID 无法解码修正 ID 后重发
404Group not found指定 id 的产品组不存在验证 id 是否属于你的门店
500Internal server error内部错误或瞬时下游故障指数退避重试(起步 5s,最多 3 次)