Skip to main content
When a request fails, the DocInject API always returns a JSON body with a single detail field describing what went wrong. Your integration should read this field to surface actionable error messages.

Error response format

Every error response follows this shape:
The detail value is a human-readable string. It changes with each error type, so treat it as display text rather than a stable key to match programmatically.

HTTP status codes

403 vs 404: DocInject returns 404, not 403, for resources that exist but your token doesn’t have access to. This prevents your integration from inferring whether a resource exists at all, which avoids leaking information across organization boundaries.

Handling errors in your integration

Check res.ok after every request and parse the detail field from the response body:

Common error scenarios

You’ll receive a 401 when:
  • The Authorization header is absent
  • The header is present but not in Bearer <token> format
  • The token has been deleted or is otherwise invalid
Fix: verify your API key is correct and that you’re setting the Authorization header on the request.
You’ll receive a 403 when your token is valid but the action requires a role you don’t have. For example, only organization admins can invite members, change member roles, or view documents owned by other members.Fix: check that the API key belongs to a user with the required role, or contact your organization admin.
You’ll receive a 400 when the request body is malformed or a required field is missing. The detail field will describe what’s wrong, for example, "count must be 1–100".Fix: validate your request payload against the endpoint’s required fields before sending.
A 500 indicates an unexpected error on DocInject’s side. These are rare and usually transient.Fix: retry the request with exponential backoff. If the error persists, contact DocInject support with the request details and timestamp.
Do not rely on the detail string value as a stable error code. Use the HTTP status code to branch your error handling logic.