SAP Marketing Cloud

Written By Devin O'Neill ()

Updated at April 15th, 2025

Defaults

Prerequisites:

API to Create Contact & Post Interaction:

Username/ Password for API:

  • Field Names & Field Identifier:
  • Origin ID:
  • Sandbox Details with Credentials (If possible):

Functions:

addOrUpdateContact()

This function is used to add or update contacts into the SAP marketing cloud.

Parameters:

Parameter Name Parameter Description Example
$xcsrfToken Pass the X-CSRF token t9unmhNOcbF-IFKSwz3k_Q==
$contactOrigin (required)   SAP_HYBRIS_CONSUMER
$contactId Pass the unique contact id Annex123
$fieldData (required) Pass the field mapping array

array (

'OriginDataLastChgUTCDateTime' => '2019-10-17T13:12:00',

'EmailAddress' => 'spunekar@annexloud.com',

'IsConsumer' => true,

'IsContactPerson' => false,

'IsObsolete' => false,

'YY1_LoyaltyStatus_MPS' => 'Optin',

'YY1_AC_CustomerID_MPS' => 'ACMN123AC',

'YY1_AC_lifetime_points_MPS' => '1000',

'YY1_AC_available_point_MPS' => '1000',

'YY1_AC_current_tier_MPS' => 'Gold',

'YY1_ACFirstName_MPS' => 'Suvarna',

'YY1_ACLastName_MPS' => 'Punekar',

'YY1_AC_loyalty_join_da_MPS' => '2019-10-17T13:12:00',

'YY1_AC_points_expirati_MPS' => '200',

'YY1_AC_points_expirat1_MPS' => '2019-12-12T05:33:04',

'YY1_AC_last_activity_d_MPS' => '2019-08-10T06:33:04',

'YY1_AC_last_reward_red_MPS' => '2019-08-02T06:33:04',

'YY1_AC_first_activity__MPS' => '2019-08-10T22:33:27',

'YY1_AC_tier_after_expi_MPS' => 'Silver',

'YY1_AC_tier_expiration_MPS' => '2019-12-30T06:33:04',

'YY1_AC_last_purchase_d_MPS' => '2019-08-10T22:33:27',

'YY1_AC_spend_to_next_t_MPS' => '400',

'YY1_AC_used_points_MPS' => '800'

);

contactInteraction()

This function is used to add interactions to contacts in the SAP marketing cloud.

Parameters:

Parameter Name Parameter Description Example
$xcsrfToken Pass the X-CSRF token t9unmhNOcbF-IFKSwz3k_Q==
$fieldData (required) Pass the field mapping array

array (

'InteractionContactOrigin' => 'SAP_HYBRIS_CONSUMER',

'InteractionContactId' => 'spunekar@annexloud.com',

'CommunicationMedium' => 'ONLINE_SHOP',

'InteractionType' => $_POST['interaction_type'],

'InteractionTimeStampUTC' => date('Y-m-d\TH:i:s'),

'InteractionSourceObjectType' => 'CUAN_MARKETING_ORCHESTRATION',

'InteractionSourceObject' => '9FA37CF0B0FBA0FE17DD5E7550DC088546DE713C',

'MarketingArea' => 'CXXGLOBAL',

'InteractionIsAnonymous' => false,

'InteractionLastChangedDateTime' => '2019-10-17T13:12:00',

'InteractionContentSubject' => 'AC Loyalty',

'InteractionContent' => 'Optin',

);

additionalIds()

This function is used to add Additional ID & additional Origin ID for the existing/created contact.

Parameters:

Parameter Name Parameter Description Example
$xcsrfToken Pass the X-CSRF token t9unmhNOcbF-IFKSwz3k_Q==
$contactID Pass the unique contact id Annex123
$contactOrigin Pass the contact Origin SAP_HYBRIS_CONSUMER
$additionalContactID Pass the additional Contact id Annex123
$additionalContactOrigin Pass the additional Origin id SAP_ERP_CUSTOMER
$fieldData (required) Pass the field mapping array

array (

'ContactID' =>, 'TESTIMMPLY123',

'ContactOrigin' => 'SAP_HYBRIS_CONSUMER',

'InteractionContactAdditionalExternalID' => 'TESTIMMPLY123',

'InteractionContactAdditionalOrigin' => 'SAP_ERP_CUSTOMER',

 
 

);

Example usage of class:

$sapObject = new Sapmarketingcloud();
$sapObject->clientEndpointUrl = 'https://gdm-partner.demo.hybris.com';
$sapObject->username = 'Marketing01';
$sapObject->password = 'Welcome1';
$xcsrfToken = $sapObject->getToken();
$contactOrigin = 'SAP_HYBRIS_CONSUMER';
$contactId = 'Annex123';
$contactData = $sapObject->addOrUpdateContact($xcsrfToken, $contactOrigin, $contactId, $contactData);

$contactData = $sapObject->additionalIDs($xcsrfToken,$contactID, $contactOrigin, $additionalContactID, $additionalContactOrigin, $fieldData);