Browse and search developers
REST API
Errors, pagination, idempotency and rate limits
The REST API error format and types, cursor pagination, Idempotency-Key retries, request ids and the per-key rate limit.
On this page
Errors
Every error has the same JSON shape and an HTTP status that matches it. Branch on error.type for the category and error.code for the specific reason; show error.message to people. Quote error.requestId (also in the X-Request-Id header) when you contact support.
{
"error": {
"type": "permission_error",
"code": "missing_scope",
"message": "This API key does not have the `forms:write` scope.",
"requestId": "req-3f9"
}
}| type | Status | When |
|---|---|---|
authentication_error | 401 | No key (missing_api_key), or the key is invalid, expired, revoked, or its creator left the workspace (invalid_api_key). |
permission_error | 403 | The key lacks the scope (missing_scope) or its creator lacks the workspace permission. |
invalid_request_error | 400 | Validation failed (validation_failed, with details listing each field), malformed JSON, or a bad cursor. |
not_found_error | 404 | The id does not exist in this key’s workspace, or the endpoint does not exist (unknown_endpoint). |
conflict_error | 409 | An Idempotency-Key was reused with a different request (idempotency_key_reused). |
plan_error | 402 | The action needs a higher plan, for example publishing a paid block. |
rate_limit_error | 429 | Too many requests for this key. Wait for Retry-After seconds. |
api_error | 500 | Something went wrong on FormitAI’s side. Retry with backoff. |
Pagination
List endpoints for forms and responses return { data, hasMore, nextCursor }, newest first. Pass nextCursor back as cursor to get the next page; stop when nextCursor is null. Cursors are opaque, so do not build or edit them. limit is 1–100 and defaults to 25. Webhook lists return every item in data without paging.
Idempotency
Endpoints that create something (POST /forms, POST /forms/{formId}/questions, POST /forms/{formId}/duplicate, POST /webhooks) accept an Idempotency-Key header of 8–128 letters, digits, _, -, : or .. If you send the same key with the same request again within 24 hours, you get the first response back, with an Idempotent-Replayed: true header, and nothing is created twice. Sending the same key with a different body or path returns a 409.
Rate limits
Each key can make 120 requests per minute. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (seconds until the window resets). Over the limit you get a 429 with a Retry-After header. Creating forms is also limited to two per second per organization, the same as in the app.
async function formitFetch(url, init, attempt = 0) {
const res = await fetch(url, init);
if ((res.status === 429 || res.status >= 500) && attempt < 4) {
const wait = Number(res.headers.get('Retry-After')) || 2 ** attempt;
await new Promise((r) => setTimeout(r, wait * 1000));
return formitFetch(url, init, attempt + 1);
}
return res;
}Related
Can't find what you need?