---
metadata:
  - name: generator
    content: Diplodoc Platform v5.64.0
alternate:
  - https://boost.yandex.com/doc/en/analytics/content/mobile-api/post/post-profile-attributes.md
  - https://boost.yandex.com/doc/ru/analytics/content/mobile-api/post/post-profile-attributes.md
  - https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-profile-attributes.md
  - href: https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-profile-attributes.md
    type: text/markdown
    title: Markdown version
  - href: https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/zh/llms.txt?revision=r21738064

# 个人资料属性

传输用户参数。

使用示例：您可以通过 Post API 发送用户参数，以补充用户档案，并使用这些数据进行基于用户群体的分段。 例如，添加一个属性，表示用户是忠诚计划的成员。

事件属性可以通过参数或请求体传递。 当您在请求体中传递数据时，应在请求 URL 中添加 `.csv`。 要了解更多信息，请查看[示例请求](#sample)。

要将事件绑定到用户，您需要在API请求中使用以下字段之一：

- `profile_id`
- `appmetrica 设备 ID`

{% note alert %}

Post API 有数据加载限制。 要了解更多信息，请查看[限制](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/restrictions.md)。

{% endnote %}

## 请求格式 {#request-format}

```
提交 https://api.boost.yandex.com/logs/v1/import/profiles
  ? post_api_key=<string>
  & application_id=<int>
  & profile_id=<string>
  & attributes=<>
```

#|
|| `post API 密钥`* | 用于数据上传的令牌。 您可以在应用的 **设置** 部分获取它。 ||
|| `应用ID`* | 应用在 Analytics module 中的唯一数字标识符。 ||
|| `profile_id`* | 用户个人资料 ID。 Post API 仅允许您上传先前通过 SDK 发送的标识符的数据。

{% note alert %}

不要传递 `appmetrica_device_id` 参数的值。 服务器只接受这些参数中的一个。

{% endnote %}

||
|| `attributes`* | 一组自定义属性值，格式为 `{key:value}`。 可能的值类型：字符串、数字、布尔值或计数器。 如果传递的属性值已为该账户记录，它将被新值覆盖。 之前的属性值将被删除。 了解更多关于[用户资料属性](https://boost.yandex.com/doc/zh/analytics/content/data-collection/profile-attributes.md)的信息。

{% note alert %}

要收集自定义个人资料属性，请在应用设置中添加它们。 要做这一步，打开应用页面，选择**设置**，然后点击**个人属性**。

{% endnote %}
||
|#

### First-party data {#fpd}

第一方数据（FPD，1PD）指的是登录信息、电子邮箱、电话号码、内部标识符（如`user_id`和`CRM_id`等），以及其他能唯一识别用户的数据。 这可以确保用户在服务的网页界面执行部分操作、在移动应用执行其他操作时，或者使用不同设备（例如在智能手机上使用移动应用和在平板上使用）时，用户操作能正确关联。

Analytics module 不以纯文本形式存储第一方数据属性值。 已传递的标识符会以哈希形式保存，用于跨设备和平台匹配用户操作。 用户个人资料仅包含有关为该用户传递的第一方数据属性的信息。

Post API 支持发送以下属性：

- `appmetrica_1pd_phone_sha256_0`..`appmetrica_1pd_phone_sha256_9` — 电话号码哈希值（最多10个值）；
- `appmetrica_1pd_email_sha256_0`..`appmetrica_1pd_email_sha256_9` — 电子邮箱地址哈希值（最多10个值）；
- `appmetrica_1pd_telegram_sha256` — Telegram 登录哈希（一个值）。

示例：发送电话号码哈希的请求

```
POST（提交） https://api.boost.yandex.com/logs/v1/import/profiles
  ? post_api_key=<string>
  & application_id=<int>
  & profile_id=<string>
  & attributes={"appmetrica_1pd_phone_sha256_0":"<string>"}
```

在发送包含第一方数据属性的请求时，Analytics module会自动生成名称为`appmetrica_1pd_phone_0`..`appmetrica_1pd_phone_9`、`appmetrica_1pd_email_0`..`appmetrica_1pd_email_9`、`appmetrica_1pd_telegram`的属性。

您可以通过布尔型个人资料属性来验证第一方数据属性是否已传递：

- `appmetrica_1pd_phone_passed` — 等于 `true`，如果用户至少提供了 `appmetrica_1pd_phone_sha256_*` 属性的一个有效值。
- `appmetrica_1pd_email_passed` — 等于 `true`，如果用户至少提供了 `appmetrica_1pd_email_sha_256_*` 属性的一个有效值。
- `appmetrica_1pd_telegram_passed` — 等于 `true`，如果从用户收到了 `appmetrica_1pd_telegram_sha256` 属性的有效值。

该Analytics module接口不会显示传递的FPD，但您可以在[个人资料列表](https://boost.yandex.com/doc/zh/analytics/content/mobile-reports/profile-list.md)中验证已传递第一方数据属性——在分段参数中以及**预定义属性**子部分中按个人资料属性进行分组。

{% cut "个人资料列表中的分段" %}

![用户列表中的分段](../../../_images/profile-fpd-segment-zh.png){style="border: solid 1px #cccccc; max-width: 400px;"}

{% endcut %}

{% cut "在个人资料列表中分组" %}

![在个人资料列表中分组](../../../_images/profile-fpd-grouping-zh.png){style="border: solid 1px #cccccc; max-width: 500px;"}

{% endcut %}

通过 SDK 也可发送第一方数据属性：

- [对于 Android](https://boost.yandex.com/doc/zh/analytics/content/sdk/android/analytics/android-operations.md#send-attribute-profile-1pd)
- [用于 iOS](https://boost.yandex.com/doc/zh/analytics/content/sdk/ios/analytics/ios-operations.md#send-attribute-profile-1pd)

## Response codes {#response-codes}

| Code | 描述 |
| ----- | ----- |
| 200 | 数据已成功上传。 |
| 403 | 请求缺少授权头，或指定了无效的令牌。 |
| 400 | 请求中缺少一个或多个必需参数。 |

## 示例请求 {#sample}

{% list tabs %}

- 在请求体中发送数据

  ```http translate=no
  POST /logs/v1/import/profiles.csv?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012 HTTP/1.1
  Host: api.boost.yandex.com
  Connection: close

  application_id,profile_id,attributes
  1234567890,1234567890abcdef,"{""string_attribute_name"":""string_value"",""number_attribute_name"":1234,""bool_attribute_name"":true,""counter_attribute_name"":-1}"
  ```

  发送第一方数据：

  ```http translate=no
  POST /logs/v1/import/profiles.csv?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012 HTTP/1.1
  Host: api.boost.yandex.com
  Connection: close
  
  application_id,profile_id,attributes
  1234567890,1234567890abcdef,"{""appmetrica_1pd_phone_sha256_0"":""phone-number-hash"",""appmetrica_1pd_email_0"":""email-hash"",""appmetrica_1pd_telegram"":""login-hash""}"
  ```

- 通过请求参数发送数据

  ```http translate=no
  POST /logs/v1/import/profiles?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012&application_id=1234567890&profile_id=1234567890abcdef&attributes={"string_attribute_name":"string_value","number_attribute_name":1234,"bool_attribute_name":true,"counter_attribute_name":-1} HTTP/1.1
  Host: api.boost.yandex.com
  Content-Length: 0
  Connection: close
  ```

  发送第一方数据：

  ```http translate=no
  POST /logs/v1/import/profiles?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012&application_id=1234567890&profile_id=1234567890abcdef&attributes={"appmetrica_1pd_phone_sha256_0":"phone-number-hash","appmetrica_1pd_email_0":"email-hash","appmetrica_1pd_telegram":"login-hash"} HTTP/1.1
  Host: api.boost.yandex.com
  Content-Length: 0
  Connection: close
  ```

{% endlist %}

你只能使用 Post API 来修改用户的[自定义](https://boost.yandex.com/doc/zh/analytics/content/data-collection/profile-attributes.md#custom)属性。 要传递[预定义](https://boost.yandex.com/doc/zh/analytics/content/data-collection/profile-attributes.md)属性，请使用AppMetrica SDK。 有关更多信息，请参阅[设置发送属性配置](https://boost.yandex.com/doc/zh/analytics/content/data-collection/about-profiles.md#profile-settings)。

## 其他 Post API 方法 {#other-methods}

- [上传事件](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-import-events.md)
- [上传应用内收入事件](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-revenue.md)
- [上传广告收入事件](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-adrevenue.md)
- [上传电商事件](https://boost.yandex.com/doc/zh/analytics/content/mobile-api/post/post-ecommerce.md)

<!-- source: zh/analytics/content/_includes/feedback-button-2.md -->
如果您没有找到所需答案，可以通过反馈表单提交您的问题。 请尽可能详细地描述问题。 如果可能，请附上截图。

<a href="../troubleshooting/feedback-new">
  <span class="button">联系支持</span>
</a>

<a href="../troubleshooting/feedback-docs">
  <span class="button">建议改进文档</span>
</a>
<!-- endsource: zh/analytics/content/_includes/feedback-button-2.md -->
