Set User Attributes API

Last updated:2023-09-21
Expand all
Set User Attributes API

In the Operation Growth platform, user attributes can be used to record basic user characteristics, such as age, gender, registration time, and similar information.

User attributes are stored and recorded in the form of a user table. The processing rule for a user attribute is determined by the rule of the attribute itself: once only, overwrite, accumulate, or append. You can set user attributes through the API below.

Setting user attributes must be based on CUID, and the user attribute must already exist in the Data Center of the Operation Growth platform.


Request Method

PUT

Request URL

PUT https://growth.jiguang.cn/smartop/api/v1/user/attribute
          PUT https://growth.jiguang.cn/smartop/api/v1/user/attribute

        
This code block is shown in the floating window

Request Header

> Content-Type: application/json > Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==
          > Content-Type: application/json
> Authorization: Basic N2Q0MzFlNDJkZmE2YTZkNjkzYWMyZDA0OjVlOTg3YWM2ZDJlMDRkOTVhOWQ4ZjBkMQ==

        
This code block is shown in the floating window

QPS Limit

QPS <= 100

Request Body Parameters

This API supports setting a single record.

In real business scenarios, do not include comments. Comments in the example below are only used to help developers understand parameter meanings.

{ "cuid":10362473, "data":{ "user_number_once":46.2, // User attribute name and attribute value "user_string_once":"refef", "user_datetime_once": "2023-12-12 00:56:23" } }
          {
 "cuid":10362473,
 "data":{
 "user_number_once":46.2, // User attribute name and attribute value
 "user_string_once":"refef",
 "user_datetime_once": "2023-12-12 00:56:23"
 }
}

        
This code block is shown in the floating window
Field Type Required Description
cuid Long Yes Unique user ID in the Operation Growth platform
data JSON Object Yes User attribute list. The key is the attribute name, and the value is the attribute value.
When the attribute value type is bool, only integers 0/1 are supported, where 0 means false and 1 means true.
When the attribute value type is datetime, only strings in yyyy-MM-dd HH:mm:ss format are supported.
  • User attribute names must be created in the platform in advance. Developers are advised to view the user attribute list first, then configure corresponding user attribute values.

Response Parameters

Field Type Required Description
code Int Yes Whether the API call succeeded. 0 means success, and other values indicate errors.
msg String Yes API call result description, text description of the error code.

Success Response

{ "code": 0, "msg": "ok" }
          {
 "code": 0,
 "msg": "ok"
}

        
This code block is shown in the floating window

Failure Response

{ "code": 40010, "msg": "用户属性[user_number_once1]不存在" }
          {
 "code": 40010,
 "msg": "用户属性[user_number_once1]不存在"
}

        
This code block is shown in the floating window

Error Codes

Error Code Description Solution
4009 API authentication failed Confirm whether the project ID and project secret are correct
40002 Invalid business parameter Check whether the data field is correct
40003 Invalid CUID Confirm whether this CUID exists in the project
40007 CUID is empty Confirm whether cuid in the request body is empty
40009 User attribute value cannot be empty Confirm whether the value of the user attribute in the request body is empty
40010 User attribute does not exist Confirm whether the user attribute has been created in the Operation Growth platform
-1 Internal server error Contact Jiguang technical support
Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center