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

请求说明

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

请求参数

Path-parameters: 参考API说明与公共参数
Body:

{
    "cohort_name": "分群名",
    "cohort_type": 4,
    "description": "分群描述",
    "dsl_content": {},
    "refresh_rule": 1
}

字段含义说明

Field

Type

Description

cohort_name

int

分群名

cohort_type

int

分群类型,固定为4,即规则创建,表示通过dsl_content创建分群

description

string

分群描述信息

dsl_content

object

分群规则,可在前端UI配置后拷贝修改,详见7.3节

refresh_rule

int

1:手动刷新 2:每日例行刷新

返回参数

Response:

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

字段含义说明

Field

Type

Description

cohort_id

int

创建成功的分群id

请求示例

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

# 例如,app_id= 164314

dsl = {
    "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": 1 # 1表示手动刷新、2表示每日刷新
}
resp = bc.data_finder("/openapi/v1/164314/cohorts", body=dsl)
cohort_id = resp.json()["data"]["cohort_id"]

返回示例

返回结果:

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