Website • Documentation • Pricing
Treblle is an API intelligence platfom that helps developers, teams and organizations understand their APIs from a single integration point.
- .NET Framework 4.6.2 or higher (supports 4.6.2, 4.7.x, 4.8, and 4.8.1)
- ASP.NET Web API 5.2.7+
- Newtonsoft.Json 13.0.3+
Install-Package Treblle.Netdotnet add package Treblle.Net- Right-click on your project in Solution Explorer
- Select "Manage NuGet Packages"
- Search for "Treblle.Net"
- Click "Install"
Add your Treblle credentials to Web.config:
<configuration>
<appSettings>
<add key="Treblle:ApiKey" value="{Your_API_Key}" />
<add key="Treblle:SdkToken" value="{Your_SDK_Token}" />
</appSettings>
</configuration>Get your credentials: Visit your Treblle Dashboard → Find your API → Navigate to Settings → Copy SDK Token and API Key
Simply register the Treblle handler in your WebApiConfig.cs and all API endpoints will be tracked automatically:
using Treblle.Net;
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Add Treblle handler - tracks all endpoints automatically
config.MessageHandlers.Add(new TreblleHandler());
// Your existing Web API configuration
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}That's it! All your API endpoints are now being monitored. 🎉
For fine-grained control, you can use the [Treblle] attribute on specific controllers or methods:
[Treblle]
public class ProductsController : ApiController
{
public IHttpActionResult Get()
{
return Ok(_productService.GetAll());
}
}These two settings are required for the SDK to function:
<configuration>
<appSettings>
<add key="Treblle:ApiKey" value="{Your_API_Key}" />
<add key="Treblle:SdkToken" value="{Your_SDK_Token}" />
</appSettings>
</configuration>All optional configuration settings:
| Setting | Type | Default | Description |
|---|---|---|---|
Treblle:ExcludedPaths |
string | (none) | Comma-separated paths to exclude from tracking |
Treblle:AdditionalFieldsToMask |
string | (none) | Comma-separated field names to mask |
Treblle:DisableMasking |
bool | false |
Disable data masking |
Treblle:Debug |
bool | false |
Enable detailed debug logging |
<configuration>
<appSettings>
<!-- Required -->
<add key="Treblle:ApiKey" value="{Your_API_Key}" />
<add key="Treblle:SdkToken" value="{Your_SDK_Token}" />
<!-- Optional -->
<add key="Treblle:ExcludedPaths" value="/health,/admin/*,/internal/*" />
<add key="Treblle:AdditionalFieldsToMask" value="apiKey,authToken,internalId" />
<add key="Treblle:Debug" value="false" />
<add key="Treblle:DisableMasking" value="false" />
</appSettings>
</configuration>The SDK automatically masks sensitive fields before sending data to Treblle. This happens on your server before any data leaves your infrastructure.
The following fields are automatically masked:
Authentication & Secrets:
password,pwdsecretpassword_confirmation,passwordConfirmation
Financial Data:
cc,card_number,cardNumber,ccvcredit_score,creditScore
Personal Information:
emailssnaccount.*(all account fields)
Nested Fields:
user.email,user.dob,user.password,user.ssuser.payments.cc
Different field types use different masking strategies:
| Field Type | Strategy | Example |
|---|---|---|
| Passwords/Secrets | Complete masking | ***** |
| Credit Cards | Last 4 digits visible | ****-****-****-1234 |
| Emails | Partial masking | j***@example.com |
| SSN | Last 4 digits visible | ***-**-1234 |
| Dates | Year masked | 12/25/**** |
Add your own fields to mask:
<add key="Treblle:AdditionalFieldsToMask" value="apiKey: DefaultStringMasker,authToken: DefaultStringMasker,dob: DateMasker" />Available Maskers:
DefaultStringMasker- Complete maskingCreditCardMasker- Credit card number maskingEmailMasker- Email address maskingSocialSecurityMasker- SSN maskingDateMasker- Date masking
Simple format (uses DefaultStringMasker):
<add key="Treblle:AdditionalFieldsToMask" value="customSecret,apiToken,internalId" /><add key="Treblle:DisableMasking" value="true" />Warning: This sends all data (passwords, credit cards, emails, etc.) in plain text. We suggest that you use this only in development/testing environments.
The SDK automatically excludes common non-API requests:
File Extensions:
.css,.js,.map.jpg,.jpeg,.png,.gif,.svg,.ico.woff,.woff2,.ttf,.eot.mp4,.mp3,.webm.pdf,.zip,.rar,.tar,.gz.html,.htm
Default Paths:
/swagger/*,/swagger-ui/*,/swagger-resources/*/assets/*,/static/*,/public/*/css/*,/js/*,/images/*,/img/*,/fonts/*/favicon.ico,/robots.txt,/sitemap.xml/_next/*,/_nuxt/*,/node_modules/*/.well-known/*
Content Types:
- HTML, CSS, JavaScript
- Images, videos, audio
- Fonts
- Binary files
Exclude specific endpoints using pattern matching:
<add key="Treblle:ExcludedPaths" value="/health,/admin/*,internal,/debug/info" />Pattern Matching:
| Pattern | Behavior | Example |
|---|---|---|
/health |
Exact match | Excludes only /health |
/admin/* |
Wildcard match | Excludes all paths starting with /admin/ |
internal |
Segment match | Excludes any path containing internal |
/api/v1/status,/api/v2/status |
Multiple patterns | Comma-separated list |
Examples:
/health→ Matches/healthonly/admin/*→ Matches/admin/users,/admin/settings, etc.swagger→ Matches/swagger,/api/swagger,/v1/swagger/docs, etc./api/internal/*,/debug/*→ Matches both patterns
Enable debug mode to see detailed logging of SDK operations:
<add key="Treblle:Debug" value="true" />Configuration Status:
[TREBLLE DEBUG] === TREBLLE CONFIGURATION ===
[TREBLLE DEBUG] ✅ SDK Token: ab12****ef78
[TREBLLE DEBUG] ✅ API Key: cd34****gh90
[TREBLLE DEBUG] 🔧 Debug Mode: ENABLED
Request Tracking:
[TREBLLE DEBUG] 🚀 Request Started: POST /api/users
[TREBLLE DEBUG] 🔒 Applied data masking to 12 fields
[TREBLLE DEBUG] 📊 Payload size: 2.34 KB
[TREBLLE DEBUG] ✅ Request Completed: POST /api/users - Status: 201 - Load Time: 155ms
[TREBLLE DEBUG] 📤 Payload sent to Treblle - Response: 200
Skipped Requests:
[TREBLLE DEBUG] ⏭️ Request skipped: Missing SDK Token or API Key configuration
[TREBLLE DEBUG] ⏭️ Request skipped: Filtered out (static asset)
[TREBLLE DEBUG] ⏭️ Request skipped: Response content type not tracked (text/html)
Error Tracking:
[TREBLLE DEBUG] ❌ Error in request capture: NullReferenceException
[TREBLLE DEBUG] ❌ Error in payload sending: HTTP 401: Unauthorized
Upgrading from Treblle.Net v1.x to v2.x requires a few configuration changes. This guide will help you migrate smoothly.
The configuration keys have been renamed to use the Treblle: prefix:
Old (v1.x):
<appSettings>
<add key="TreblleApiKey" value="{Your_API_Key}" />
<add key="TreblleProjectId" value="{Your_Project_Id}" />
</appSettings>New (v2.x):
<appSettings>
<add key="Treblle:ApiKey" value="{Your_API_Key}" />
<add key="Treblle:SdkToken" value="{Your_SDK_Token}" />
</appSettings>Note: TreblleProjectId is now called Treblle:SdkToken. You can find your SDK Token in the Treblle Dashboard.
All optional configuration keys now use the Treblle: prefix:
| v1.x Key | v2.x Key |
|---|---|
AdditionalFieldsToMask |
Treblle:AdditionalFieldsToMask |
DisableMasking |
Treblle:DisableMasking |
Debug |
Treblle:Debug |
| N/A | Treblle:ExcludedPaths (new feature) |
# Update to v2.x
Update-Package Treblle.NetOr via .NET CLI:
dotnet add package Treblle.Net --version 2.0.1Replace your old configuration:
<!-- OLD - Remove this -->
<appSettings>
<add key="TreblleApiKey" value="your-api-key-here" />
<add key="TreblleProjectId" value="your-project-id-here" />
<add key="AdditionalFieldsToMask" value="field1,field2" />
</appSettings>With the new configuration:
<!-- NEW - Use this -->
<appSettings>
<add key="Treblle:ApiKey" value="your-api-key-here" />
<add key="Treblle:SdkToken" value="your-sdk-token-here" />
<add key="Treblle:AdditionalFieldsToMask" value="field1,field2" />
</appSettings>The Treblle SDK modifies some global ServicePointManager settings when first initialized. These changes affect all HTTP clients in your application, including third-party libraries.
The SDK configures the following global settings for optimal performance and security:
| Setting | Value | Purpose |
|---|---|---|
SecurityProtocol |
TLS 1.2 + TLS 1.1 | Ensures secure HTTPS communication |
DefaultConnectionLimit |
10 | Allows up to 10 concurrent connections per endpoint |
MaxServicePointIdleTime |
90 seconds | Keeps connections alive for connection reuse |
Expect100Continue |
Disabled | Improves request performance |
UseNagleAlgorithm |
Disabled | Reduces latency for small packets |
These settings will apply to all HttpClient, WebClient, and HttpWebRequest instances in your application, not just Treblle's HTTP calls.
Good news: These are generally beneficial defaults that improve performance and security for most applications.
If your application requires different ServicePointManager settings:
- Configure after Treblle initializes: Add your custom settings in
Global.asax.csor your startup code after the first Treblle request - Override specific settings: You can change any setting after Treblle loads - your changes will persist
// In Global.asax.cs Application_Start
protected void Application_Start()
{
// Your Web API config (Treblle gets initialized here)
GlobalConfiguration.Configure(WebApiConfig.Register);
// Override Treblle's settings if needed
ServicePointManager.DefaultConnectionLimit = 100; // Your custom value
ServicePointManager.UseNagleAlgorithm = true; // Your custom value
}- Need help?: If this causes issues, please open an issue on GitHub - we're happy to make this configurable
Check configuration:
<!-- Both are required -->
<add key="Treblle:ApiKey" value="{Your_API_Key}" />
<add key="Treblle:SdkToken" value="{Your_SDK_Token}" />Enable debug mode to see what's happening:
<add key="Treblle:Debug" value="true" />Common issues:
- ✅ Handler not registered in
WebApiConfig.cs - ✅ Request is being filtered out (check debug logs)
- ✅ Path is in excluded paths list
- ✅ Content type is not JSON-based
Check debug logs for skip reasons:
[TREBLLE DEBUG] ⏭️ Request skipped: Filtered out (static asset)
Common filter reasons:
- Static file extensions (
.css,.js,.png, etc.) - HTML responses (
text/html) - Path matches excluded patterns
- No JSON response payload
Requests/responses over 2MB are replaced with size information:
{
"message": "Response payload over 2MB limit",
"size_bytes": 3145728,
"size_mb": 3.0,
"treblle_info": "Payload content replaced due to size limit"
}Solution: This is by design to prevent performance issues. The event is still tracked with metadata.
Connection timeout:
- Default timeout: 10 seconds
- Check firewall rules for outbound HTTPS
- Verify network connectivity to
*.treblle.com
application/json✅application/x-www-form-urlencoded✅multipart/form-data✅
application/json✅application/vnd.api+json✅application/ld+json✅application/hal+json✅application/problem+json✅text/json✅- Empty responses (201, 204, etc.) ✅
application/xml❌ (Use Treblle.Net.Wcf for WCF/XML services)text/xml❌text/html❌- Binary content types ❌
If you have problems of any kind feel free to reach out via https://treblle.com or email [email protected] and we'll do our best to help you out.
Copyright 2025, Treblle Inc. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
