Skip to Content
Technical Articles
Author's profile photo Gaurav Abbi

Use SAP BTP, Kyma runtime to extend SAP Marketing Cloud


This blog describes step by step how to do all the necessary configurations required to achieve API and event integration with SAP Marketing Cloud and SAP BTP, Kyma runtime. This, in turn, enables the customers and partners to extend SAP Marketing Cloud using SAP BTP, Kyma runtime.
Remark: Pairing SAP Marketing Cloud or SAP S/4HANA Cloud is currently not possible with SAP BTP trial accounts

The above configuration enables access to SAP Marketing Cloud APIs and provides the ability to configure Kyma functions and microservices to be triggered with SAP Marketing Cloud events.

This is achieved thanks to SAP S/4HANA Cloud Extensibility which is a generic way of extending any S/4 system using both Cloud Foundry and SAP BTP, Kyma runtime.

Once the configuration is done, the runtime flow will trigger functions and microservices in SAP BTP, Kyma runtime with SAP Marketing Cloud events. It will also be possible to call SAP Marketing Cloud APIs using the provided credentials.



  • A provisioned SAP BTP, Kyma runtime. Read this blog to get started.
  • An SAP Marketing Cloud tenant that will be extended using SAP S/4HANA Cloud Extensibility and SAP BTP, Kyma runtime.
  • Quota available for the SAP Enterprise Messaging service on the SAP BTP subaccount on which SAP BTP, Kyma runtime is enabled.

Register the S/4 system (SAP Marketing Cloud)

You will start by registering SAP Marketing Cloud as a system in SAP BTP Cockpit. This will allow SAP S/4HANA Cloud Extensibility to set up the necessary configurations and resources to enable API and events integration with SAP BTP, Kyma runtime.
  • Create a system in SAP BTP Cockpit.

  • Copy the generated token.
  • Create a new Extension in SAP Marketing Cloud under Maintain SAP Cloud Platform Extensions and provide the copied token.
  • In SAP BTP, add entitlements for SAP S/4HANA Cloud Extensibility to the subaccount in which SAP BTP, Kyma runtime is enabled.
    • Choose Add Service Plans.
    • Select SAP S/4HANA Cloud Extensibility.
    • Select the registered S/4 system from the drop-down menu.
    • Select both messaging and api-access plans.
    • Save the changes

This will make the registered system accessible in Kyma runtime’s Service Catalog as you will see in the next steps.

Enable calling SAP Marketing Cloud APIs

TIP: For details on setting up api-access for SAP S/4HANA Cloud APIs in the Kyma runtime, see the official documentation on SAP Help Portal.

This section describes how to do the necessary setup in SAP BTP, Kyma runtime to be able to make API calls to SAP Marketing Cloud.

  • In SAP BTP, Kyma runtime, access SAP S/4HANA Cloud Extensibility in Service Catalog.

  • Create a new instance with the api-access plan.

In the background, this will:

    • Set up all the necessary communication arrangements in SAP Marketing Cloud.
    • Create the necessary system users to make API calls.
    • Set up any other configuration required to make API calls.

NOTE: scenarioId will depend on the API calls that will be made to SAP Marketing Cloud.

  • Bind the created instance to a function or a microservice in Kyma.

The connection configuration will be available as environment variables that can be used by microservices or functions.

See a sample function that uses the credentials injected by the service binding:

 * Add this to dependencies
  "name": "call-mktng-api",
  "version": "1.0.0",
  "dependencies": {
      "axios": "latest"
const axios = require("axios");
const baseURI = `${process.env['MKTNG_URL']}/sap/opu/odata/SAP/API_MKT_CAMPAIGN_SRV;v=2`
console.log(`baseURI is-- ${baseURI}`);

module.exports = {
    main: async function (event, context) {
        try {
            const response = await axios({
                method: 'get',
                url: `${baseURI}/Campaigns?$top=2`,
                auth: {
                    username: process.env['MKTNG_User'],
                    password: process.env['MKTNG_Password']
        } catch (error) {

Such a function can either be called internally from other functions or exposed externally via Kyma API Rules and then invoked via the URL

Enable SAP Marketing Cloud events consumption

TIP: For details on enabling the consumption of SAP S/4HANA Cloud events in Kyma runtime, see the official documentation on SAP Help Portal.

Set up EMS clients

In Kyma’s Service Catalog, create the SAP S/4 HANA Cloud Extensibility instance with the messaging plan:

  • For systemName, enter the name of the registered system.
  • Provide a unique emClientId.

It will create the Enterprise Messaging client in the background and set up the necessary communication arrangement. You can verify the created client in the Enterprise Messaging admin UI.

The namespace will look as follows: sap/S4HANAOD/{emClientId}

This Enterprise Messaging client will be receiving the events from SAP Marketing Cloud. To capture and forward the events from this instance to Kyma, you need to create another Enterprise Messaging client.

In subscriberFilter, provide the same namespace that was created for the SAP S/4 HANA Cloud Extensibility instance of the messaging plan. This is done to receive events from that namespace in this Enterprise Messaging client.

Configure events in SAP Marketing Cloud

You now need to configure in SAP Marketing Cloud all event types you wish to send to SAP BTP, Kyma runtime for various extensions.

  • In SAP Marketing Cloud, access Enterprise Event Enablement.

  • Go to channels list and select the channel with the name SAP_CP_XF_{emClientId}

  • Search and select the events that will be sent.

As an example, I selected sap/s4/beh/marketingpermission/v1/MarketingPermission/*.

You will see the same events appearing in the EMS admin UI.


Set up an extension in SAP BTP, Kyma runtime

You can now create a serverless function or a microservice that can receive the events from SAP Marketing Cloud via Enterprise Messaging.

These steps show how to create a function, but the flow will be similar if you decide to use a microservice.

To enable secure access, you have an option to set up OAuth2 for the exposed webhook. However, it is not a must to use OAuth2 – customers can always use their preferred authentication mechanism such as basic authentication or any other that works with EMS webhooks.

  • Set up an OAuth2 client in Kyma.
Note: The client id and client secret values are by default encoded. Please decode and then copy them to EMS webhook details

  • Expose the function with an API Rule.

Configure an Enterprise Messaging webhook

To consume the events, you need to go to the second Enterprise Messaging client that was created and configure the queue and subscription to enable SAP BTP, Kyma runtime to start receiving the events. Then, you need to create a webhook.

  • Create a new queue for this EMS client.

  • Create a queue subscription.

  • Configure the queue subscription by setting Topic to the namespace originally created for the messaging instance of SAP S/4HANA Cloud Extensibility.

  • Set up the webhook.

  • The webhook url is the URL of the API rule created in Kyma runtime to receive events.
  • Provide the client id and client secret for the OAuth client client created in Kyma runtime.
  • Provide the Token URL. It is of the form https://oauth2.{kyma cluster domain}/oauth2/token
This completes the whole setup and allows the function to start receiving events.
As the last check, you can view the payload printed in the Kyma logs:
Sample Json Payload
Now you have both events and apis from SAP Marketing Cloud connected to SAP BTP, Kyma runtime. Thus enabling you to extend SAP Marketing Cloud using SAP BTP, Kyma runtime

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Nikolay Starikov
      Nikolay Starikov

      Thank you Gaurav! That´s a very useful guide

      Author's profile photo Sunita Sagar
      Sunita Sagar

      Hi Gaurav,

      Thank you for a great blog. Please can you advice which release of Marketing Cloud did you use and did you need to do any additional steps to enable the communication scenarion required for the integration with Kyma runtime?


      Author's profile photo Gaurav Abbi
      Gaurav Abbi
      Blog Post Author

      Hi Sunita,

      You can try with 2008 release. Please ensure the user that you logs-in with has enough information to perform administrative actions such as creating "Extensions" and as such.

      Author's profile photo Manuel Seeger
      Manuel Seeger

      Hi Gaurav,


      We are trying to set up this scenario, however we find we don't have a " Enterprise Event Enablement" app in Marketing Cloud. Are there additional prerequisites which we are missing?

      Best regards,


      Author's profile photo Gaurav Abbi
      Gaurav Abbi
      Blog Post Author

      Hi Manuel,

      You can get in touch with the responsible person for your marketing access. Perhaps appropriate access is missing. Which release version you are on?


      Best regards,

      Gaurav Abbi

      Author's profile photo Josef Ehbauer
      Josef Ehbauer

      Hi Manuel,

      Following the marketing cloud integration guide, you need to do two steps in the Marketing Cloud system

      • Retrieve the integration token via the app "Maintain SAP Cloud Platform Extension" being used for the initial connection between the SAP Marketing Cloud system on the Kyma Platform
      • Register the required business objects for eventing via the app "Enterprise Event Enablement"

      Note, to access the app "Enterprise Event Enablement" you need to extend the business role for the administrator by the corresponding business catalog. If you won't find the catalog, kindly raise a support ticket, that colleague look into, and figure out the root cause for that issue.

      Best Regards, Josef