⚡ Rate Limits, Concurrency & Retries
Every limit the Sweeppea API v3 applies, what each one answers when you reach it, and how to write a client that never trips over them.
Every other limit on this page sits well above it. A client that stays within its plan rate and honours the Retry-After header will never see any other limit.
The Limits at a Glance
| Limit | Value | Counted per | When you go over it |
|---|---|---|---|
| Plan rate limit | 150 calls per minute by default (MaxApiCallsPerMinute in POST /account/plan) | API key, rolling 60-second window, all endpoints together | 429 + exact Retry-After + X-RateLimit-Limit / X-RateLimit-Remaining. Not charged to your monthly allowance |
| Firewall | 1,000 requests per minute from one IP address (5,000 per rolling 5-minute window) | Source IP address, whatever the API key | 429 + Retry-After: 60 |
| Platform-wide throttle | 300 requests per second (bursts of 600) | All clients together | 429 + Retry-After: 1 |
| Monthly allowance | MaxApiCallsAllowed in POST /account/plan | Account, calendar month | Not blocked. Reported in every response (Telemetry); the account owner is emailed at 80% and 100%. Plan your usage or upgrade |
Two more rules apply before any limit is counted:
| Rule | What happens |
|---|---|
A request without Authorization: Bearer YOUR_API_KEY | 401, refused at the edge. It never reaches the API |
A request sent to any address other than https://api-v3.sweeppea.com | 403 with the correct address |
Your Plan's Rate Limit
Every account has an API rate limit: how many calls it may make in any sixty-second window, across every endpoint. It is part of your subscription plan, it is reported as MaxApiCallsPerMinute by POST /account/plan, and unless your plan says otherwise it is 150 calls per minute.
- It is a rate, not an allowance. It is never "spent" and never resets: at any moment it counts the calls of the last 60 seconds.
- It is counted per API key. Spreading the same key over several servers or addresses does not raise it.
- A refused call is not charged. It is never written to the API log, so it does not consume your monthly allowance.
- It is a different limit from
MaxApiCallsAllowed, which is the monthly total.
Going over it returns 429 Too Many Requests:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 7
X-RateLimit-Limit: 150
X-RateLimit-Remaining: 0
{
"Response": false,
"Message": "Rate limit exceeded: your plan allows 150 API calls per minute (rolling 60-second window, per API key). This call was NOT processed and does NOT count against your monthly allowance. Retry in 7 seconds.",
"Code": 429,
"Limit": 150,
"WindowSeconds": 60,
"RetryAfterSeconds": 7,
"Documentation": "https://apidocs.sweeppea.com/concurrency.html"
}
Retry-After is exact: it is the number of seconds until the oldest call in your window leaves it and a slot is free. Wait that long, then retry. Do not retry sooner, because the call will be refused again.
If your integration genuinely needs a higher rate, contact support. It is a plan setting and can be raised.
The Firewall
In front of the API there is a firewall that limits each IP address to 1,000 requests per minute, measured over a rolling five-minute window (5,000 requests per five minutes). It protects the platform from floods and is deliberately far above any plan rate: a client that respects its plan limit never reaches it.
When an IP address goes over it, every request from that address is answered for a short while with:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
"Response": false,
"Code": 429,
"Message": "Too many requests from your IP address. The API firewall allows up to 1,000 requests per minute from one IP address (measured over a rolling 5-minute window), independently of your plan. Nothing was processed. Wait the number of seconds in the Retry-After header, then try again.",
"Documentation": "https://apidocs.sweeppea.com/concurrency.html"
}
You can tell the two 429 answers apart by the body: the plan limit carries Limit and RetryAfterSeconds, the firewall does not. Both are handled the same way: wait Retry-After seconds, then retry.
the firewall answered 555 (with an empty body) above 75 requests per minute, or 403 (empty body) above 300 requests per five minutes. Both limits were below the plan rate and both codes are gone. If your client still special-cases them, treat them like 429.
Parallel Requests
You can send requests in parallel. Every endpoint processes many requests at the same time, and the platform keeps a fixed amount of capacity reserved for each one.
- Up to 5 requests in flight per API key is a comfortable pace. More parallelism does not make your plan rate any higher; it only reaches the limit sooner.
- Three endpoints process one request at a time platform-wide, because two simultaneous calls could corrupt data:
POST /winners/draw,POST /sweepstakes/createandPOST /sweepstakes/clone. Send them one at a time. If another call is already running, yours is answered500with the message "The API could not complete this request…" and was not processed: retry it after a few seconds.
Status Codes You Must Handle
| Status | Meaning | What to do |
|---|---|---|
200 / 201 | Success | — |
400 Bad Request | A parameter is missing or invalid. The body lists every accepted parameter under Help | Fix the request. Do not retry as is |
401 Unauthorized | The Authorization: Bearer … header is missing or malformed | Send Authorization: Bearer YOUR_API_KEY. Do not retry |
403 Forbidden | "Invalid API token" (the key matches no account), a refusal (plan, module, ownership, disabled account), an endpoint that does not exist, or a request sent to an address other than api-v3.sweeppea.com | Read Message. Do not retry as is |
404 Not Found | The record does not exist or does not belong to your account | Do not retry |
429 Too Many Requests | A rate limit: plan, firewall or platform-wide. Nothing was processed | Wait Retry-After seconds, then retry. Safe for writes too |
500 with "The API could not complete this request…" | The API was momentarily busy and did not process the request | Retry after a few seconds. Safe for writes too |
500 with any other Message | The endpoint itself failed while processing | Read Message. For a write, check whether it took effect before retrying |
502 / 503 / 504 | The request may or may not have been processed | Reads: retry with backoff. Writes: check whether it took effect before retrying |
Every error body has the same shape: { "Response": false, "Message": "…", "Code": … }.
Retrying Correctly
- Honour
Retry-Afterwhen it is present (every429). It is the exact wait. - Otherwise use exponential backoff with jitter: 1 s, 2 s, 4 s, 8 s (plus a random fraction), at most 4 attempts.
- Never retry a
400,401,403or404. They will fail the same way. - Retry writes only when nothing was processed (
429, or the500that says so). After a502/503/504on a write, read the record first.
/* Calls The Sweeppea API, Honouring Retry-After And Backing Off With Jitter */
const sleep = (_ms) => new Promise((_resolve) => setTimeout(_resolve, _ms));
const NOT_PROCESSED = /The API could not complete this request/;
async function sweeppeaCall(_path, _body, _apiKey, _maxAttempts = 4) {
for (let attempt = 1; attempt <= _maxAttempts; attempt++) {
const response = await fetch(`https://api-v3.sweeppea.com/${_path}`, {
method : 'POST',
headers : { 'Authorization' : `Bearer ${_apiKey}`, 'Content-Type' : 'application/json' },
body : JSON.stringify(_body)
});
const data = await response.json().catch(() => ({}));
/* Rate Limited: Wait Exactly What The API Says */
if (response.status === 429 && attempt < _maxAttempts) {
await sleep((Number(response.headers.get('Retry-After')) || 60) * 1000);
continue;
}
/* Busy, Not Processed: Safe To Retry, Even A Write */
if (response.status === 500 && NOT_PROCESSED.test(data.Message || '') && attempt < _maxAttempts) {
await sleep((2 ** attempt) * 1000 + Math.random() * 500);
continue;
}
return { status : response.status, data };
}
}import random
import time
import requests
NOT_PROCESSED = 'The API could not complete this request'
def sweeppea_call(path, body, api_key, max_attempts=4):
"""Calls the Sweeppea API, honouring Retry-After and backing off with jitter."""
for attempt in range(1, max_attempts + 1):
response = requests.post(
f'https://api-v3.sweeppea.com/{path}',
headers={'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json'},
json=body,
timeout=35,
)
try:
data = response.json()
except ValueError:
data = {}
# Rate limited: wait exactly what the API says
if response.status_code == 429 and attempt < max_attempts:
time.sleep(int(response.headers.get('Retry-After', 60)))
continue
# Busy, not processed: safe to retry, even a write
if response.status_code == 500 and NOT_PROCESSED in (data.get('Message') or '') and attempt < max_attempts:
time.sleep(2 ** attempt + random.random() / 2)
continue
return response.status_code, data
Pacing a Bulk Job
At 150 calls per minute you can make 2.5 calls per second. Pace your job a little under that and you will never be refused:
/* 2 Calls Per Second = 120 Per Minute, Comfortably Under A 150/min Plan */
const CALLS_PER_SECOND = 2;
for (const item of items) {
const startedAt = Date.now();
await sweeppeaCall('participants/add', item, apiKey);
await sleep(Math.max(0, (1000 / CALLS_PER_SECOND) - (Date.now() - startedAt)));
}
Read your plan's real rate from POST /account/plan (MaxApiCallsPerMinute) instead of hard-coding 150.
Best Practices
- Plan around your plan rate (
MaxApiCallsPerMinute, 150 by default). It is the only limit a well-behaved client meets. - Always honour
Retry-After. It is exact on the plan limit and safe on every other429. - Retry only what was not processed:
429, and the500that says "The API could not complete this request". Check a write before retrying anything else. - Keep about 5 requests in flight per key, and send
winners/draw,sweepstakes/createandsweepstakes/cloneone at a time. - Watch
Telemetryin every successful response:APICallsandMaxAPICallstell you how much of the monthly allowance is used. - Always call
https://api-v3.sweeppea.comand always sendAuthorization: Bearer YOUR_API_KEY. - Every API call is monitored and audited to prevent fraud and abuse. Sustained traffic far above your plan, or traffic designed to get around the limits, can lead to the API key being suspended.