Back to top

Gainsight REST API allows you to add/update Customers, Usage Data, Scorecard records, Milestones, CTAs and load NPS responses and distribute Survey emails.

Gainsight REST API Root

https://instance_name.salesforce.com/services/apexrest/JBCXM/GSAPI/V1

Here instance_name should be replaced with your organization instance name e.g : na15,ap1 etc

Limits : Maximum number of records supported in single request by area name

Area NameLimit
Customers 1000
Scorecard customer level - 1000
measure level- 200
Usage Data 200
CTAs 200
Milestones 2000
NPS responses 100
Survey distribution 300
If more records are sent than defined limit then records are processed through a batch process and appropriate acknowledgment will be sent in response.

Authorization : In header Authorization: Bearer access_token, access_token should be replaced with user session ID or if you are acting on behalf of someone else then use OAuth 2.0 access token.

Please refer to salesforce documentation to know how to setup OAuth

Resource Group 

Customers 

Add/Update customers
/customers/upsert

Create new customers or updates existing customer info records.

customer object schema :

{
    "data": {
        "customers": [ // array of customer info objects
            {
                "account": "001F000001NH5isIAD", //account ID
                "asv": 1000,
                "mrr": 1200,
                "otr": 1000, //One-time revenue
                "orgContractDate": "2015-02-04", // Orginal Contract Date
                "nextRenewalDate": "2016-02-03" // Next Renewal Date
                "status": "Inactive", // status picklist value
                "stage": "Seasoned Customer", // stage picklist value
                "users": 1200,
                "obj": { // To set any custom fields values
                    "attributes": {
                        "type": "JBCXM__CustomerInfo__c"
                    },
                    "Id": "a0DF000000JLkyRMAT",
                    "jbcxm__nps__c": 3
                }
            }
        ]
    }
}

Note:

  • If customer exists with same account ID as sent in request then existing customer info record will get updated, otherwise new customer info record will be created.
  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "customers": [{
                "account": "001F000001NH5isIAD",
                "asv": 1000,
                "mrr": 1200,
                "orgContractDate": "2015-02-04",
                "status": "Inactive",
                "stage": "Seasoned Customer",
                "users": 1200,
                "obj": {
                    "attributes": {
                        "type": "JBCXM__CustomerInfo__c"
                    },
                    "Id": "a0DF000000JLkyRMAT",
                    "jbcxm__nps__c": 3
                }
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":1000,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":1}
    // failure case
    {"nextBatchSize":1000,"errLog":[{"type":"Custom","jbcxm__account__c":null,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":1,"passCount":0}
    
    

CTAs 

Create or update CTAs
/cta/upsert

schema:

{
    "data" {

        "honorOrgTimeZone": true, //date field values are stored in organization timezone , defaults to false
        "ctas": [ // array of  CTA records
            {
                "account": "account ID",
                "name": "Name of the CTA ",
                "type": "Risk/Opportunity",
                "reason": "CTA Reason",
                "priority": "Priority Type",
                "stage": "Stage Type",
                "assignee": "user ID",
                "playbook": "play book ID",
                "comment": "comment goes here",
                "numOfDays": "3",
                "source": "foo",
                "createdDate": "2015-02-01",
                "dueDate": "2015-02-10",
                "postFrequency": "Never",
                "obj": { // to set any custom field values
                    "attributes": {
                        "type": "JBCXM__CTA__c"
                    },
                    "JBCXM__TaskCount__c": 3
                }
            }

        ]
    }
}

Note:

  • Required fields: account, name ,reason and priority.

  • if playbook is provided in the request then it will associate the tasks of playbook to the CTA.

  • If createdDate is not provided then it will be defaulted to date.today().

  • If dueDate is not provided then it will be defaulted to createdDate + 5(excluding weekends).

  • If assignee is not provided then it will be defaulted to current session user ID.

  • JBCXM__OriginalDueDate__c is always defaulted to dueDate.

  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "ctas": [{
                "account": "001F000001NH5isIAD",
                "name": "Test 2",
                "type": "Opportunity",
                "reason": "Survey Response",
                "priority": "medium",
                "stage": "Open",
                "assignee": "005F0000002hy6CIAQ",
                "playbook": "a0XF0000007pDnNMAU",
                "comment": "abcd",
                "numOfDays": "3",
                "source": "",
                "createdDate": "2015-02-01",
                "dueDate": "2015-02-10",
                "postFrequency": "Never",
                "obj": {
                    "attributes": {
                        "type": "JBCXM__CTA__c"
                    },
                    "JBCXM__TaskCount__c": 3
                }
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":1}
    // failure case
    {"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"},{{"type":"Custom","jbcxm__account__c":"001i00000","jbcxm__type__c":a0Qi0000003outSEAQ,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":2,"passCount":0}
    
    

Features 

Add or update features by account
/feature/upsert

schema:

{
    "data": {
        "honorOrgTimeZone": true, //date field values are stored in organization timezone , defaults to false
        "customerFeatures": [{
            "account": "account ID",
            "feature": "Feature Name",
            "comment": "comments goes here",
            "licenced": false, // boolean
            "enabled": true // boolean
        }]
    }
}

Note:

  • If record already exits for given feature and account ID then existing record will be updated.
  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "customerFeatures": [{
                "account": "001F000001NH5isIAD",
                "feature": " Email Services",
                "comment": "Enabled this feature from Jan-4-2015",
                "licenced": false,
                "enabled": true
            }, {
                "account": "001F000001NH5isIAD",
                "feature": "Survey",
                "comment": "Enabled this feature from Jan-4-2015",
                "licenced": true,
                "enabled": true
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
        { "nextBatchSize": 1000, "errLog": [], "status": 
        "SUCCESS", "failCount": 0, "passCount": 1 }
    
    

Milestones 

Add or update Milestones by account
/milestones/upsert

schema:

{
    "data": {
        "honorOrgTimeZone": true, //date field values are stored in organization timezone , defaults to false
        "milestones": [{
            "account": "001i000001DPhyhAAD", //account ID
            "milestoneDate": "2015-02-02",
            "comment": " text goes here",
            "milestone": "Conference" // milestone name
        }]
    }
}

Note:

  • If record already exits for given milestone and account ID then existing record will be updated.
  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "milestones": [{
                "account": "001F000001NH5isIAD",
                "milestoneDate": "2014-02-10",
                "comment": "foo",
                "milestone": "Conference"
            }, {
                "account": "001F000001NH5isIAD",
                "milestoneDate": "2014-03-01",
                "comment": "foo",
                "milestone": "Reference"
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
        { "nextBatchSize": 1000, "errLog": [], "status": 
        "SUCCESS", "failCount": 0, "passCount": 1 }
    // failure case
    { "nextBatchSize": 1000, "errLog": [ { "type": "Custom", 
    "jbcxm__account__c": "001i000001DPhyhAAD", 
    "jbcxm__milestone__c": null, "jbcxm__date__c": 1404777600000,
    "errorLog": "Milestone field is null or missing" }, { 
    "type": "Custom", "jbcxm__account__c": "001i000001DPhyhAAD", 
    "jbcxm__milestone__c": null, "jbcxm__date__c": 1404777600000,
    "errorLog": "Invalid Account" } ], "status": "FAILED", 
    "failCount": 2, "passCount": 0 }
    
    

NPS 

Load NPS responses
/npsResponse/upsert

schema:

"data": {
    "honorOrgTimeZone": true, //date field values are stored in organization timezone , defaults to false
    "npsResponses": [ // array of  NPS response records
        {
            "account": "SF account id" //Mandatory,
            "userrole": "CSM" //Optional, default value is "User",
            "username": "foo" // Optional, if not passed defaulted to "useremail",
            "useremail": "foo@acme.com" //Mandatory,
            "surveycode": "NPS survey master code",
            "surveyid": "NPS survey master id",
            "npsscore": 5 //It should be in the range of [0, 10] and Mandatory,
                "respondeddate": "2014-02-01"
            "npscomment": "comment goes here" //Optional
        }
    ]
}
}

Note:

  • Required fields account, surveycode or surveyid, useremail,npsscore and respondeddate

  • If surveycode is provided then it will check if there exists NPS survey master matching with this survey code and associate the record with that survey, otherwise it will create a new NPS master and associate the record with new one.

  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "npsResponses": [{
                "account": "001F000001NH5isIAD",
                "userrole": "user",
                "username": "John Carter",
                "useremail": "private@acme.com",
                "surveycode": "NPS Survey2015",
                "npscomment": "comment goes here",
                "surveyid": "a0vF000000R4o7TIAR",
                "npsscore": "2",
                "respondeddate": "2014-02-01"
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":100,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":4}
    // partial success case
    {"nextBatchSize":100,"errLog":[{"type":"Custom","userrole":"PM","account":"","respondeddate":1397595661000,"useremail":"john@acme.com","errorLog":"Invalid Account or Survey Master details or NPS score","npscomment":"<script>alert(lkjadlfk jalkfj&,:;./?).asdlkflk","npsscore":5,"surveycode":"testsurey1234","username":"bad"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":3}
    
    

Scorecards - Measure level 

Add/update measures
/scorecard/updateMetricScore

Set scores for individual measures by account.

schema:


{  "data": {
    "scores": [ // array of scorecard objects
      {
        "account":"account ID",
        "metric":"Customer Relationship", //metric name
        "scorevalue":100, // score value
        "resetscore":true, // if true metric value changed to N/A
        "comment":"comments goes here"
    }
    ]
}
}

Note:

  • You should use score or scorevalue to set the score for a metric.

  • If record already exits for given measure and account ID then existing record will be updated.

  • If customer roll-up summary is enabled then customer level scores are re-populated based on latest scores.

  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
        {
            "data": {
                "scores": [{
                    "account": "account ID",
                    "metric": "Customer Relationship",
                    "scorevalue": 100,
                    "resetscore": true,
                    "comment": "foo"
                }]
            }
        }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":200,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":1}
    // failure case
    {"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":null,"errorLog":"Invalid Account or Metric or Score"}],"status":"FAILED","failCount":1,"passCount":0}
    
    

Scorecards - Overall score 

Add/Update customer level scores
/scorecard/updateCustomerScore

Set scores at customer level (Overall score).

schema:

{
    "data": {
        "scores": [ // array of scorecard objects
            {
                "account": "account ID",
                "scorevalue": 100, // score value
                "resetscore": true, // if true metric value changed to N/A
                "comment": "comments text goes here",
                "goals": "Goals text goes here"
            }
        ]
    }
}

Note: You should use score or scorevalue to set the score for customer overall health.

  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "scores": [{
                "account": "account ID",
                "scorevalue": 100,
                "resetscore": true,
                "comment": "Usage Increased",
                "goals": "foo"
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":1000,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":1}
    // failure case
    {"nextBatchSize":1000,"errLog":[{"type":"Custom","jbcxm__account__c":null,"errorLog":"Invalid Account or Score"}], "status":"FAILED","failCount":1,"passCount":0}
    
    

Survey 

Distribute survey
/survey/send

API call to distribute survey emails once the participants are added to the survey.

schema:

{
    "data": {
        "distributionData": [ // array of  NPS response records
            {
                "surveyCode": "Survey CODE",
                "resend": true, // optional , flag to say resending email to participants. Defaulted to false
                "fromAddress": "From address to use for Gainsight email service", // optional , defaulted to survey level setting
                "emailService": "Gainsight", //Optional, defaulted survey level setting
                "templateId": "Email template to use", //Optional, defaulted survey level setting
                "participants": [ // array of survey participant objects
                    {
                        "attributes": {
                            "type": "JBCXM__SurveyParticipant__c"
                        },
                        "Id": "a0qF0000008WeO0IAK"
                    }, {
                        "attributes": {
                            "type": "JBCXM__SurveyParticipant__c"
                        },
                        "Id": "a0qF0000008WeO0IHJ"
                    }
                ]
            }
        }
    ]
}
}
  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "distributionData": {
                "surveyCode": "NPS Survey 2015 Q3",
                "resend": true,
                "fromAddress": "foo@acme.com",
                "emailService": "Salesforce",
                "templateId": "00XF0999991LQCRMA4",
                "participants": [{
                    "attributes": {
                        "type": "JBCXM__SurveyParticipant__c"
                    },
                    "Id": "a0qF6666668WeO0IAK"
                }]
            }
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"status":"SUCCESS","msg": "Appropriate message"}
    // failure case
    {"status":"FAILURE","msg": "Failure reason"}
    
    

Usage Data 

Add/Update Usage Data
/usageData/upsert

Load usage data by instance, account and user level.

Usage Object schema:

{
    "data": {
        "usageLevel": "ACCOUNTLEVEL" // supported INSTANCELEVEL ,USERLEVEL and ACCOUNTLEVEL
        "honorOrgTimeZone": true, //date field values are stored in organization timezone , defaults to false
        "usage": [ // array of  usage data records
            {
                account: "account ID ",
                usageLevel: "INSTANCELEVEL/USERLEVEL/ACCOUNTLEVEL",
                instanceId: "foo ",
                instanceName: "Name of the instance",
                user: "user identifier",
                usageDate: "2015-02-04",
                obj: { // if you want to set any custom fields
                    "attributes": {
                        "type": "JBCXM__UsageData__c"
                    },
                    "JBCXM__UniqueVisits__c": 3
                }
            }
        ]
    }
}

Note:

  • Required fields based on the Usage level.
    • ACCOUNTLEVEL:account and date(If multiple records are sent with same Account ID and time period then latest record will be considered for updation or creation.)
    • INSTANCELEVEL:account, date and instanceId(If multiple records are sent with same Account ID,Instance ID and time period then latest record will be considered for updation or creation.)
    • USERLEVEL: account, date and user(If multiple records are sent with same Account ID,User ID and time period then latest record will be considered for updation or creation.)
  • Request
  • Headers
    Content-Type: application/json
    Authorization: Bearer access_token
    Body
    {
        "data": {
            "usage": [{
                "account": "001F000001NH5isIAD",
                "usageLevel": "ACCOUNTLEVEL",
                "usageDate": "2015-02-02",
                "obj": {
                    "attributes": {
                        "type": "JBCXM__UsageData__c"
                    },
                    "PageView__c": 300
                }
            }]
        }
    }
    
    
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    // success case
    {"nextBatchSize":200,"errLog":[],"status":"SUCCESS","failCount":0,"passCount":2}
    // partial success
    {"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i000001DPhy","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"}],"status":"PARTIAL SUCCESS","failCount":1,"passCount":1}
    // failure case
    {"nextBatchSize":200,"errLog":[{"type":"Custom","jbcxm__account__c":"001i000001DPhy","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"},{"type":"Custom","jbcxm__account__c":"te","jbcxm__date__c":1404777600000,"errorLog":"Invalid Account"}],"status":"FAILED","failCount":2,"passCount":0}
    
    

Generated by aglio on 19 Mar 2015