> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invaro.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limits

> Understanding API rate limits and best practices

Rate limits are enforced per API key to ensure fair usage of the API and maintain service stability.

<Note>
  All rate limits are calculated on a per-minute basis and reset automatically at the start of each window.
</Note>

## Rate Limit Overview

<Card title="Default Limits" icon="gauge-high">
  * **60 requests** per minute per API key
  * Batch operations count as multiple requests
  * Rolling window reset
</Card>

<Card title="Batch Operations" icon="layer-group">
  Each item in a batch counts as one request:

  * Uploading 10 files = 10 requests
  * Processing 5 statements = 5 requests
</Card>

## Rate Limit Headers

The API includes rate limit information in the response headers:

<ResponseField name="Rate Limit Headers" type="object">
  <Expandable title="Header Details">
    ```http theme={null}
    X-RateLimit-Limit: 60
    X-RateLimit-Remaining: 45
    X-RateLimit-Reset: 1704624000
    ```

    * `X-RateLimit-Limit`: Maximum requests allowed per minute
    * `X-RateLimit-Remaining`: Number of requests remaining in the current window
    * `X-RateLimit-Reset`: Unix timestamp when the rate limit will reset
  </Expandable>
</ResponseField>

## Handling Rate Limits

<Steps>
  1. **Monitor Headers**
     Check the `X-RateLimit-Remaining` header to track your remaining requests.

  2. **Implement Backoff**
     When you receive a rate limit error, wait until the reset time before retrying:
     ```json theme={null}
     {
       "success": false,
       "error": {
         "code": "RATE_LIMIT_EXCEEDED",
         "message": "Too many requests",
         "details": "Please wait before making more requests"
       }
     }
     ```

  3. **Optimize Requests**
     Use batch operations when possible to maximize your rate limit usage.
</Steps>

## Best Practices

<Card title="Implement Exponential Backoff" icon="clock-rotate-left">
  When rate limited, use exponential backoff to prevent overwhelming the API:

  ```javascript theme={null}
  function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
  }

  async function makeRequest(retries = 3) {
    for (let i = 0; i < retries; i++) {
      try {
        return await apiRequest();
      } catch (error) {
        if (error.code !== 'RATE_LIMIT_EXCEEDED') throw error;
        await sleep(Math.pow(2, i) * 1000);
      }
    }
  }
  ```
</Card>

<Card title="Batch Processing" icon="boxes-stacked">
  Group multiple items into single requests:

  ```javascript theme={null}
  // Instead of multiple single uploads
  const files = ['doc1.pdf', 'doc2.pdf', 'doc3.pdf'];
  const formData = new FormData();
  files.forEach(file => formData.append('files', file));

  // Single batch upload
  await api.upload(formData);
  ```
</Card>

## Need Higher Limits?

<Card title="Enterprise Plans" icon="building">
  For higher rate limits and dedicated support, contact our [sales team](mailto:sales@invaro.ai).

  Enterprise plans include:

  * Custom rate limits
  * Priority support
  * Dedicated account manager
</Card>
