DokuBrain

Error Codes

API error codes, HTTP status codes, and error handling.

Error Codes

All API errors follow a consistent format:

{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error description",
    "details": {}
  }
}

HTTP status codes

StatusMeaning
200Success
201Created
204No content (successful deletion)
400Bad request — invalid input
401Unauthorized — missing or invalid auth
403Forbidden — insufficient permissions
404Not found
409Conflict — resource already exists
413Payload too large — file exceeds size limit
422Unprocessable entity — validation failed
429Too many requests — rate limited
500Internal server error

Error codes

CodeHTTP StatusDescription
UNAUTHORIZED401Missing or invalid authentication
FORBIDDEN403Insufficient permissions for this action
NOT_FOUND404Resource not found
VALIDATION_ERROR400/422Request body failed validation
DUPLICATE_ENTRY409Resource with this identifier already exists
FILE_TOO_LARGE413Uploaded file exceeds maximum size
UNSUPPORTED_FILE_TYPE400File type is not supported
RATE_LIMITED429Too many requests — check Retry-After header
PROCESSING_FAILED500Document processing failed
QUOTA_EXCEEDED403Monthly document quota exceeded
INTERNAL_ERROR500Unexpected server error

Handling errors

Error handling example
const response = await fetch('https://api.dokubrain.com/api/v1/documents', {
  headers: { Authorization: `Bearer ${apiKey}` },
});
 
if (!response.ok) {
  const { error } = await response.json();
 
  switch (error.code) {
    case 'UNAUTHORIZED':
      // Re-authenticate or refresh token
      break;
    case 'RATE_LIMITED':
      // Wait and retry
      const retryAfter = response.headers.get('Retry-After');
      break;
    case 'QUOTA_EXCEEDED':
      // Upgrade plan
      break;
    default:
      console.error(`API error: ${error.message}`);
  }
}

Rate limit headers

Rate-limited responses include these headers:

HeaderDescription
X-RateLimit-LimitMax requests per window
X-RateLimit-RemainingRemaining requests in current window
X-RateLimit-ResetUnix timestamp when the window resets
Retry-AfterSeconds to wait before retrying

On this page