MuleSoft for Treblle
Prerequisites
Before you begin, make sure you have:
- MuleSoft API Gateway 4+
- Java 17 or higher
- Anypoint Studio 7.21.0 or later
- An active MuleSoft account with API Manager access
- Maven 3.8+ configured with proper
settings.xml
- A Treblle account with API key and SDK token
Creating and Deploying the Custom Policy
This guide will walk you through creating, configuring, and deploying a custom Mule 4 policy that sends incoming request payloads and headers to Treblle when a request is received.
Obtaining Organization ID
- Navigate to Anypoint Platform Business Groups
- Select your business group
- Note the Business Group ID from the URL or page details. You’ll need this for the next step.
Updating Policy Configuration
-
Clone the Treblle MuleSoft repository:
Terminal window git clone https://github.com/Treblle/treblle-mulesoft.gitcd treblle-mulesoft -
Open
treblle-policy/pom.xml
and update thegroupId
with your Business Group ID:<groupId>{BUSINESS_GROUP_ID}</groupId>
Configuring Maven Settings
-
Navigate to the
samples/.m2/settings.xml
file -
Update your MuleSoft credentials:
<username>{YOUR_MULESOFT_USERNAME}</username><password>{YOUR_MULESOFT_PASSWORD}</password>
Building and Deploying the Policy
-
Navigate to the
treblle-policy
directory:Terminal window cd treblle-policy -
Build the policy:
Terminal window mvn -s ../samples/.m2/settings.xml clean package -
Deploy to MuleSoft Exchange:
Terminal window mvn -s ../samples/.m2/settings.xml clean deploy
Verifying Policy Installation
- Visit Anypoint Exchange
- Search for “treblle policy”
- Confirm the policy is available in your organization
The policy should appear with version 1.0.0 and display as a Custom Policy.
Applying the Treblle Policy to Your API
Configuring API Manager
- Log in to Anypoint Platform
- Navigate to API Manager
- Select your API (e.g.,
hello-world
) - Go to the Policies tab
- Click Apply New Policy
Configuring Treblle Policy
- Choose treblle-policy from the list of available policies
- Configure the policy with your Treblle credentials:
- API Key: Enter your Treblle API key
- SDK Token: Enter your Treblle SDK token
Applying and Testing
- Save the policy configuration
- Apply the policy to your API
- Invoke your API endpoint with a test request
- Check your Treblle Dashboard to see the API traffic
The request should appear in Treblle within a few seconds, including headers, payload, and response data.
How It Works
The Treblle MuleSoft policy acts as a middleware that:
- Intercepts incoming API requests before they reach your implementation
- Captures request payloads and headers without modifying them
- Sends the data asynchronously to Treblle’s servers
- Allows the request to continue to your API implementation without delay