You need to enable JavaScript to run this app.
导航
修改创建分群
最近更新时间:2024.06.30 18:36:03首次发布时间:2024.06.30 18:36:03

请求说明

Path:/openapi/v1/{app_id}/cohorts/{cohort_id}
Method: PATCH
Content-type: application/json

请求参数

Path-parameters:

参数

类型

是否必选

示例值

描述

cohort_id

int

1001076

分群ID

Body:
修改通过上传文件创建分群:

{
    "cohort_name": "分群名",
    "cohort_type": 2, //2为文件上传类型的分群
    "description": "分群描述",
    "dsl_content": {
        "uuid_file_key": "upload_uuid/164314/20220819/1eb8f3c6-4447-4e9c-a538-c1b33a1cd0e4.csv", 
        // uuid_file_key需要通过9.1接口上传文件后获取
        "file_list": [
            {
                "name": "user_unique_id_template (3).csv" //上传文件的名称
            }
        ],
        "dsl_type": "user_unique_id" // 支持user_unique_id、ssid、device_id、web_id
    },
    "refresh_rule": 1
}

修改规则创建分群:

{
    "cohort_name": "分群名",
    "cohort_type": 4 //4为规则上传类型的分群
    "description": "分群描述",
    "dsl_content": {},
    "refresh_rule": 1
}

返回参数

Response:

{
    "code": 200,
    "message": "success",
    "data": null
}

请求示例

bc 为创建的 RangersClient, 其初始化请参考使用说明, 各语言的 SDK 都提供了类似的接口
调用(Python):

# 例如,app_id= 164314 cohort id= 1001076
body = {
    "cohort_name": "openapi-修改",
    "cohort_type": 4, // 4表示规则创建
    "description": "",
    "dsl_content": {
        "periods": [],
        "app_ids": [
            164314
        ],
        "content": {
            "profile_filters": [],
            "profile_groups": [],
            "queries": [
                [
                    {
                        "show_label": "event--A--A",
                        "event_name": "any_event",
                        "event_type": "origin",
                        "next_query_label": null,
                        "sequence_first": true,
                        "logic": true,
                        "condition": {
                            "property_operation": ">",
                            "property_values": [
                                0
                            ],
                            "period": {
                                "granularity": "day",
                                "last": {
                                    "amount": 7,
                                    "unit": "day"
                                },
                                "type": "last",
                                "timezone": "Asia/Shanghai"
                            }
                        },
                        "filters": [
                            {
                                "expression": {
                                    "logic": "and",
                                    "conditions": []
                                }
                            }
                        ],
                        "event_indicator": "events"
                    }
                ]
            ],
            "query_type": "$cohort"
        },
        "version": 3
    },
    "refresh_rule": 2 # 从1修改为2
}
resp = bc.data_finder("/openapi/v1/164314/cohorts/1001076", body=dsl)
cohort_id = resp.json()["data"]["cohort_id"]

返回示例

返回结果:

{
    "code": 200,
    "message": "success",
    "data": {
        "cohort_id": 1001076
    }
}