> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limits

> Understand CometChat REST API rate limits, response headers, and how to handle rate-limited requests in your React Native application.

<Accordion title="AI Integration Quick Reference">
  * Core Operations (login, create/delete user, create/join group): `10,000` requests/min cumulative
  * Standard Operations (all other): `20,000` requests/min cumulative
  * Rate-limited responses return HTTP `429` with `Retry-After` and `X-Rate-Limit-Reset` headers
  * Monitor usage via `X-Rate-Limit` and `X-Rate-Limit-Remaining` response headers
</Accordion>

CometChat applies rate limits to REST API requests to ensure fair usage and platform stability. SDK methods that call the REST API under the hood (like fetching users, sending messages, or creating groups) are subject to these limits. Understanding them helps you build applications that handle high traffic gracefully.

## Rate Limit Tiers

| Operation Type      | Limit               | Examples                                     |
| ------------------- | ------------------- | -------------------------------------------- |
| Core Operations     | 10,000 requests/min | Login, create/delete user, create/join group |
| Standard Operations | 20,000 requests/min | All other operations                         |

<Note>
  Rate limits are cumulative within each tier. For example, if you make 5,000 login requests and 5,000 create user requests in one minute, you've hit the 10,000 core operations limit.
</Note>

## Response Headers

CometChat includes rate limit information in response headers:

| Header                   | Description                               |
| ------------------------ | ----------------------------------------- |
| `X-Rate-Limit`           | Your current rate limit                   |
| `X-Rate-Limit-Remaining` | Requests remaining in current window      |
| `Retry-After`            | Seconds to wait before retrying (on 429)  |
| `X-Rate-Limit-Reset`     | Unix timestamp when limit resets (on 429) |

## Handling Rate Limits

When you exceed the rate limit, CometChat returns HTTP `429 Too Many Requests`. Implement exponential backoff to handle this gracefully:

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    async function callWithRetry<T>(
      apiCall: () => Promise<T>,
      maxRetries: number = 3
    ): Promise<T> {
      for (let attempt = 0; attempt < maxRetries; attempt++) {
        try {
          return await apiCall();
        } catch (error: any) {
          if (error.code === "TOO_MANY_REQUEST" && attempt < maxRetries - 1) {
            const waitTime = Math.pow(2, attempt) * 1000;
            console.log(`Rate limited. Retrying in ${waitTime / 1000}s...`);
            await new Promise((resolve) => setTimeout(resolve, waitTime));
          } else {
            throw error;
          }
        }
      }
      throw new Error("Max retries exceeded");
    }

    // Usage
    const users: CometChat.User[] = await callWithRetry(() =>
      new CometChat.UsersRequestBuilder().setLimit(30).build().fetchNext()
    );
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    async function callWithRetry(apiCall, maxRetries = 3) {
      for (let attempt = 0; attempt < maxRetries; attempt++) {
        try {
          return await apiCall();
        } catch (error) {
          if (error.code === "TOO_MANY_REQUEST" && attempt < maxRetries - 1) {
            const waitTime = Math.pow(2, attempt) * 1000; // 1s, 2s, 4s
            console.log(`Rate limited. Retrying in ${waitTime / 1000}s...`);
            await new Promise((resolve) => setTimeout(resolve, waitTime));
          } else {
            throw error;
          }
        }
      }
    }

    // Usage
    const users = await callWithRetry(() =>
      new CometChat.UsersRequestBuilder().setLimit(30).build().fetchNext()
    );
    ```
  </Tab>
</Tabs>

## Tips for Staying Within Limits

* **Batch operations** — Space out bulk operations over time instead of firing all at once
* **Monitor headers** — Check `X-Rate-Limit-Remaining` to proactively slow down before hitting limits
* **Avoid frequent login/logout** — Core operations share a lower limit; minimize login cycles
* **Use pagination** — Fetch data in reasonable page sizes (30-50 items) rather than requesting everything at once

<Note>
  Rate limits can be adjusted based on your use case and plan. Contact CometChat support if you need higher limits.
</Note>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Key Concepts" icon="book" href="/sdk/react-native/key-concepts">
    Review the fundamental building blocks of CometChat
  </Card>

  <Card title="Setup & Authentication" icon="lock" href="/sdk/react-native/overview">
    Initialize CometChat and authenticate users in your app
  </Card>

  <Card title="Real-Time Listeners" icon="tower-broadcast" href="/sdk/react-native/real-time-listeners">
    Complete reference for all SDK event listeners
  </Card>

  <Card title="Connection Status" icon="signal" href="/sdk/react-native/connection-status">
    Monitor SDK connection state changes
  </Card>
</CardGroup>
