Overview
Tresa Contafy API implements rate limiting to ensure fair usage and protect against abuse. Rate limits vary by endpoint and are enforced using a combination of IP-based and user-based throttling.Rate limits are designed to accommodate normal usage patterns. If you consistently hit rate limits, consider optimizing your integration or upgrading your plan.
Global API Rate Limit
All API endpoints under/api/ are protected by a global rate limiter:
- Window: 15 minutes
- Max requests: 1,000 requests per window (production)
- Max requests: 2,000 requests per window (development)
- Key: IP address
- Standard headers: Included in response
Configuration
Set via environment variable:Response Headers
Error Response
When limit is exceeded:429 Too Many Requests
Authentication Endpoints
Authentication endpoints have stricter rate limits to prevent brute force attacks:Endpoints Covered
POST /api/auth/loginPOST /api/auth/registerPOST /api/auth/googlePOST /api/auth/request-password-reset
Limits
- Window: 15 minutes
- Max requests: 5 requests per window (production)
- Max requests: 100 requests per window (development)
- Key: IP address
- Skip successful requests: Yes (only failed attempts count)
Error Response
Invoice Upload Endpoints
XML parsing and upload endpoints have per-user rate limits:Endpoints Covered
POST /api/invoices/parsePOST /api/invoices/uploadPOST /api/expenses/parsePOST /api/expenses/upload
Limits
- Window: 5 minutes
- Max requests: 300 requests per window
- Key: User ID (authenticated user)
- Fallback: IP address (if not authenticated)
Rate limit is per user, not per IP. This allows multiple users from the same network to upload simultaneously.
Key Generation
Error Response
Plan-Based Limits
Certain features have limits based on your subscription plan:Profile Limits
| Plan | Max Profiles |
|---|---|
| FREE | 1 |
| BASIC | 5 |
| PRO | 20 |
| ENTERPRISE | Unlimited |
validateProfileLimit middleware
Invoice and Expense Limits
All plans have unlimited invoices and expenses per month.While there’s no monthly limit, the 300 requests per 5 minutes upload rate limit still applies.
Public Report Tokens
| Plan | Max Active Tokens |
|---|---|
| FREE | 0 (feature disabled) |
| BASIC | 10 |
| PRO | 50 |
| ENTERPRISE | Unlimited |
validatePublicReportTokenLimit middleware
SAT AI Search Limits
| Plan | AI Searches per Month |
|---|---|
| FREE | 5 |
| BASIC | 100 |
| PRO | Unlimited |
| ENTERPRISE | Unlimited |
validateSATSearchLimit middleware
Feature Access Limits
Some features are restricted by plan:Public Reports
Required: BASIC plan or higherSAT Download (FIEL/e.firma)
Required: PRO plan or higherAPI Access
Required: PRO plan or higher All endpoints are available to PRO and ENTERPRISE plans. FREE and BASIC plans can use the web interface only.File Upload Limits
XML file uploads are limited by size:- Max file size: 10 MB
- Enforced by:
express-fileuploadmiddleware
Handling Rate Limits
Check Rate Limit Headers
Always check response headers to monitor your usage:Implement Exponential Backoff
When receiving a429 error, wait before retrying:
Batch Requests
Avoid making sequential requests in loops:Cache Responses
Cache responses that don’t change frequently:Monitoring Rate Limits
Application Logging
Log rate limit hits to identify issues:User Notifications
Inform users when approaching limits:Rate Limit Bypass
If you need higher limits:- Upgrade to PRO or ENTERPRISE plan
- Contact [email protected] for custom limits
- Optimize your integration to reduce requests
Proxy Considerations
The API runs behind a reverse proxy (Railway) in production:req.ipreflects the real client IP- Rate limiting works correctly for users behind the same proxy
X-Forwarded-Forheaders are trusted
OPTIONS Requests
CORS preflight requests (OPTIONS) are excluded from rate limits:OPTIONS requests don’t count toward your rate limit quota.
Best Practices
- Monitor headers: Always check
RateLimit-*headers - Implement backoff: Use exponential backoff for retries
- Batch operations: Group related requests together
- Cache aggressively: Cache static data like profiles and plans
- Respect limits: Don’t attempt to circumvent rate limits
- Upgrade when needed: Use appropriate plan for your usage
- Handle 429 gracefully: Show user-friendly error messages
- Log rate limit hits: Monitor and optimize high-traffic endpoints
Plan-Specific Recommendations
FREE Plan
- Focus on web interface usage
- Cache profile data locally
- Upload invoices in small batches
- Use parse endpoint to test before uploading
BASIC Plan
- Implement basic caching for profile lists
- Batch invoice uploads with delays
- Monitor public report token usage
PRO Plan
- Utilize full API access
- Implement robust caching layer
- Use webhooks for real-time updates
- Batch operations with higher concurrency
ENTERPRISE Plan
- Custom rate limits available on request
- Dedicated support for optimization
- Advanced monitoring and analytics
Getting Help
If you’re experiencing rate limit issues:- Review this guide and optimize your integration
- Check API Status for incidents
- Contact [email protected] with:
- Your user ID or email
- Affected endpoints
- Request patterns and frequency
- Business use case
Next Steps
- Upload invoices efficiently
- Manage subscriptions to increase limits
- Set up webhooks to reduce polling