> 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/codashop-and-distribution/integration-guides/usersync-api-request/usersync-api-request-example-and-responses.md).

# UserSync API Request Example & Responses

## <mark style="color:purple;">**UserSync API Request**</mark>

<mark style="color:purple;">**Example**</mark>\
Format JSON-RPC\
<http://www.jsonrpc.org/specification>

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

<table><thead><tr><th width="255">Parameter</th><th width="112.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>String</td><td>A unique ID identifying the API call.</td></tr><tr><td>jsonrpc</td><td>String</td><td>Fixed to “2.0” by json-rpc standard.</td></tr><tr><td>method</td><td>String</td><td>Fixed to “syncUser”</td></tr><tr><td>params.serviceProvider</td><td>String</td><td>Payment service provider name, default value is “Coda”, but partner can decide the value.</td></tr><tr><td>params.isForTest</td><td>Integer</td><td>A flag to indicate whether this order is for sandbox test or real order. If isForTest=1, this order is a sandbox test order; otherwise if isForTest=0, this order is a real order.</td></tr><tr><td>params.signature</td><td>String</td><td>Generated based on the content of the message. See section on <a data-mention href="#signature-calculation">#signature-calculation</a></td></tr><tr><td>params.user.userId</td><td>String</td><td>The user ID/player ID of the customer account in the partner's system.</td></tr><tr><td>params.user.zoneId</td><td>String</td><td><p>The zone ID/server ID of the customer account in the partner's system.</p><p>If zoneId is not required, the default value is “”.</p></td></tr><tr><td>params.purchaseOrigin</td><td>String</td><td>Note: purchaseOrigin is a 2 country code ISO standard. This will be the region where the user of codashop did the purchase from.<br><br><a href="https://www.iban.com/country-codes">https://www.iban.com/country-codes</a></td></tr></tbody></table>

## <mark style="color:purple;">Signature Calculation</mark>

The signature must be included in all requests. The signature for a request is a hash of the following fields, in the correct sequence:

<mark style="color:purple;">**For UserSync API calls:**</mark>\
`id + jsonrpc + method + serviceProvider + userId + zoneId + isForTest`\
\ <mark style="color:purple;">**For Validate and Topup API calls:**</mark> \
`id + jsonrpc + method + serviceProvider + txnId + orderId + userId + zoneId + currency + amount + sku + quantity + paymentChannelId + isForTest (+ roleId)`

## <mark style="color:purple;">UserSync API Request Responses</mark>

UserSync API Response describes the response to a UserSync API request by the partner.\
\
See below for examples of [Valid](#valid-user-verify-response) and [Invalid](#invalid-user-verify-response) UserSync API responses.

## <mark style="color:purple;">Valid UserSync API Response</mark>

<mark style="color:purple;">**Example 1**</mark>\
Format: JSON-RPC

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

```

<mark style="color:purple;">**Example 2**</mark>

If the Publisher wants to send metadata to showcase personalized SKU list based on the in-game user information

```javascript
//
{
  "id": "6164695159717629913",
  "jsonrpc": "2.0",
  "result": {
    "username": "Randy",
    "metadata": {
      "originCountry": "ID",
      "inGameLevel": "Gold Level"
      "roleInfo": "Warrior"
      
    },"personalisedSkus": [
      {
        "skuId": "100_diamonds_coda",
        "description": "100 Diamonds",
        "details": {
          "status": 1
          "category": "vip-cash",
          "price": 1.25,
          "currency": "USD",
          "pendingPurchaseLimit": 5
          "validTill": "2025-04-29 00:00:00"
          "imageUrl": "https: //cdn1.partner.com/S/content/common/images/denom-image/BGMI/100x100/60_bgmi_uc.png"
        }
      },
      {
        "skuId": "1000_diamonds_coda",
        "description": "100 Diamonds",
        "details": {
          "status": 2
          "category": "growth",
          "price": 150000,
          "currency": "IDR",
          "pendingPurchaseLimit": 0,
          "imageUrl": "https: //cdn1.partner.com/S/content/common/images/denom-image/BGMI/100x100/60_bgmi_uc.png"
        }
      }
    ]
  }
}
```

<table><thead><tr><th width="375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>The id of the message this response is associated with.  </td></tr><tr><td>jsonrpc</td><td>Fixed to “2.0” by json-rpc standard.</td></tr><tr><td>result</td><td>An Object representing success. </td></tr><tr><td>result.username</td><td>Player username, nickname, or other identifier that can be used to let the customer confirm they are topping up the intended account. For example, a unique player id may be “123456789”, and their username (not necessarily unique) may be “Terminator123”. </td></tr><tr><td>result.metadata</td><td>Publisher can use this field to add details such as user’s country of origin, in-game level, list of character or roleInfo of that user etc. (Optional)</td></tr><tr><td>result.personalisedSkus</td><td>The list of SKUs available to the user. (Optional)</td></tr><tr><td>result.personalisedSkus.skuId</td><td>SkuId (Optional)</td></tr><tr><td>result.personalisedSkus.description</td><td>Name of the SkuId (Optional)</td></tr><tr><td>result.personalisedSkus.details</td><td>The Object that holds sku’s details (Optional)</td></tr><tr><td>result.personalisedSkus.status</td><td><p>SKU status</p><p></p><p>INACTIVE (Locked/Disabled) = 0<br>ACTIVE (Available) = 1<br>PURCHASED (Already Purchased) = 2</p></td></tr><tr><td>result.personalisedSkus.details.category</td><td>Category or the Sub-type of the SKU (Optional)</td></tr><tr><td>result.personalisedSkus.details.price</td><td>Price that needs to be send in API to the publishers (Optional)</td></tr><tr><td>result.personalisedSkus.details.currency</td><td>Currency that needs to be sent in API to the publishers during top-up (Optional)</td></tr><tr><td>result.personalisedSkus.details.pendingPurchaseLimit</td><td>The maximum quantity of this SKU the user can purchase based on their current eligibility (Optional)</td></tr><tr><td>result.personalisedSkus.details.validTill</td><td>The specific date and time until which the SKUs will remain available for purchase. YYYY-MM-DD HH:MM:SS (Optional)</td></tr><tr><td>result.personalisedSkus.metadata.imageUrl</td><td>Image source for a specific SKU in Partner’s CDN (Optional)</td></tr></tbody></table>

## <mark style="color:purple;">Invalid UserSync API Response</mark>

Format: JSON-RPC

```javascript
// 
{
    "id": "6164695159717629913",
    "jsonrpc": "2.0",
    "error": {
        "code": -100,
        "message": "Invalid user ID"
    }
}
```

<table><thead><tr><th width="200">Parameter</th><th>Description</th></tr></thead><tbody><tr><td>id</td><td>The ID of the message this response is associated with.  </td></tr><tr><td>jsonrpc</td><td>Fixed to “2.0” by json-rpc standard.</td></tr><tr><td>error.code</td><td>A code representing the error.</td></tr><tr><td>error.message</td><td>A message explaining the error.</td></tr></tbody></table>

For any queries related to integration, reach out to the [Partnership Support Team](/references/contact-us.md).


---

# 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/codashop-and-distribution/integration-guides/usersync-api-request/usersync-api-request-example-and-responses.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.
