Rate Limits
Each API key can generate up to 120 mockups per minute. The limit stops a runaway loop from emptying your wallet (or, with automatic refills, charging your card again and again). It is well above what real integrations use.
How it is counted
- The limit applies to
POST /api/v1/mockups/generate. Listing templates and sets, reading your balance and uploading artwork are not limited this way. - It counts mockups, not requests. A request with 12 templates uses 12 of the minute's 120. A request with one template uses 1.
- The window is a rolling 60 seconds: each mockup stops counting 60 seconds after its request.
- The limit is per API key. Retries that return a stored result through an
Idempotency-Keydon't count.
When you go over
The request is refused before anything renders, so nothing is charged. You get a 429 response with a Retry-After header (seconds to wait) and this body:
{
"error": "Rate limit exceeded: up to 120 mockups per minute per API key. Retry in 23 seconds.",
"code": "RATE_LIMIT_EXCEEDED",
"details": {
"limit": 120,
"window_seconds": 60,
"requested": 12,
"retry_after": 23
},
"hint": "Wait retry_after seconds (also sent as the Retry-After header), then send the same request again. Nothing was charged.",
"request_id": "013b73a7-9d8e-4a5d-9e45-251197bd75a1"
}| Field | Meaning |
|---|---|
details.limit | Mockups allowed per minute for this key |
details.window_seconds | Length of the rolling window |
details.requested | Mockups this request would make. Templates a set still lists after you deleted them don't count |
details.retry_after | Seconds until this request would fit (same as the Retry-After header) |
Wait retry_after seconds and send the same request again. Responses under the limit carry no rate limit headers.
Handling it in code
async function generate(body, idempotencyKey = crypto.randomUUID()) {
for (let attempt = 0; attempt < 5; attempt++) {
const response = await fetch('https://www.mockupanda.com/api/v1/mockups/generate', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MOCKUPANDA_API_KEY}`,
'Content-Type': 'application/json',
// Same key on every attempt: a retry can never be charged twice.
'Idempotency-Key': idempotencyKey
},
body: JSON.stringify(body)
});
if (response.status !== 429) return response;
const wait = Number(response.headers.get('Retry-After')) || 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, wait * 1000));
}
throw new Error('Still rate limited after 5 attempts');
}Staying under the limit
- Send requests one after another rather than many at once. A single request renders its templates one by one, so a steady loop of requests rarely gets near 120 a minute.
- Batch templates: one request with several
template_ids(up to 12) is the same count as several single requests, with less overhead. - Don't regenerate the same artwork on the same template. Keep the result you already paid for.
Need more?
If your volume needs a higher limit, contact us through the feedback button in your dashboard and tell us how many mockups you expect per hour, so we can work out a higher limit with you.