> For the complete documentation index, see [llms.txt](https://growingio.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://growingio.gitbook.io/docs/developer-manual/api-reference/customize-api/old-definition/uservar.md).

# 用户变量上传

## 获取认证码

旧版本上传接口使用 cs1-cs20 的方式上传用户属性，对应的签名计算中 keyArray 为1234,1235。加密 Message 为 `ai=$projectKeyId&cs=$keyArray`

如 Java：

```java
public String authToken(String projectKeyId, String secretKey, String keyArray) throws Exception {
    String message = "ai="+projectKeyId+"&cs="+keyArray;
    Mac hmac = Mac.getInstance("HmacSHA256");
    hmac.init(new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256"));
    byte[] signature = hmac.doFinal(message.getBytes("UTF-8"));
    return Hex.encodeHexString(signature);
}
```

## 接口定义

#### URL

<https://data.growingio.com/saas/{ai}/user>

#### 请求类型

POST

#### 参数说明

{% tabs %}
{% tab title="请求参数" %}

| 请求头参数        | 类型     | 是否必传 | 说明              |
| ------------ | ------ | ---- | --------------- |
| Access-Token | string | 是    | Public Key，项目公钥 |

| 路径参数 | 类型     | 是否必传 | 说明   |
| ---- | ------ | ---- | ---- |
| ai   | string | 是    | 项目ID |

| 查询参数 | 类型     | 是否必传 | 说明                            |
| ---- | ------ | ---- | ----------------------------- |
| auth | string | 是    | 针对每条数据独立生成的认证，详细见本页面的获取认证码页签。 |

| body参数        | 类型     | 是否必传 | 说明                                              |
| ------------- | ------ | ---- | ----------------------------------------------- |
| cs1           | string | 是    | 登录用户ID。                                         |
| cs2           | string | 否    | <p>用户属性2。</p><p>旧版本上传接口使用cs1-cs20的字段上传用户属性。</p> |
| {% endtab %}  |        |      |                                                 |
| {% endtabs %} |        |      |                                                 |
