Rate Limits

The MediLoop API implements rate limiting to ensure fair usage and maintain service quality for all users.

Rate Limit Tiers

Rate limits vary based on your subscription plan:

PlanRequests/minRequests/dayBulk Recipients
Sandbox10010,000100
Starter30050,000500
Professional1,000500,0001,000
EnterpriseCustomCustomCustom

Rate Limit Headers

Every API response includes headers to help you track your rate limit status:

HeaderDescription
X-RateLimit-LimitMaximum requests allowed per minute
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the limit resets
Example Response Headers
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 295
X-RateLimit-Reset: 1705315200

Rate Limit Exceeded

When you exceed the rate limit, the API returns a 429 Too Many Requests response:

RESPONSE429
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Please retry after 60 seconds.",
    "type": "rate_limit_error",
    "retry_after": 60
  }
}

Handling Rate Limits

Best practices for handling rate limits:

  • Monitor headers - Check X-RateLimit-Remaining before making requests
  • Implement exponential backoff - When rate limited, wait and retry with increasing delays
  • Use bulk endpoints - Send multiple items in one request when possible
  • Cache responses - Avoid repeated requests for the same data
  • Queue requests - Spread requests over time instead of bursting

Exponential Backoff Example

import time
import requests

def make_request_with_retry(url, headers, max_retries=5):
    for attempt in range(max_retries):
        response = requests.get(url, headers=headers)
        
        if response.status_code == 429:
            retry_after = int(response.headers.get('Retry-After', 60))
            wait_time = min(retry_after, 2 ** attempt)
            print(f"Rate limited. Waiting {wait_time}s...")
            time.sleep(wait_time)
            continue
        
        return response
    
    raise Exception("Max retries exceeded")

Endpoint-Specific Limits

Some endpoints have additional limits:

EndpointLimitNotes
Bulk notifications1,000 recipients/requestUse for mass notifications
Patient registration100/minuteDuplicate detection adds overhead
AI processing60/minuteAI endpoints have lower limits

Requesting Higher Limits

If you need higher rate limits, you can:

  • Upgrade to a higher plan in the Developer Portal
  • Contact support for Enterprise custom limits
  • Request temporary limit increases for specific events