Overview
Logic+ flows can be triggered on demand by sending an API request to Sharpen's /v1/logics/ endpoint. This allows external systems, applications, or scheduled processes to launch a Logic+ execution programmatically, with the option to pass in custom variables at the time of execution.
Prerequisites
Before making an API request to execute a Logic+, ensure the following are in place:
API Key and Secret
An API Key and Secret must be created in your environment. These are used to authenticate your request.
API credentials can be found or created in Admin → Configuration → Integrations:
A Published Logic+
The Logic+ you want to execute must be created and published before it can be triggered via API.
Logic ID
You will need the Logic ID of the flow you want to execute. This can be found in the URL while the Logic+ is open in the browser editor:
IZ0 example:
https://app.sharpencx.com/admin/configuration/logicPlus/#/dashboard/0212mme95143e4t1IZ1 example:
https://app.iz1.sharpen.cx/admin/configuration/logicPlus/#/dashboard/02115986bps6btk1uj
The Logic ID is the alphanumeric string at the end of the URL (e.g., 0212mme95143e4t1).
Making the Request
Method
POSTURL
Replace <LogicID> with the Logic ID from the URL of your published Logic+.
IZ0:
https://api.sharpen.cx/v1/logics/<LogicID>/execute/IZ1:
https://api.iz1.sharpen.cx/v1/logics/<LogicID>/execute/
Headers
Include your API Key and Secret as request headers:
{
"X-API-KEY": "apiKeyGoesHere",
"X-API-SECRET": "apiSecretGoesHere"
}
Body (Optional)
You may include a JSON body to pass custom variables into the Logic+ at the time of execution. This is a useful way to supply values upfront rather than performing a data lookup or external call from within the flow itself.
{
"customVariables": {
"customerPhoneNumber": "3171112222",
"customerAddressStreet": "123 Easy Street",
"PII_customerLast4SSN": "9832",
"salesforceRecordID": "0012F00002h5G8VQAU",
"salesforceCustomerLevel": "Platinum"
}
}
Any variables passed in the customVariables object will be available throughout the Logic+ flow as interaction variables, referenced using $(variableName) syntax.
Example: PHP cURL
The following is a complete PHP cURL example that executes a Logic+ flow with custom variables. Replace the Logic ID, API key, API secret, and variable values with your own.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-gateway.iz1.sharpencx.com/v1/logics/02115986bps6btk1u/execute',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"sync": true,
"customVariables": {
"interactionId": "1111111",
"customerPhoneNumber": "3171112222",
"customerAddressStreet": "123 Easy Street",
"PII_customerLast4SSN": "9832",
"salesforceRecordID": "0012F00002h5G8VQAU",
"salesforceCustomerLevel": "Platinum"
}
}',
CURLOPT_HTTPHEADER => array(
'x-api-key: apiKeyGoesHere',
'x-api-secret: apiSecretGoesHere',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
The "sync": true parameter is used when a custom response is required to return all configured data points from a “Response” panel within a Logic+ automation flow. This enables the application to receive and process the returned data as part of a bi-directional exchange.
If the integration only requires one-way data transmission and does not need to receive data back from the Logic+ flow, the "sync": true parameter is not necessary.
Related Articles
This article is part of a series on Admin Configuration topics.