Fun with Marketo — Building a Marketo integration in 15 minutes

Marketo is a world-renowned business automation solutions provider and one of the best in the business. They provide software solutions that cover a wide range of marketing related operations ranging from lead management to mobile marketing.

The best thing about Marketo is that, not only they provide feature-rich SaaS solutions, but also provide a number of integration endpoints such as a REST API, a JavaScript API, a SOAP API and even Webhooks so that you can seamlessly integrate your other software systems or applications with Marketo.

So in this article, let’s see how we can build a simple but powerful integration with Marketo using their REST APIs.

The Scenario …

First of all, let’s define a simple integration scenario that we need to solve or implement in this article. Marketo provides the capability to maintain your marketing lead information within their solution, more specifically in their Lead Database. Each of these lead records has a unique ID associated with it as well.

So in our use case, an external application needs to get information of a specific lead record from Marketo. Although that application can directly use the REST endpoint for that, it requires authentication and we do not want to expose those credentials to the external app.

Therefore, we ask the application just to send a simple HTTP GET request that contains a transport header (let’s say with the name lead-id) that contains the ID of the lead record to retrieve. Then our integration solution will fetch the corresponding lead record from Marketo and send it as the response. So the external app does not need to worry about authentication and other bureaucracies.

The Plan …

So let’s first plan out what we need to do in order to implement this scenario. As I see following are the steps we have to follow.

  1. Expose an HTTP endpoint to accept the request from the external app
  2. Extract the lead ID from the transport header named lead-id
  3. Implement the authentication process with Marketo REST API, with the capabilities to acquire an authentication token, to store the retrieved token, and to handle token expiration errors
  4. Execute the lead record retrieval operation on Marketo REST API
  5. Sends back the received information as the response to the original request by the app

Woah! Hold on there. We will never be able to do all these steps within 15 minutes. No, we won’t. But the good news is we do have a plan B which is much easier. So let’s get to that!

Plan B — the easier way …

Fortunately, we do not have to implement all the above steps from scratch to get this going. We can easily use AdroitLogic UltraStudio to build such an integration just by dragging and dropping UI components, without writing a single line of code.

Yes, UltraStudio does have an HTTP ingress connector which we can use for exposing an HTTP endpoint to the external app and most importantly a Marketo egress connector which we can use to retrieve the lead record from Marketo. And we do not need to worry about all the authentication and other overheads, as this Marketo egress connector takes care of them under-the-hood.

Building The Solution …

So let’s get to work. First, let’s create a new Project with UltraStudio for our solution. When comes to selecting the connectors for the project, let’s choose HTTP NIO Connector and Marketo Connector.

Select HTTP NIO and Marketo as connectors to be used in the UltraStudio project

Then when it prompts you to select processing elements, select Logging processors, so that we can log the requested lead ID for auditing and troubleshooting purposes later.

Select Logging as processing elements to be used in the UltraStudio project

After the design view is opened in the IDE, let’s build our integration flow as follows, with an HTTP ingress connector, logging processing element and a Marketo egress connector along with a Get Marketo Lead Information connector operation.

Integration Flow to retrieve Marketo Lead record for a requested ID

Now let’s see how we should configure these element properties to achieve our goal.

HTTP Ingress Connector (1)

HTTP ingress connector is used to accept HTTP requests from the external application and then to send back the response. So let’s configure it as follows so that it will listen on port 8280 and accepts GET requests on service path /service/get-lead .

On Basic tab,

  • Http port = 8280
  • Service path = /service/get-lead

On Transport Configuration tab,

  • Allowed HTTP methods = GET

Finally click Save.

Logger Processing Element (2)

Logger processing element is used to log the requested lead ID of each request. For that we can configure the log template and log level as follows so that it will print a log similar to INFO LoggerProcessingElement Request for ID : 2 received .

  • Log Templete = Request for ID : @{message.headers.lead-id} received
  • Log Level = INFO
If you haven’t noticed, the log template here uses a place holder expression @{message.headers.lead-id}, which will be resolved to the value of the transport header with name lead-id .

Marketo Lead DB Egress Connector (3)

Marketo egress connector is used to authenticate with the Marketo identity endpoint and then to make the REST API request. For that, it requires the following configuration parameters that are specific to your Marketo application.

  • Base URI = The base URI to be used to connect to Marketo. For example, if your identity endpoint URL is and REST endpoint URL is, the base URI should be
  • Client ID = The client ID assigned to your service
  • Client Secret = The client secret assigned to your service
If you don’t know how to retrieve this information from Marketo, please have a look at this Getting Started guide of Marketo REST API.

Get Marketo Lead Information Operation (4)

This connector operation is used to prepare the request according to the Marketo REST API to get the lead information. For that, let’s configure it as follows.

  • Operation = Get Lead by ID
  • Lead ID = @{message.headers.lead-id}
Here also, we use the same placeholder expression as the lead ID, so that it will be resolved from the header with name lead-id. And we do not specify any value to Fields parameter, so the response will contain all the lead record fields.

Running The Solution …

Since we have finished with the implementation, let’s try our solution. Run the UltraStudio project and once it is started, use your favorite HTTP client to perform an HTTP GET request with a header named lead-id which contains the ID of the lead record to get. The request URL should be the HTTP endpoint we exposed through our ingress connector, which is http://localhost:8280/service/get-lead.

If all went well, you should get the lead record details as a JSON response similar to the following 😃 and we are all done!

Sample Response for a request made with lead-id header set to value “2”

Going the Extra Mile …

So we are done with our simple, yet but useful integration solution. We only implemented the minimal integration to get it working, and if you are adventurous enough to do more, you can try improving the above solution with more features. Here are some ideas for you to try!

Tweaking the response from Marketo

In our integration, we just forwarded the response from Marketo as it is to the external client. But we can do some processing on the original response using any of UltraStudio’s JSON processing elements before it is being sent out.

For example, we can extract only the lead details part of the json (without request metadata such as requestId and success fields) using the JSON Path Extractor processing element and then send the extracted value to the external client.

Handling error scenarios

We also didn't worry about handling error scenarios in our solution. For example, what will happen if the original request didn’t have a header with name lead-id?

In our current solution, it will lead to a response with a 500 — Internal Server Error status. But we can improve this behavior by using the Conditions Evaluator processing element to check the existence of this header and handle the error scenario gracefully.


Marketo is the registered trademark of Marketo Inc. in the United States and/or other countries.

Call To Action

  • Clap. Appreciate and let others find this article.
  • Comment. Share your views on this article.
  • Follow me. Udith Gunaratna to receive updates on articles like this.
  • Keep in touch. LinkedIn, Twitter