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

# Limites de Taxa

> Entenda os limites que se aplicam às requisições da API e como tratá-los.

A Vendaze API aplica limites de taxa por aplicativo (`client_id`) por minuto para garantir uso justo e proteger a disponibilidade do serviço.

## Limites por método HTTP

| Método   | Limite        | Aplica-se a                |
| -------- | ------------- | -------------------------- |
| `GET`    | 1.000 req/min | Todos os endpoints `/v1/*` |
| `POST`   | 200 req/min   | Todos os endpoints `/v1/*` |
| `PATCH`  | 200 req/min   | Todos os endpoints `/v1/*` |
| `DELETE` | 100 req/min   | Todos os endpoints `/v1/*` |

Endpoints OAuth têm limites mais restritos por IP:

| Endpoint                     | Limite             |
| ---------------------------- | ------------------ |
| `POST /oauth/token`          | 20 req/min por IP  |
| `POST /oauth/revoke`         | 20 req/min por IP  |
| `GET /oauth/authorize`       | 20 req/min por IP  |
| `POST /v1/auth/register-app` | 10 req/hora por IP |
| `POST /v1/auth/rotate-app`   | 10 req/hora por IP |

## Headers de controle

Toda resposta inclui headers com seu consumo atual:

```
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: 1748000060
```

| Header                  | Descrição                                   |
| ----------------------- | ------------------------------------------- |
| `X-RateLimit-Limit`     | Limite total da janela atual.               |
| `X-RateLimit-Remaining` | Requisições restantes na janela.            |
| `X-RateLimit-Reset`     | Unix timestamp de quando a janela reinicia. |

## Quando o limite é excedido

```http theme={null}
HTTP/1.1 429 Too Many Requests
Retry-After: 60
```

```json theme={null}
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit exceeded. Try again in 60 seconds.",
    "request_id": "uuid"
  }
}
```

Use backoff exponencial com jitter ao receber um `429`:

```javascript theme={null}
async function withRetry(fn, maxAttempts = 3) {
  for (let attempt = 0; attempt < maxAttempts; attempt++) {
    const res = await fn();
    if (res.status !== 429) return res;

    const retryAfter = parseInt(res.headers.get('Retry-After') ?? '60');
    const jitter = Math.random() * 1000;
    await new Promise((r) => setTimeout(r, retryAfter * 1000 + jitter));
  }
  throw new Error('Max retry attempts exceeded');
}
```
