> For the complete documentation index, see [llms.txt](https://docs.coda.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codashop-yu-distrubution/ji-cheng-zhi-nan/usersync-api-qing-qiu/usersync-api-mi-yao-de-shi-yong-chang-jing-ji-shi-li.md).

# UserSync API 密钥的使用场景及示例

## **使用场景与优势**

### **1. 显示应用内昵称**

* **目标**：通过显示用户熟悉的应用内名称或昵称，提升转化率。
* **优势**：增强信任感与个性化体验，让用户感到更有亲切感与参与感。

#### API 示例 – 显示应用内昵称

**格式**：JSON-RPC\
规范参考：<http://www.jsonrpc.org/specification>

**请求：**

```javascript
{
   "id": "6164695159717629913",
   "jsonrpc": "2.0",
   "method": "syncUser",
   "params": [
       {
           "serviceProvider": "Coda",
           "purchaseOrigin": "TH",
           "user": {
               "userId": "111111",
               "zoneId": "101"
           }
       }
   ]
}
```

**响应：**

```javascript
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "username": "Randy"
  }
}
```

*在此场景中，商店展示用户在应用内的昵称（“Randy”）以营造熟悉且个性化的体验。*

### **2. 基于购买历史与活动的规则化 SKU 折扣资格**

* **目标**：根据用户的购买历史和游戏内活动（如新用户或首次购买者）配置规则，展示特定的 SKU 折扣。
* **优势**：针对性折扣策略促进新用户获取

#### **API 示例 - 基于规则的 SKU 折扣资格**

格式 JSON-RPC

<http://www.jsonrpc.org/specification>

**请求**：

```javascript
{
   "id": "6164695159717629913",
   "jsonrpc": "2.0",
   "method": "syncUser",
   "params": [
       {
           "serviceProvider": "Coda",
           "purchaseOrigin": "TH",
           "user": {
               "userId": "111111",
               "zoneId": "101"
           }
       }
   ]
}
```

**响应**：

```javascript
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": 
  {
    "username": "Randy",
    "metadata": 
    {
      "inGameLevel": 1,
      "First Purchase Discount": "Yes"
    },
    "personalisedSkus": [
    {
        "skuId": "weekly_pass_coda1",
        "details":{
        "status": 1
        "pendingPurchaseLimit": 1
        }
     },
     {
        "skuId": "100_diamonds_coda2",
        "details":{
        "status": 1
        "pendingPurchaseLimit": 2
        }
     }
      {
        "skuId": "100_diamonds_coda2",
        "details":{
        "status": 2
        "pendingPurchaseLimit": 0
        }
     }
   ]
  }
}
```

*在此场景下，店铺可为配置为享有“首次购买折扣”资格且处于等级 1 的用户展示特定 SKU 的折扣信息及可用购买限额。*

### **3. 动态惊喜 SKU**

* **目标**：根据用户互动、再互动需求或限时促销活动，实时获取并展示专属 SKU。
* **优势**：通过提供动态生成、针对用户个性化的 SKU，激发兴趣并营造紧迫感。

**API 示例 - 动态惊喜 SKU**

格式 JSON-RPC

<http://www.jsonrpc.org/specification>

**请求**：

```javascript
{
   "id": "6164695159717629913",
   "jsonrpc": "2.0",
   "method": "syncUser",
   "params": [
       {
           "serviceProvider": "Coda",
           "purchaseOrigin": "TH",
           "user": {
               "userId": "111111",
               "zoneId": "101"
           }
       }
   ]
}
```

**响应**：

```javascript
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "username": "Randy",
    "personalisedSkus": [
      {
        "skuId": "mystery_box",
        "description": "Mystery Gift Box",
        "details": {
          "category": "special",
          "price": 5.99,
          "currency": "USD",
          "imageUrl": "https://cdn.partner.com/images/mystery-box.png"
          "pendingPurchaseLimit": 1
        }
      }
    ]
  }
}
```

*在此场景中，会根据用户的互动历史向他们展示一个惊喜 SKU（例如神秘礼盒）。*

### **4. 其他使用场景**

* 重新参与促销：为长时间未活跃或未进行购买的用户触发特别优惠。
* VIP 及高消费用户（鲸鱼用户）：识别高价值或重复购买客户，展示独家商品或折扣，以鼓励持续消费并提高留存率。
* 基于事件的个性化：利用用户的生日等元数据，在特殊场合提供独家奖励或折扣
* 互补 SKU 推荐：根据用户现有的应用内库存推荐互补商品，提升用户体验并增加转化率

#### **API 示例 - 互补 SKU 推荐**

格式化 JSON-RPC

<http://www.jsonrpc.org/specification>

**请求：**

```javascript
{
   "id": "6164695159717629913",
   "jsonrpc": "2.0",
   "method": "syncUser",
   "params": [
       {
           "serviceProvider": "Coda",
           "purchaseOrigin": "ID",
           "user": {
               "userId": "111111",
               "zoneId": "101"
           }
       }
   ]
}
```

**响应：**

```javascript
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "username": "Randy",
    "metadata": {
      "currentCatalogue": "9 Mystery Cards"
    },
    "personalisedSkus": [
      {
        "skuId": "MysteryCard_coda1",
        "description": "Buy now to unlock next level in the game",
        "details": {
        "status": 1
        "pendingPurchaseLimit": null
        }
      }
    ]
  }
}

```

*在此场景中，用户会收到关于应购买哪些物品以提升游戏表现的推荐。*


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coda.co/https-coda-payments.gitbook.io-zhong-wen-coda-private-technical-documentation/codashop-yu-distrubution/ji-cheng-zhi-nan/usersync-api-qing-qiu/usersync-api-mi-yao-de-shi-yong-chang-jing-ji-shi-li.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
