API essentials

View Markdown

Errors and retries

JSON successes return { data, requestId, links }; collections put { items, nextCursor } inside data. All authenticated operations return 200 on success, including creation and deletion. File downloads return bytes. Success responses are streamed. Resolve stored asset paths such as /api/public/workspace-logo/... against links.app, and pass those stored paths back when saving templates. Published invoice pages use /i/{publicId} under links.invoices; links.api gives the versioned API base. These returned bases keep app, API and invoice domains separate without hardcoding hosts. Use X-Request-Id for support. Errors return { error: { code, message, fields? }, requestId }.

400 means malformed JSON; 401 means a missing/invalid/expired/revoked key; 403 means insufficient access; 404 means missing or inaccessible; 409 means a business-rule or retry conflict. 413 means a body/file limit; 415 means unsupported content; 422 means invalid fields or query parameters. A 503 indicates provider, storage or database unavailability. After an uncertain mutation response, retry with the same key and body.

Collections default to 50 records, with limit from 1–100 and after from nextCursor. Results use stable ID order. Restart if a cursor record is removed or no longer accessible. Unknown/repeated query parameters are rejected. Ordinary JSON bodies are limited to 1 MiB; base64 upload requests allow 4.25 MiB. Public uploads allow 3 MiB decoded so base64 requests fit Vercel’s request limit; image pipelines enforce their native image limits and normalization.