Error Response Format
When a request fails, the API returns a JSON object with anerror key. The value is either a single string or an array of strings describing what went wrong.
Single error:
HTTP Status Codes
Error Examples by Status Code
400 Bad Request
401 Unauthorized
403 Forbidden
Standard permission error:404 Not Found
422 Unprocessable Entity
429 Too Many Requests
500 Internal Server Error
Rate Limits
The DocuTrust API enforces rate limits to ensure fair usage and platform stability.
When you exceed the limit, the API returns a
429 Too Many Requests response. The Retry-After header tells you how many seconds to wait before retrying.
Rate Limit Headers
Every API response includes rate limit headers so you can track your usage proactively:Plan Limits
Some API actions are restricted by your account’s subscription plan. When you exceed a plan limit, the API returns a403 Forbidden response that includes an upgrade_url field pointing to your billing page:
- Monthly submission count
- Number of templates
- Number of API tokens
- Number of team members
- File storage capacity
Best Practices
Exponential Backoff
When you receive a429 or 5xx response, implement exponential backoff with jitter to avoid thundering herd problems:
Idempotency
Create and send operations accept anIdempotency-Key header to prevent duplicate requests on retry.
Keys expire after 24 hours. Keys are bound to the calling token — a different token cannot replay another’s cached response.
Error Handling Checklist
Always check the HTTP status code
Always check the HTTP status code
Do not assume every response is successful. Check the status code before parsing the response body as a success payload.
Parse both error formats
Parse both error formats
The
error field may be a string or an array of strings. Handle both cases in your error handling logic.Log the X-Request-Id header
Log the X-Request-Id header
Every API response includes an
X-Request-Id header. Log this value so you can reference it when contacting support about 500 errors.Respect Retry-After headers
Respect Retry-After headers
When rate-limited, always wait at least as long as the
Retry-After header specifies. Ignoring this header will extend your rate limit window.Do not retry 400, 401, 403, or 404 errors
Do not retry 400, 401, 403, or 404 errors
These errors indicate a problem with the request itself. Retrying the same request will produce the same error. Fix the request parameters before retrying.
Surface upgrade_url to end users
Surface upgrade_url to end users
When you receive a
403 with an upgrade_url, display a clear message to the user explaining the plan limit and providing a link to upgrade.