Get user rank across target groups

The API fetches a user’s rankings in all enrolled targets within a timeframe.

👍

Note

For detailed information about our APIs and for hands-on testing, refer documentation on API overview and step-by-step guide on making your first API call.

Prerequisites

  • Authentication: Basic/OAuth authentication
  • Default access group
  • Enable leaderboards for the organisation.
  • Create a target milestone or streak.
  • Enable leaderboards for the milestone or streak

Resource Information

URIapi_gateway/intouch-api-v3/v3.1/leaderboards/user/{userId}
HTTP MethodGET
PaginationNo
Rate limit informationNA

API Endpoint Example

https://eu.api.capillarytech.com/api_gateway/intouch-api-v3/v3.1/leaderboards/user/381329847

Headers

HeaderDescription
DATA-SCOPE-ORGList of Organisation IDs
DATA-SCOPEScopes define what data can be accessed using the API. You can use scopes to control access to data from a parent or child organisation. Defining a scope ensures that the response contains only data from the respective organisation.

Supported headers: SELF, OTHER and ALL.

Refer to connected orgs data scopes for more information.

Request query parameters

Parameters
(Parameters marked with * sign are mandatory)
TypeDescription
userIDIntThe unique ID of the customer.

Request body

[
   {
        "orgId" : 50711,
        "targetGroupId" : 232,
        "targetRuleId" : 365,
        "periodId": 243
    },
    {
        "orgId" : 50711,
        "targetGroupId" : 232,
        "targetRuleId" : 366 ,
        "periodId" : 243
    }
]

Request body parameters

Parameters (Parameters marked with * sign are mandatory)TypeDescription
orgIdLongUnique identifier for the organisation.
targetGroupId*LongUnique identifier for target group
targetRuleId*LongUnique identifier for target rule.
Maximum of 25 rule IDs supported.
periodIdLongIdentifier of period for which result will be fetched

Response body


   {
    "data": {
        "lastSyncTime": "2024-06-24T17:37:00.000IST",
        "customerId": 381329847,
        "userEnrichmentDetails": {
            "mobile": "918781885773",
            "last_name": "",
            "first_name": "",
            "email": "[email protected]"
        },
        "userRanks": [
            {
                "orgId": 50711,
                "targetGroupId": 232,
                "targetRuleId": 366,
                "periodId": 243,
                "achievedValue": 3000,
                "rank": 1771,
                "lastActivityTime": "2022-11-25T21:45:05.000IST",
                "totalUsersInTargetGroup": 4527
            }
        ]
    },
    "errors": [],
    "warnings": []
}

Response parameters

ParametersData TypeDescription
dataObjectAn object that contains details of the leaderboard.
– lastSyncTimeStringThe time when the data was updated.
Supported format: YYYY-MM-DDTHH:MM:SS.000z The system uses the organisation time zone to display the time.
–customerIdIntegerIdentifier of the customer.
–userEnrichmentDetailsObjectAn object that contains key-value pairs of information related to the user.
–userRanksObjectA list of the user’s ranks across different target rules.
–orgIdIntegerThe organisation ID to which the target group belongs.
–targetGroupIdIntegerThe unique identifier for the target group.
–targetRuleIdIntegerThe unique ID of the target rule. A target rule is a set of parameters that define the rules for achieving a target.
–periodIdIntegerThe unique ID of the target period. A period is a set of parameters that define the timeframe for a target.
–achievedValueLongThe value achieved by the user for that target rule.
Example: If the customer has earned 5000 points, the value will be 5000.
–rankIntegerRank of the user in the target group for the target rule in the target period
–lastActivityTimeStringLast activity time Supported format: YYYY-MM-DDTHH:MM:SS.000z
–totalUsersInTargetGroupIntegerThe number of users enrolled in the target rule.
errorsObjectErrors encountered while fetching the object.
warningsObjectWarnings encountered while fetching object.

API-specific warnings and errors

Error CodeDescriptionReason
-Maximum number of target rules allowed is 25, only first 25 target rules will be consideredMore than 25 target rules are passed in the request body
-Target group id 999 not found or deactivatedThe target group ID is invalid or not found.
-Leaderboard is not enabled for the target group id 43879Leaderboard is not enabled for the requested target group.
-Target rule id 999 does not belong to target group id 232The target rule ID passed does not belong to the target group passed or is invalid.
-Target period id 999 not found for the target id 366The target period ID passed does not belong to the target group passed or is invalid.
-No active target period found for the target id 366The current target period does not exist.
51512The following orgs are not part of the hierarchyOne or more of the organisations passed is not part of the connected organisation hierarchy.
310133Leaderboards are not enabled for the following orgsLeaderboards are not enabled for the organisation.
Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!