Rate limits
Each API key can make 60 requests per minute. Over the limit, the requests are refused until the minute is over.
The limit
The requests are counted per key, over 60 seconds: the keys of a workspace each have their own limit. A request over the limit is refused with a 429 status, and the Retry-After header gives the number of seconds to wait before sending it again:
Response headers
HTTP/1.1 429 Too Many Requests
Retry-After: 23
Content-Type: application/json; charset=utf-8Response
{
"status": 429,
"name": "TooManyRequestsError",
"message": "Too many requests",
"code": "too_many_requests",
"data": { "retryAfter": 23, "scope": "api-key" }
}Handling the limit
Wait for the time given by Retry-After, then send the request again:
async function request(url, options = {}) {
const response = await fetch(url, {
...options,
headers: { ...options.headers, Authorization: `Bearer ${process.env.BACKMYFORM_API_KEY}` }
});
if (response.status === 429) {
const seconds = Number(response.headers.get('Retry-After') ?? 60);
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
return request(url, options);
}
return response;
}Retry after the limit
Making fewer requests
- To know when a submission arrives, use a webhook rather than reading the submissions again and again.
- Keep what you read: the forms and their fields change rarely.
- Give each tool its own key: a tool that makes many requests then doesn't slow the others down.
The submissions sent by your website to a form are not counted in this limit: they have their own limits, per visitor. See HTML forms.