Spending and Earning Comparison
Overview
The Spending and Earning Comparison insight is a schedule-trigger insight that looks at all the aggregated card and bank accounts of the user and provides a spend to earning/income percentage.
Following are the additional details for the insight:
Insight Name | SPENDING_AND_EARNING_COMPARISON |
---|---|
Applicable Entity | ACCOUNT |
Insight Type | AGGREGATE |
Trigger Type | SCHEDULE |
Supported Containers | BANK, CARD |
Use Cases
- Customer:
- User engagement
- User:
- Financial wellness - Keep track of spending as a percentage of earnings.
Suggested Action
If the spend-to-earning percentage is high, suggest users to spend less. Recommend setting up a VIEW with a budget to keep a check on spending.
Duplicate Insight Checks
To prevent the same insight from generating repeatedly, the insight is generated once per scheduled frequency for a user.
Following is the applicable frequency for this insight:
Frequency | Description | |
---|---|---|
MONTHLY | The insight will be triggered once on the first day of the calendar month. Duplicate check will evaluate if the insight instance that matches the duplicate check criteria exists for the current calendar month (1st of the calendar month to the last day of the month). For example:
|
Insight Dynamic Trigger (On-Demand Evaluation)
The insight can be triggered using the following on-demand insight trigger API:
POST /insights/trigger
Peer Benchmarking Data
This insight does not provide peer benchmarking data.
Thresholds
Threshold does not apply to this insight.
GET Customer Subscription
The GET customer subscription API provides all the information about the defaults set for the insights that are subscribed by the customer. The default frequency for the insight is MONTHLY
and the default duration for the insight is LAST_THREE_MONTHS
.
Method and URL:
GET /insights/configs/customerSubscriptions
Header Parameters:
Key | Value | |
---|---|---|
Authorization |
Client credentials-based authorization | Bearer {{Access Token}} |
API key-based authentication | Bearer {{JWT Token_Customer}} |
|
Deprecated cobrand and user credential-based authentication | cobSession={cobSession received in the cobrand login service} |
|
Content-Type |
application/json |
|
Api-Version |
3.0 |
|
2.1 |
||
2 |
||
Cobrand-Name |
{Name of the Customer} |
Sample Request:
GET /insights/configs/customerSubscriptions
Sample Response:
For more information about the attributes that are returned in the API response, refer to the Insights Data Model page.
- Api-Version 3.0 and 2.1 Response
{
"customerSubscription":[
{
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"insightType": "AGGREGATE",
"triggerType": "SCHEDULE",
"containers": [
"BANK",
"CARD"
],
"description": "Generates an insights that provides the ratio of spending to earning.",
"applicableEntity": [
"ACCOUNT"
],
"customerConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
]
}
]
}
- Api-Version 2 Response
{
"customerSubscription":[
{
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"insightType": "AGGREGATE",
"triggerType": "SCHEDULE",
"container": [
"BANK",
"CARD"
],
"description": "Generates an insights that provides the ratio of spending to earning.",
"applicableEntity": [
"ACCOUNT"
],
"customerConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
]
}
]
}
PATCH Customer Subscription
Using the PATCH API for customer subscription, customers can change the defaults for each insight. Alternatively, customers can use the insights configuration tool to achieve the same result.
Warning! Changing any defaults can potentially impact all users who have subscribed to this insight. If the user has overridden the customer threshold, then the user preference will be applied. For all other users, the new defaults will apply.
Method and URL:
PATCH /insights/configs/customerSubscriptions
Header Parameters:
Key | Value | |
---|---|---|
Authorization |
Client credentials-based authorization | Bearer {{Access Token}} |
API key-based authentication | Bearer {{JWT Token_Customer}} |
|
Deprecated cobrand and user credential-based authentication | cobSession={cobSession received in the cobrand login service} |
|
Content-Type |
application/json |
|
Api-Version |
3.0 |
|
2.1 |
||
2 |
||
Cobrand-Name |
{Name of the Customer} |
Editable Parameters:
Editable Attributes | Impact | Allowed Values |
---|---|---|
isSubscribed | Subscribes or unsubscribes all the users from the Spending and Earning Comparison insight. | true, false |
insightTitle | The title returned in the GET feed API as well as the insights configuration tool can be changed. | Alphanumeric characters up to 100 characters (including spaces) |
Sample Request:
{
"customerSubscription": [
{
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"customerConfiguration": [
{
"isSubscribed": true,
"entityType": "ACCOUNT"
}
]
}
]
}
Error Messages:
HTTP Status Code | Reason |
---|---|
400 | Y806: Invalid Input |
400 | Y800: Invalid value for insightName |
400 | Y800: Invalid value for insightTitle; special characters ><\""'%{}|^~[] are not supported. |
400 | Y801: Invalid length for insightTitle; min 3 and max 100 characters including spaces are allowed. |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying frequency is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying duration is not allowed |
400 | Y802: For SPENDING_AND_EARNING_COMPARISON insight passing threshold is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying applicableEntity is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying triggerType is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying container is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying description is not allowed |
400 | Y800: Invalid value for isSubscribed; Supported values are true, false |
400 | Y825: Update not allowed without a valid request body |
400 | Y803: Invalid request; Either a valid insightTitle or customerConfiguration is required |
400 | Y812: Required field/value - insightName missing in the request |
400 | Y802: Modifying InsightType attribute is not allowed |
400 | Y813: entityType should be provided |
400 | Y803: At least one additional attribute is required in addition to entityType. |
400 | Y800: Invalid value for customerConfiguration; customerConfiguration is either missing, duplicated, or has insufficient/ incorrect attributes |
400 | Y800: Invalid value for entityType. Supported entityType for SPENDING_AND_EARNING_COMPARISON insight are - [ACCOUNT] |
400 | Y800: Invalid value for input json |
401 | Y020: Invalid token in authorization header |
401 | Y020: Token has expired |
GET User Subscription
The GET user subscription API provides all the information about the user defaults set for the insight.
The entityId
filter does not apply to this insight.
Method and URL:
GET /insights/configs/userSubscriptions
Header Parameters:
Key | Value | |
---|---|---|
Authorization |
Client credentials-based authorization | Bearer {{Access Token}} |
API key-based authentication | Bearer {{JWT Token_Customer}} |
|
Deprecated cobrand and user credential-based authentication | cobSession={cobSession received in the cobrand login service}, userSession={userSession received in the user login service} |
|
Content-Type |
application/json |
|
Api-Version |
3.0 |
|
2.1 |
||
2 |
||
Cobrand-Name |
{Name of the Customer} |
Sample Request:
GET /insights/configs/userSubscriptions?insightName=SPENDING_AND_EARNING_COMPARISON
Sample Response:
For more information about the attributes that are returned in the API response, refer to the Insights Data Model page.
- Api-Version 3.0 and 2.1 Response
{
"userSubscription":[
{
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"insightType": "AGGREGATE",
"triggerType": "SCHEDULE",
"containers": [
"BANK",
"CARD"
],
"description": "Generates an insights that provides the ratio of spending to earning.",
"applicableEntity": [
"ACCOUNT"
],
"userConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
],
"customerConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
]
}
]
}
- Api-Version 2 Response
{
"userSubscription":[
{
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"insightType": "AGGREGATE",
"triggerType": "SCHEDULE",
"container": [
"BANK",
"CARD"
],
"description": "Generates an insights that provides the ratio of spending to earning.",
"applicableEntity": [
"ACCOUNT"
],
"userConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
],
"customerConfiguration": [
{
"entityType": "ACCOUNT",
"isSubscribed": true,
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
]
}
]
}
PATCH User Subscription
Using the PATCH user subscription API for user subscription, users can change the defaults for each insight. If the user wants the insight to be evaluated for a new account, then add that account using the PATCH user subscription API. The customer default threshold values will apply if the user has not set any values.
Method and URL:
PATCH /insights/configs/userSubscriptions
Header Parameters:
Key | Value | |
---|---|---|
Authorization |
Client credentials-based authorization | Bearer {{Access Token}} |
API key-based authentication | Bearer {{JWT Token_Customer}} |
|
Deprecated cobrand and user credential-based authentication | cobSession={cobSession received in the cobrand login service}, userSession={userSession received in the user login service} |
|
Content-Type |
application/json |
|
Api-Version |
3.0 |
|
2.1 |
||
2 |
||
Cobrand-Name |
{Name of the Customer} |
Editable Parameters:
Editable Attributes | Impact | Allowed Values |
---|---|---|
isSubscribed | Subscribes or unsubscribes from the Spending and Earning Comparison insight. | true, false |
Sample Request:
{
"userSubscription":[
{
"insightName":"SPENDING_AND_EARNING_COMPARISON",
"userConfiguration":[
{
"entityType":"ACCOUNT",
"isSubscribed":true
}
]
}
]
}
Error Messages:
HTTP Status Code | Reason |
---|---|
400 | Y806: Invalid input |
400 | Y800: Invalid value for insightName |
400 | Y800: Invalid value for input param in SPENDING_AND_EARNING_COMPARISON insight |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying frequency is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying duration is not allowed |
400 | Y802: For SPENDING_AND_EARNING_COMPARISON insight passing threshold is not allowed |
400 | Y802: Modifying insightTitle using this API is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying applicableEntity is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying triggerType is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying container is not allowed |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, modifying description is not allowed |
400 | Y800: Invalid value for isSubscribed; Supported values are true, false |
400 | Y825: Update not allowed without a valid request body |
400 | Y812: Required field/value - insightName missing in the request |
400 | Y802: Modifying InsightType attribute is not allowed |
400 | Y813: entityType should be provided |
400 | Y803: At least one additional attribute is required in addition to entityType. |
400 | Y800: Invalid value for userConfiguration; userConfiguration is either missing, duplicated, or has insufficient/ incorrect attributes |
400 | Y800: Invalid value for entityType. Supported entityType for SPENDING_AND_EARNING_COMPARISON insight are - [ACCOUNT] |
400 | Y802: For insight SPENDING_AND_EARNING_COMPARISON, configurations at an entityId level are not allowed |
400 | Y800: Invalid value for input json |
401 | Y020: Invalid token in authorization header |
401 | Y020: Token has expired |
GET Insight Feeds
The GET insights feed API retrieves all or a subset of the valid insight notifications generated for a particular user. However, using the insightName
filter, you can specifically request for the Spending And Earning Comparison insight. The insight will be generated only if the creditTotal
is greater than 0.
The entityId
filter does not apply to this insight.
Calculation Logic for Derived Attributes:
spentPercent
=debitTotal
/creditTotal
*100 (Round off to 2 decimal places)
Method and URL:
GET /insights/feed
Header Parameters:
Key | Value | |
---|---|---|
Authorization |
Client credentials-based authorization | Bearer {{Access Token}} |
API key-based authentication | Bearer {{JWT Token_Customer}} |
|
Deprecated cobrand and user credential-based authentication | cobSession={cobSession received in the cobrand login service}, userSession={userSession received in the user login service} |
|
Content-Type |
application/json |
|
Api-Version |
3.0 |
|
2.1 |
||
2 |
||
Cobrand-Name |
{Name of the Customer} |
Sample Request:
GET /insights/feed?insightName=SPENDING_AND_EARNING_COMPARISON
Sample Response:
For more information about the attributes that are returned in the API response, refer to the Insights Data Model page.
{
"feed": [
{
"id": "61f2129e37830906bb0d4793",
"insightName": "SPENDING_AND_EARNING_COMPARISON",
"insightTitle": "Spending And Earning Comparison",
"insightType": "AGGREGATE",
"triggerType": "SCHEDULE",
"createdDate": "2022-01-27T03:33:49Z",
"subscription": [
{
"entityType": "ACCOUNT",
"frequency": "MONTHLY",
"duration": "LAST_THREE_MONTHS"
}
],
"basicAccount": [
{
"id": 14571141,
"providerName": "Dag Site",
"accountName": "PDV Test Data- All Category",
"accountStatus": "ACTIVE",
"accountType": "OTHER",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14571141"
}
},
{
"id": 14570940,
"providerName": "Dag Site",
"accountName": "PDV_Test_Data-Long_Tenure_Recurring_Payments",
"accountStatus": "ACTIVE",
"accountType": "CHECKING",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14570940"
}
},
{
"id": 14570939,
"providerName": "Dag Site",
"accountName": "PDV_Test_Data-Account_Balance",
"accountStatus": "ACTIVE",
"accountType": "SAVINGS",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14570939"
}
},
{
"id": 14570940,
"providerName": "Dag Site",
"accountName": "PDV Test Data- Account Balance",
"accountStatus": "ACTIVE",
"accountType": "SAVINGS",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14570940"
}
},
{
"id": 14570937,
"providerName": "Dag Site",
"accountName": "PDV Test Data-Event",
"accountStatus": "ACTIVE",
"accountType": "CHECKING",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14570937"
}
},
{
"id": 14570936,
"providerName": "Dag Site",
"accountName": "PDV_Test_Data_Sch/Ref",
"accountStatus": "ACTIVE",
"accountType": "CHECKING",
"container": "bank",
"link": {
"entityName": "account",
"url": "/accounts?accountId=14570936"
}
}
],
"transactionDerived": {
"creditTotal": {
"amount": 86814.02,
"currency": "USD"
},
"debitTotal": {
"amount": 279565.71,
"currency": "USD"
},
"spentPercent": "322.03",
"link": {
"entityName": "transaction",
"url": "/derived/transactions?fromDate=2021-10-01&toDate=2021-12-31&accountId=14571141,14570940,14570939,14570940,14570937,14570936"
}
}
}
]
}