Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions developer/reference/rate-limits/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
The Makeswift REST API implements rate limiting to ensure fair usage and protect service stability. Rate limits are applied per authentication token across all endpoints.

---

## Rate Limit Configuration

### Limits

- **Rate**: 100 requests per second
- **Time Window (TTL)**: 1 second
- **Scope**: Per authentication token (API key or Bearer token)

### What This Means

Each unique API key or Bearer token is allowed to make up to 100 requests per second. The limit resets every second, providing a rolling window of allowed requests.

---

## Response Headers

<Note>
While both API Key and Bearer Token authentication methods are supported, you
must use **only one** authentication method per request. Requests that include
both an API Key and Bearer Token will be rejected.
</Note>

### Rate Limit Headers

Every API response includes headers showing your current rate limit status:

```http
x-ratelimit-limit: 100
x-ratelimit-remaining: 95
x-ratelimit-reset: 1
```

#### Header Descriptions

| Header | Description | Example |
| ----------------------- | -------------------------------------------------- | ------- |
| `x-ratelimit-limit` | Maximum requests allowed in the current window | `100` |
| `x-ratelimit-remaining` | Number of requests remaining in the current window | `95` |
| `x-ratelimit-reset` | Time in seconds until the limit resets | `1` |

---

## Rate Limit Exceeded

### 429 Response

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

**Example Response:**

```http
HTTP/1.1 429 Too Many Requests
x-ratelimit-limit: 100
x-ratelimit-remaining: 0
x-ratelimit-reset: 1
Content-Type: application/json

{
"statusCode": 429,
"message": "ThrottlerException: Too Many Requests",
"error": "Too Many Requests"
}
```

### What to Do

1. **Wait**: Wait for the time specified in `x-ratelimit-reset` header (typically 1 second)
2. **Retry**: Implement exponential backoff for retries
3. **Monitor**: Track the `x-ratelimit-remaining` header to avoid hitting limits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc may be too specific. Some of our existing behavior was decided on haphazardly, like having 100 requests per second or the particular way that we do throttling. I think we need to be a lot more generic here in this doc and just say that we implement rate limiting and reserve the right to change it in the future.

I think this can be a comment. I don't think it needs to be an entire document. Sorry if you feel like you're getting whiplash on this.

4 changes: 4 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,10 @@
]
}
]
},
{
"group": "Rate limits",
"pages": ["developer/reference/rate-limits/overview"]
}
]
}
Expand Down