跳转到主要内容
将产品组从测试环境发布到生产环境。使用 UPSERT 行为 — 您可以在修改后重新发布,与仅支持首次发布的商品发布不同。
POST /v1/actions/subscription-product-group/publish-group
认证方式: API Key
此端点不要包含 X-Environment 请求头。发布始终是从 test 到 production 的单向操作。

请求体

字段类型必需说明
idstring产品组 ID(UUID 格式,必须为测试环境的组)

请求示例

await client.subscriptionProductGroups.publish({
  id: "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
});
// Uses callApi() helper from authentication.mdx
const result = await callApi("POST", "/v1/actions/subscription-product-group/publish-group", {
  id: "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
});
console.log(result.data);
// Uses callApi() helper from authentication.mdx
String body = """
    {"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a"}""";

String response = callApi("POST", "/v1/actions/subscription-product-group/publish-group", body);
System.out.println(response);
# Uses call_api() helper from authentication.mdx
result = call_api("POST", "/v1/actions/subscription-product-group/publish-group", {
    "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
})
print(result["data"])
// Uses callAPI() helper from authentication.mdx
body := map[string]interface{}{
    "id": "d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a",
}
result, err := callAPI("POST", "/v1/actions/subscription-product-group/publish-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"
});
let result = call_api("POST", "/v1/actions/subscription-product-group/publish-group", &body).await?;
println!("{}", result);
/* Uses call_api() helper from authentication.mdx */
const char *body = "{\"id\":\"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a\"}";
char *response = call_api("POST", "/v1/actions/subscription-product-group/publish-group", body);
printf("%s\n", response);
free(response);
// Uses callApi() helper from authentication.mdx
std::string body = R"({"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a"})";
std::string response = callApi("POST", "/v1/actions/subscription-product-group/publish-group", body);
std::cout << response << std::endl;
MERCHANT_ID="MER_2aUyqjCzEIiEcYMKj7TZtw"
TIMESTAMP=$(date +%s)
BODY='{"id":"d4e5f6a7-b8c9-0d1e-2f3a-4b5c6d7e8f9a"}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/subscription-product-group/publish-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/publish-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"}'
BODY_HASH=$(echo -n "$BODY" | openssl dgst -sha256 -binary | base64 -w 0)
CANONICAL_REQUEST="POST
/v1/actions/subscription-product-group/publish-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/publish-group" \
  --header="Content-Type: application/json" \
  --header="X-Merchant-Id: $MERCHANT_ID" \
  --header="X-Timestamp: $TIMESTAMP" \
  --header="X-Signature: $SIGNATURE" \
  --post-data="$BODY"
与商品发布不同,产品组发布支持重复 UPSERT 操作。您可以随时更新测试组并重新发布到生产环境。生产组将被创建或更新以匹配当前测试组。

错误响应

重试策略:4xx 一律不要重试 — 修正请求后重发。5xx 指数退避重试(起步 5s,最多 3 次)。
状态码errors[0].message含义推荐处理
400Missing required field: id请求体缺少 id补齐 id 后重发
400Can only publish test environment groups指定的产品组已在 production(或非 test 环境)仅 test 环境的产品组可发布
400Cannot publish: product_ids is empty产品组无成员商品通过 update-group 添加至少一个商品后重发
404Group not found指定 id 的产品组不存在验证 id 是否属于你的门店
500Internal server error内部错误或瞬时下游故障指数退避重试(起步 5s,最多 3 次)