API Design | Jul 31, 2025 | 10 min read | By Rahul Khinchi | Reviewed by Pratim Maloji Bhosale
Rahul Khinchi is a Developer Advocate at Treblle, where he focuses on improving API workflows and developer experience. He writes technical content on API observability, security, and governance, and builds open-source tools to demonstrate real-world API use cases. Rahul has spoken at developer meetups and universities, and previously held developer advocacy roles at Syncloop. He was selected for Google Summer of Code in 2022 and has led community initiatives supporting thousands of beginners in open source.
Just getting started with MuleSoft and want to track your API traffic? I’ve been there. Here’s the exact setup I used to connect Treblle with MuleSoft, from proxy creation to real-time monitoring, so you can skip the confusion and get results in minutes.
If you're just getting started with MuleSoft and wondering how to track your API traffic with Treblle, this guide is for you. I recently worked on integrating Treblle with MuleSoft from scratch. I'll walk you through the exact steps I followed.
I've been tasked with setting up Mulesoft with Treblle, and I'm overwhelmed. There are so many moving parts—where do you even start?
After some trial and error (okay, a lot of error), I figured out a straightforward approach that got me from zero to a fully monitored API in about 15 minutes. Here's exactly what I did, including the mistakes I made, so you don't have to.
Need real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore TreblleNeed real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore TreblleBefore anything, I made sure I had:
Anypoint Studio (v7.21 or later) - MuleSoft's IDE
Java 17+
MuleSoft account with API Manager access
Treblle account with API Key and SDK Token
Maven 3.8+ - for building the policy
Don't have Treblle credentials? No worries! I created a free project atTreblle.com and grabbed my API Key and SDK Token in less than a minute.
Tip: Check this documentation to learn more about how to get the API Key and SDK Token.
I didn't need to write a single line of code. We'll use a mock API to simulate real traffic, which means you can follow along.
I decided to:
Create a simple API proxy that connects to a mock data source
Deploy it to MuleSoft's cloud infrastructure
Add Treblle to track every request
Test everything with real traffic
This way, I could see immediate results and understand how everything connects before diving into more complex implementations.
Log in to Anypoint Platform
Navigate to API Manager
Click the Add API button
Select Add new API
Runtime Selection:
Choose Mule Gateway (API gateway embedded in Mule runtime)
Select Deploy a proxy application
Choose CloudHub 2.0 as the target type
Runtime Configuration:
Target Type: CloudHub 2.0
Select Space: Choose your preferred region (e.g., Cloudhub-US-East-2
)
Runtime Version: 4.9.7 (or latest available)
Java Version: Java 17 (for better performance)
Proxy App Name: user-management-api-proxy
(use lowercase, numbers, and hyphens only)
API Name: User Management API
Asset Types: HTTPS API (You can choose from HTTP, REST, and SOAP)
The downstream configuration (how requests come into your API) can mostly be left as defaults. The critical part is the upstream configuration, where your API proxy will forward requests.
But you can configure it if desired:
Protocol: HTTPS (recommended for production)
Inbound TLS: Leave default (no custom TLS context needed)
Port: 8081
Base Path: /api/users
Client Provider: Anypoint
Instance Label: user-management-v1
(recommended for multiple API versions)
Upstream URL: https://mocki.io/v1/45022130-8f2d-49ce-8462-db1297dcf065
Outbound TLS: Leave default (no custom TLS context needed)
Note: We're using a mock API for demonstration. In production, this would be your actual CloudHub application URL, like https://user-management-api-yourname.us-e1.cloudhub.io
This is a mock API that returns realistic user data. It is perfect for testing without having to build an actual backend.
If you want to create a custom mock API:
Go to Mocki.io
Scroll down to the Free API Editor section
Create a response body and click Create API
Copy the generated URL
Review all configurations in the Review section
Click Save & Deploy
Wait for the proxy application to deploy (this may take a few minutes)
Once deployed, note the Proxy URL - this will be your public API endpoint
After clicking "Save & Deploy," I learned the first rule of cloud deployments: patience. Everything spun up in about 2 minutes, which felt like forever when you're excited to see results.
In Runtime Manager, you'll see your proxy application user-management-api-proxy
Wait for the status to show Running with a green indicator
The deployment typically takes 1-2 minutes
Once active, you'll see the Public Endpoint in the application details:
https://user-management-api-proxy-5q5pek.5ec6y6-3.usa.e2.cloudhub.io
Success! I got back a JSON response with mock user data. The proxy was working, but I could not see what was happening. That's where I will use Treblle.
Log in to your Treblle Dashboard
Create a new project or use an existing one
Here's where things got interesting.
Unlike built-in policies, Treblle's monitoring policy must be deployed to your organization's Exchange first. This is a one-time setup, but it involves some command-line work.
Navigate to Anypoint Platform Business Groups
Select your business group
Note the Business Group ID from the URL or page details
Note: The Business Group ID is a unique identifier that looks like: 68ef933a-6a4e-4d9d-8262-9c2a93c11111
Need real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore TreblleNeed real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore Trebllegit clone https://github.com/Treblle/treblle-mulesoft.git
cd treblle-mulesoft
treblle-policy/pom.xml
file with my Organization ID and configured my Maven settings with my MuleSoft credentials.<groupId>{BUSINESS_GROUP_ID}</groupId>
samples/.m2/settings.xml
and update your MuleSoft credentials:<username>{YOUR_MULESOFT_USERNAME}</username>
<password>{YOUR_MULESOFT_PASSWORD}</password>
Caution: Ensure your MuleSoft account has sufficient permissions to deploy to Exchange. You may need the Exchange Contributor or Exchange Administrator role.
cd treblle-policy
mvn -s ../samples/.m2/settings.xml clean package
mvn -s ../samples/.m2/settings.xml clean deploy
Tip: If you encounter permission errors during deployment, verify that your MuleSoft account has the necessary API Manager and Exchange permissions.
Visit Anypoint Exchange
Search for "treblle policy"
Confirm the policy is available in your organization
The policy should appear with version 1.0.6 and display as a Custom Policy
Go to API Manager in Anypoint Platform
Find your User Management API instance
Click on your API instance
Go to the Policies tab.
Click Apply New Policy
Search for "treblle-policy"
Choose treblle-policy from the list of available policies
Configure the policy with your Treblle credentials:
API Key: Enter your Treblle Project ID
SDK Token: Enter your Treblle API Key
Mask Keywords: (Optional) email,password,ssn - comma-separated sensitive fields to mask
Mask Payload: (Optional) false - set to true to mask entire payloads
Click Apply to save the policy configuration
Wait for the policy to be applied (usually takes 30-60 seconds)
The policy should appear in your Policies list as "Applied."
After applying the policy, I waited about 30 seconds for it to take effect. Then I started hitting my API endpoint with different types of requests.
Test the proxy endpoint to ensure it's working:
curl https://user-management-api-proxy-5q5pek.5ec6y6-3.usa.e2.cloudhub.io
Open Aspen in your browser
Enter your proxy URL
Test different HTTP methods (GET, POST, PUT, DELETE)
View real-time responses
Go to your Treblle Dashboard
Select your project
You should see real-time data including:
Request/Response logs with full payloads
Performance metrics (response times, status codes)
Error tracking for any failed requests
Usage analytics showing endpoint popularity
And then I saw it happen in real-time:
Every request appeared instantly in my Treblle dashboard
Response times measured in milliseconds (my API was fast!)
Complete request/response data - headers, payloads, everything
Beautiful visualizations showing usage patterns
I could literally watch the data flow:
My curl command hits the API Manager proxy
Treblle policy captures the request
Request forwards to mocki.io
Response flows back through the proxy
Treblle captures the complete cycle
Using a mock API meant I could focus on the monitoring setup without worrying about backend complexity.
The proxy approach gave me immediate results with minimal configuration
Treblle's policy captured everything I needed without impacting performance
I should have checked my Exchange permissions before attempting the policy deployment.
Testing the upstream URL directly first would have saved some debugging time.
Setting up masking keywords from the start is better than adding them later.
The proxy pattern works great for legacy systems that don't have built-in monitoring.
Having real-time visibility immediately changed how I think about API performance.
The detailed request logs made debugging so much easier
Building my first API with MuleSoft and monitoring it with Treblle was eye-opening. The combination of MuleSoft's robust API management platform and Treblle's comprehensive monitoring gave me everything I needed to build, deploy, and observe a production-ready API.
But here's the real insight: monitoring from day one changes everything. Instead of deploying and hoping for the best, I could see exactly what was happening, catch issues early, and optimize based on real data.
If you're thinking about diving into API development, do yourself a favor: set up monitoring from the start. Your future self will thank you when you don't understand why your API is slow or who's using it.
If you're in a similar situation, here's what I'd recommend:
Start with this exact setup. Don't try to build something complex right away. Get the proxy working, add monitoring, and understand the data flow.
Focus on the monitoring first. You can always replace the mock API with a real backend later, but having visibility from day one is invaluable.
Use the data to drive decisions. After a week of monitoring data, you'll be amazed at what you learn about your API usage patterns.
Gradually add complexity. Authentication, rate limiting, and caching - add these features one at a time so you can measure their impact.
Need real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore TreblleNeed real-time insight into how your APIs are used and performing?
Treblle helps you monitor, debug, and optimize every API request.
Explore TreblleLearn how to send and receive data in REST APIs using query strings, headers, JSON bodies, and form-data. This guide covers practical examples across popular frameworks, and shows you how to build secure, reliable APIs from request to response.
Pagination is key to building fast, scalable REST APIs. It improves performance, reduces server load, and helps users navigate large datasets easily. This guide covers common pagination strategies, implementation tips, and best practices for clean, efficient API design.
APIs are the backbone of modern software, but speed, reliability, and efficiency do not happen by accident. This guide explains what API performance really means, which metrics matter, and how to optimize at every layer to meet the standards top platforms set.