> For the complete documentation index, see [llms.txt](https://docs.jgopay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jgopay.com/english/rate-limiting.md).

# Rate Limiting

All API endpoints are rate-limited per merchant to protect service stability. Limits are tracked by merchant ID for authenticated requests and by IP address for unauthenticated requests.

## Limits

| Endpoint                 | Limit        | Window   |
| ------------------------ | ------------ | -------- |
| `POST /auth/token`       | 5 requests   | 1 minute |
| `POST /payment/request`  | 100 requests | 1 minute |
| `POST /payment/withdraw` | 50 requests  | 1 minute |
| Other endpoints          | 100 requests | 1 minute |

Limits reset on a sliding window basis.

## Exceeding the Limit

When you exceed the rate limit, the API returns HTTP `429 Too Many Requests`:

```json
{
  "statusCode": 429,
  "message": "Too Many Requests",
  "error": "Too Many Requests",
  "timestamp": "2026-02-04T10:30:00.000Z",
  "path": "/api/v1/payment/request",
  "correlationId": "abc-123-def-456"
}
```

## Response Headers

Every API response includes rate limit headers:

| Header                  | Description                                     |
| ----------------------- | ----------------------------------------------- |
| `X-RateLimit-Limit`     | Maximum requests allowed in the current window  |
| `X-RateLimit-Remaining` | Requests remaining in the current window        |
| `X-RateLimit-Reset`     | Unix timestamp (seconds) when the window resets |
| `Retry-After`           | Seconds to wait before retrying (only on 429)   |

Use `Retry-After` when present — it's more accurate than calculating from `X-RateLimit-Reset`.

## Recommended Backoff Strategy

Use exponential backoff with jitter to avoid thundering herd:

```javascript
async function requestWithBackoff(fn, maxRetries = 3) {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    const response = await fn();

    if (response.status !== 429) return response;

    if (attempt === maxRetries) throw new Error('Rate limit exceeded after retries');

    // Exponential backoff: 1s, 2s, 4s + random jitter up to 1s
    const delay = Math.pow(2, attempt) * 1000 + Math.random() * 1000;
    await new Promise((resolve) => setTimeout(resolve, delay));
  }
}
```

## Best Practices

* **Cache access tokens** — Tokens are valid for 1 hour. Request once and reuse, don't request a new token per API call.
* **Queue requests client-side** — If you process bulk payments, queue them and respect the per-minute limit rather than sending all at once.
* **Don't retry 4xx errors** — Only retry on `429` (rate limit) and `5xx` (server error). Retrying `400` or `422` will always produce the same result.
* **Use `correlationId`** — Include it in support requests for faster debugging.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.jgopay.com/english/rate-limiting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
