The eLead REST Service Version 2 (available in Release v34.0 and higher) is a continuation upon the ELead Rest Service, the key difference being that version 2 can accept the eLead data from either the query string or a JSON body. If both are submitted, the service used the JSON body.
NOTE: The JSON must be a simple format, and cannot include nested statements. For HomeAdvisor and ANGI integrations, a third-party interface like Zapier MUST be used to parse the nested JSON. Otherwise, the payload must be simple JSON in order to map directly to the eLead endpoint described in this article.
See also: Dev0 Fall 2021 Release Notes
Endpoint Setup
- Login as the Administrator
- Go to Setup | Develop | Sites
- If there are no Sites listed, you will have to choose a domain. If there is already a site set up, skip to Step 8.
- As a best practice, use your full company name as a run on word. For example, 'Image Landscaping' becomes 'imagelandscaping'.
- Double check the spelling because you can't undo this once you click 'Register'!
- Accept the terms and click 'Register My Force.com Domain'.
- Now that the domain is set up, click 'New' in the 'Sites' area. If a domain was already set up then you will start here.
- Leave the 'Type of new Site' as 'Guest' and click Continue.
- Fill in the form with the following values:
- Site Label: PublicSite (This can be anything really.)
- Site Name: PublicSite
- Active Site Home Page : InMaintenance (This can be anything really.)
- Leave all other fields blank
- Click Save
- Activate the site, if not active.
- Click the link under the Site Label column
- On the Site Details screen, click Public Access Settings
- Scroll down to 'Enabled Apex Class Access' and click Edit
- Under 'Available Apex Classes' select i360.eLeadRESTVersion2 and i360.eLeadRESTVersion2Utilities and click Add
- Click Save
- Edit to add Object Permissions.
- Under Custom Object Permissions, give the ability to Read and Create on the following Objects: Appointment, eLead, Interests, Interest Selections, Lead Source, Marketing Opportunity, Prospect, and Sources.
- NOTE: Newer systems may not have Edit, Delete, View All and Modify All capabilities on any Site Guest User Profiles, if this is the Case, give Read and Create permissions.
Next, Edit the Administrative Permissions
Ensure the Profile has View All Custom Settings Enabled
It is also recommended to set the Guest Site User's Email address as any Verified Email address within the system so that Email notifications can be sent related to eLeads by the Guest Site User.
IMPORTANT: Because of the change to Salesforce Guest Users, ensure that ALL Sites are set up with the Sharing Rules on the Source, Prospect, User, and Account (if applicable), outlined below.
See also: SFDC Winter '21 Guest User Access Changes and Resolutions
Grant Read Permissions to the Guest User Profile on Objects using Sharing Rules
Go to Setup>Sharing Settings and Select the User Object
Click New Sharing Rule
When creating the Sharing Rule select 'Guest user access, based on criteria'. The criteria is Active = True. Share with select the guest user that is having issues. Grant Read Only access.
Granting Read Permissions to the Guest User Profile on Source
Go to Setup >Sharing Settings and Select the Source Object
Click New Sharing Rule
When creating the Sharing Rule select 'Guest user access, based on criteria'. The criteria is Source Name not equal to BLANK. Share with select the guest user that is having issues. Grant Read Only access.
Grant Read Permissions to the Guest User Profile on Account
Go to Setup>Sharing Settings and Select the Account Object
Click New Sharing Rule
When creating the Sharing Rule select 'Guest user access, based on criteria'. The criteria is Type equal to Vendor. Share with select the guest user that is having issues. Grant Read Only access.
Grant Read Permissions to the Guest User on Prospect
Go to Setup>Sharing Settings and Select the Prospect Object
Click New Sharing Rule
When creating the Sharing Rule select 'Guest user access, based on criteria'. The criteria is Primary Last Nam enot equal to BLANK. Share with select the guest user that is having issues. Grant Read Only access.
Save
________________________________________________________________________________________________________________
Endpoint URL
Your endpoint URL will be https://domainname.secure.force.com/services/apexrest/i360/eLeadv2. Replace the highlighted red text with the Site URL generated when creating your new site.
Ex. Site URL = https://xyzroofing.my.salesforce-sites.com/ + services/apexrest/i360/eLeadv2
So the whole endpoint needed for testing, and provided to the customer to use would be:
https://xyzroofing.my.salesforce-sites.com/services/apexrest/i360/eLeadv2
_____________________________________________________________________________________________
Validation
The eLead REST Service v2 also includes eLead Verification Settings, which can be toggled on/off in Custom Settings > Public System Settings
- eLead Required Field Validation - (for first name and last name validation)
- eLead Contact Method Validation - (for email/address/phone validation)
Required Fields
- i360__Last_Name__c
- i360__First_Name__c
And at least one of the following:
- i360__Email1__c
- i360__Address_1__c
- i360__Phone__c
Note: Though only the i360__Address_1__c/StreetAddress is required for Contact Method Validation, it is suggested to include Address, Zip (both needed for Smarty Streets verification), AND email or phone, to prevent eLead conversion issues.
If only the Address is included as a contact method in the POST, an eLead WILL be created, but will not convert successfully.
Usage
Send a test POST to the /services/apexrest/i360/eLeadv2 endpoint using the standard eLead fields to populate as query parameters. See eLead Standard Field Mapping article for full list of out of the box eLead fields.
HTTP Post Query can be used OR JSON formatting can be used to submit eLeads to the endpoint. The apex class will translate all requests into JSON upon hitting i360.
Example HTTP POST Request
FirstName=Test&LastName=Tester&Phone1=5556667890&Phone1Type=Mobile&StreetAddress=123+Fake+Street&City=Columbus&State=OH&Zip=43215&Email=testemail@notadomain.com&SourceType=Lead Provider&Interests=Doors
Example JSON Body
NOTE: The JSON must be a simple format, and cannot include nested statements. For HomeAdvisor and ANGI integrations, a third-party interface like Zapier MUST be used to parse the nested JSON. Otherwise, the payload must be simple JSON in order to map directly to the eLead endpoint described in this article.
{
"FirstName": "Test",
"LastName": "Tester",
"Phone1": "5556667890",
"Phone1Type": "Mobile",
"StreetAddress": "123 Fake Street",
"City": "Columbus",
"State": "OH",
"Zip": "43215",
"Email": "testemail@notadomain.com",
"Source": "Modernize",
"SourceType": "Lead Provider",
"Product": "Doors"
}
Responses
- If an eLead is successfully created, the response status will read
Success
and the response code will be201 Created
. The fields of the new lead will also be returned in the response. - If the creation fails, the response status will read
error
with a response code of400 Bad Request
and the response will include a description of the error. - In both cases, the request body will also be returned in the response.
Ex. of a Success response:
{
"status": "success",
"requestBody": {
"Zip": "43215",
"Phone1": "5556667890",
"StreetAddress": "123 Fake Street",
"Email": "testemail@notadomain.com",
"FirstName": "Test",
"State": "OH",
"SourceType": "Lead Provider",
"Phone1Type": "Mobile",
"LastName": "Tester",
"City": "Columbus",
"Product": "Doors"
},
"errors": [],
"createdELead": {
"attributes": {
"type": "i360__eLead__c",
"url": "/services/data/v56.0/sobjects/i360__eLead__c/a0w6S00000V9t0cQAB"
},
"i360__Extended_Comments__c": "",
"i360__Zip__c": "43215",
"i360__Phone__c": "5556667890",
"i360__Address_1__c": "123 Fake Street",
"i360__Email1__c": "testemail@notadomain.com",
"i360__First_Name__c": "Test",
"i360__State_Province__c": "OH",
"i360__Source_Type__c": "Lead Provider",
"i360__Phone_1_Type__c": "Mobile",
"i360__Last_Name__c": "Tester",
"i360__City__c": "Columbus",
"i360__Interests__c": "Doors",
"Id": "a0w6S00000V9t0cQAB"
}
}
- i360 will also create and attach a Note to the new eLead record with the full request, for better troubleshooting.