# Rate Limiting

The WarpLink REST API allows 60 requests per minute per API key for management operations such as listing apps or creating links. The API limits are the same on every plan. These limits apply to API calls, separate from traffic to your short links.

## How It Works

| Calls | Limit | What shares the allowance |
|-------|-------|---------------------------|
| REST management endpoints, such as `GET /v1/apps` | 60 requests per minute | All management requests that use the same API key |
| [SDK device routes](#sdk-routes), including referral claims | 60 requests per minute | Requests with the same key and client IP address |
| MCP | 60 calls per minute per credential, plus 600 requests per minute per client IP address | REST management and MCP share the credential allowance when they use the same API key. An MCP OAuth access token has its own allowance. |
| MCP OAuth registration, token, authorization, and consent | 60 requests per minute per endpoint and client IP address | Clients at the same address share each endpoint's allowance. The consent page and consent submission share one allowance. |
| MCP OAuth client registration | 10 registrations per hour per client IP address | This hourly limit applies in addition to the registration endpoint's per-minute limit. Reuse your registered client ID. |

The management, referral claim, MCP, and OAuth limits use sliding windows. An MCP batch uses one unit of the credential allowance per JSON-RPC call in the batch. A POST carrying five calls uses five units. The client IP allowance counts the POST as one request.

## SDK Routes

| Route | Used for |
|-------|----------|
| `GET /v1/sdk/validate` | SDK initialization |
| `GET /v1/links/resolve/{slug}` | Deep link handling |
| `POST /v1/attribution/match` | Install attribution and deferred deep links |
| `POST /v1/referrals/claims` | Recording a referral claim |

Devices behind the same public IP address share the SDK allowance when they use the same key. IPv6 addresses in the same /64 network prefix count together. The same rule applies when your backend calls a device route with an API key. For example, pace a job that submits referral claims from one server so the requests stay within that server's allowance.

Validation, link resolution, and attribution matching use an approximate 60-second period. Referral claims use the sliding window.

## Response Headers

| Header | Meaning |
|--------|---------|
| `X-RateLimit-Limit` | Size of the allowance the limiter checked. For a request stopped by a different limit, this value can differ from 60. |
| `X-RateLimit-Remaining` | Units left in the measured allowance after the request. |
| `X-RateLimit-Reset` | Seconds until the limiter's reported reset time. The value is a duration in seconds. |
| `Retry-After` | Seconds to wait before retrying a rate-limited request. |

A successful validation, link resolution, or attribution match request normally carries only `X-RateLimit-Limit`. When the limiter for these routes returns `429`, its wait is an estimate. Read `Retry-After` when it is present, and use `X-RateLimit-Remaining` from the response you already received to pace the next request. A separate API call to check the headers uses part of the allowance.

## Handling Rate Limits

When the API rate limiter rejects a request, it returns HTTP `429` and this body:

```json
{
  "error": {
    "code": "RATE_LIMIT_EXCEEDED",
    "message": "Rate limit exceeded. Try again later."
  }
}
```

Wait at least as long as `Retry-After` before retrying. If the header is absent, increase the wait after each failed attempt and add a small random delay so concurrent clients retry at different times. Cap the number of attempts and report the final error. If several jobs share a key, pause the shared queue instead of letting each job retry on its own.

For supported create requests, reuse the same `Idempotency-Key` and body when retrying. See [Safe retries and dry runs](https://warplink.app/docs/api#safe-retries-and-dry-runs).

## Worked Example

This read-only example uses the `WARPLINK_API_KEY` environment variable. Set it to an [API key](https://warplink.app/docs/authentication) with the `apps:read` scope. curl waits for `Retry-After` when supplied and retries transient failures, including HTTP `429`, up to three times.

```bash
curl --fail-with-body --retry 3 --retry-max-time 120 \
  -H "Authorization: Bearer ${WARPLINK_API_KEY}" \
  https://api.warplink.app/v1/apps
```

For example, a request limited by the management allowance could return these headers. If curl retries within the time budget, it waits at least 38 seconds before the next attempt.

```http
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 38
Retry-After: 38
```

## Best Practices

- Limit concurrency across workers using the same key. For a scheduled import or sync, spread work across the run.
- Reuse responses when the data can be cached. Use pagination to read a page of records in one call.
- Keep writes safe to retry. Save the idempotency key with the job when the operation supports one.

## Troubleshooting

**Why did a job reach the limit before it sent 60 requests?** Check whether more than one worker or an MCP client uses the same API key. On SDK routes, check whether devices use the same public IP address.

**Why did an SDK route return `429` after authentication errors?** Repeated failed authentication on validation, link resolution, or attribution match requests can temporarily limit the client IP address. Check the key configuration before starting retries.
