Document Stack
Document Stack
Docs

API Response Codes Reference

Complete reference of all HTTP status codes returned by the Document Stack API.

Success Codes (2xx)

CodeStatusDescription
200OKRequest succeeded. Response body contains the requested data.
201CreatedResource was successfully created (e.g., new template, project).
204No ContentRequest succeeded but no response body (e.g., after deletion).

Client Error Codes (4xx)

CodeStatusDescriptionCommon Cause
400Bad RequestThe request body is invalid or missing required fields.Malformed JSON, missing required data fields
401UnauthorizedAuthentication failed or missing.Missing or invalid API key, expired session
403ForbiddenAuthenticated but not authorized for this action.Insufficient role permissions, wrong organization
404Not FoundThe requested resource does not exist.Wrong template ID, deleted project
409ConflictResource conflict.Duplicate name, concurrent modification
413Payload Too LargeRequest body exceeds the 5MB limit.Large data payload or embedded images
422Unprocessable EntityRequest is well-formed but contains semantic errors.Invalid field values, wrong data types
429Too Many RequestsRate limit exceeded.Too many requests in a short period

Server Error Codes (5xx)

CodeStatusDescriptionAction
500Internal Server ErrorAn unexpected error occurred.Retry the request; contact support if persistent
502Bad GatewayThe server received an invalid response from upstream.Wait and retry
503Service UnavailableThe service is temporarily unavailable.Wait and retry; check status page
504Gateway TimeoutThe request took too long to process.Reduce document complexity; use async generation

Response Format

All API responses follow a consistent JSON structure:

FieldTypeDescription
successbooleanWhether the request succeeded
dataobject | arrayResponse data (present on success)
errorstringError message (present on failure)

Error Details

Error responses include a descriptive message in the error field. Use this message for debugging — it tells you exactly what went wrong.

Rate Limit Headers

When you receive a 429 response, check these headers:

HeaderDescription
Retry-AfterSeconds to wait before retrying
X-RateLimit-LimitMaximum requests allowed per window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetTimestamp when the rate limit resets

Retry Guidelines

Status CodeRetry?Strategy
400, 401, 403, 404, 413, 422NoFix the request; these are client errors
409MaybeRetry after resolving the conflict
429YesWait for Retry-After period, then retry
500YesRetry with exponential backoff (max 3 attempts)
502, 503YesWait 5–30 seconds, then retry
504MaybeSimplify document or use async generation

Next Steps