Introduction
Integrating Salesforce with external systems through API operations is essential for automating workflows and ensuring seamless data management. This guide provides a comprehensive overview of how to create records in Salesforce programmatically using API calls. It covers key operations such as creating Contacts, Cases, and Tasks while detailing the required request methods, headers, and body structures. Additionally, this article explains the use of variables within Logic+ flows, demonstrating how to dynamically retrieve and pass data into API requests.
When constructing the URL path, request headers, or request body, you may notice variables marked with $() syntax (for example, $(caseId)). These variables must be defined earlier in your Logic+ flow before they can be used. A common way to set these variables is by performing a lookup operation to retrieve an object ID, which can then be passed into these integration panels.
Create Contact
The Contact creation API operation enables you to add new contacts to your Salesforce organization programmatically.
API Overview: This API operation accepts contact details including First Name, Last Name, Email, Phone, and Account association. It supports both required and optional fields, including custom fields defined in your Salesforce organization.
Integration Panel Settings Example
Integration*:
Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.
Path:
/services/data/v59.0/sobjects/Contact/Request Method:
POSTRequest Headers:
{
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
}Request Body:
{
"FirstName": "$(firstName)",
"LastName": "$(lastName)",
"Phone": "$(cidNumber)"
}Content Type:
JSONVariables:
Define a variable to store your token, using the JSONPath syntax as demonstrated below.
$.data.0.messagestatusTextCreate Contact Logic+ JSON Template
{
"panels":[
{
"type": "integration",
"initiator": true,
"name": "createContact",
"coordinates": {
"x": 145.7958809880775,
"y": -163.66023268167925
},
"fields": {
"integrationId": "004hq3tmn7b4pyfv84",
"path": "/services/data/v59.0/sobjects/Contact/",
"method": "POST",
"headers": {
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
},
"contentType": "JSON",
"timeout": 30,
"variables": [
{
"name": "errorMessage",
"jsonpath": "$.data.0.message"
},
{
"name": "status",
"jsonpath": "statusText"
}
],
"fireAndForget": false,
"requestBody": {
"FirstName": "$(firstName)",
"LastName": "$(lastName)",
"Phone": "$(cidNumber)"
}
},
"exits": {
"default": "",
"timeout": "",
"error": ""
},
"version": "2.2.0"
}
]
}Create Case
Creating cases through the API allows you to programmatically generate support tickets or track customer issues in your Salesforce organization.
API Overview: The Create Case API operation accepts parameters such as Subject, Description, Priority, and Status. It can automatically associate the case with existing Accounts and Contacts, and supports the addition of custom fields during creation.
Integration Panel Settings Example
Integration*:
Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.
Path:
/services/data/v59.0/sobjects/Case/Request Method:
POSTRequest Headers:
{
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
}Request Body:
{
"Status": "New",
"Origin": "Phone",
"Subject": "Customer Support Inquiry",
"ContactId": "$(contactId)"
}Content Type:
JSONVariables:
Define a variable to store your token, using the JSONPath syntax as demonstrated below.
$.data.0.messagestatusTextCreate Case Logic+ JSON Template
{
"panels":[
{
"type": "integration",
"initiator": true,
"name": "createCase",
"coordinates": {
"x": -76.53745234525586,
"y": -182.32689934834593
},
"fields": {
"integrationId": "004hq3tmn7b4pyfv84",
"path": "/services/data/v59.0/sobjects/Case/",
"method": "POST",
"headers": {
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
},
"contentType": "JSON",
"timeout": 30,
"variables": [
{
"name": "errorMessage",
"jsonpath": "$.data.0.message"
},
{
"name": "status",
"jsonpath": "statusText"
}
],
"fireAndForget": false,
"requestBody": {
"Status": "New",
"Origin": "Phone",
"Subject": "Customer Support Inquiry",
"ContactId": "$(contactId)"
}
},
"exits": {
"default": "",
"timeout": "",
"error": ""
},
"version": "2.2.0"
}
]
}Create Task
Tasks in Salesforce help track activities that need to be completed. The Create Task API operation allows you to programmatically create action items or reminders.
API Overview: The Create Task API accepts parameters such as Subject, Due Date, Status, and Priority. Tasks can be associated with various objects like Accounts, Contacts, or Cases, and can be assigned to specific users.
Integration Panel Settings Example
Integration*:
Select your integration's base URL from the dropdown menu. This URL should have been configured during your initial setup on the Integrations page.
Path:
/services/data/v59.0/sobjects/Task/Request Method:
POSTRequest Headers:
{
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
}Request Body:
{
"Priority": "Normal",
"WhoId": "$(contactId)",
"WhatId": "$(accountId)",
"Subject": "Call",
"Description": "ID: $(qcmid) CallerID: $(cidNumber) Notes: $(interactionNotes) Disposition: $(endType)"
}Content Type:
JSONVariables:
Define a variable to store your token, using the JSONPath syntax as demonstrated below.
$.data.0.messagestatusTextCreate Task Logic+ JSON Template
{
"panels":[
{
"type": "integration",
"initiator": true,
"name": "createTask",
"coordinates": {
"x": 145.7958809880775,
"y": -163.66023268167925
},
"fields": {
"integrationId": "004hq3tmn7b4pyfv84",
"path": "/services/data/v59.0/sobjects/Task/",
"method": "POST",
"headers": {
"Content-Type": "application/json; charset=UTF-8",
"Authorization": "OAuth $(accessToken1)$(accessToken2)"
},
"contentType": "JSON",
"timeout": 30,
"variables": [
{
"name": "errorMessage",
"jsonpath": "$.data.0.message"
},
{
"name": "status",
"jsonpath": "statusText"
}
],
"fireAndForget": false,
"requestBody": {
"Priority": "Normal",
"WhoId": "$(contactId)",
"WhatId": "$(accountId)",
"Subject": "Call",
"Description": "ID: $(qcmid) CallerID: $(cidNumber) Notes: $(interactionNotes) Disposition: $(endType)"
}
},
"exits": {
"default": "",
"timeout": "",
"error": ""
},
"version": "2.2.0"
}
]
}