UploadKit
API Reference

Error Codes

Complete reference of UploadKit error codes, HTTP status codes, and troubleshooting suggestions.

Every error response from the UploadKit API has the same shape:

{
  "error": {
    "code": "FILE_TOO_LARGE",
    "message": "File size 6291456 bytes exceeds the 4194304 byte limit",
    "suggestion": "Upgrade your plan at app.uploadkit.dev/billing"
  }
}
FieldDescription
codeMachine-readable error code — use this in your error handling logic
messageHuman-readable description of what went wrong
suggestionOptional — actionable fix (shown to developers, not end users)

Error Codes

Authentication Errors

CodeHTTP StatusDescriptionFix
UNAUTHORIZED401API key is missing, malformed, or has been revokedCheck your x-api-key header; create a new key if revoked

Upload Errors

CodeHTTP StatusDescriptionFix
FILE_TOO_LARGE413File size exceeds the route's maxFileSize or your tier's limitReduce file size, increase route limit, or upgrade tier
FILE_TYPE_NOT_ALLOWED415MIME type not in the route's allowedTypes listCheck the route config in your dashboard
UPLOAD_NOT_FOUND404fileId does not exist or belongs to another projectVerify the fileId came from a /upload/request call on the same project
UPLOAD_NOT_VERIFIED422R2 object not found when confirming — the PUT upload may have failedRetry the upload from the beginning

Resource Errors

CodeHTTP StatusDescriptionFix
NOT_FOUND404The requested resource (file, project, route) does not existCheck the ID or key in the request

Quota and Billing Errors

CodeHTTP StatusDescriptionFix
TIER_LIMIT_EXCEEDED403Monthly upload count, storage, or project limit reachedUpgrade your plan at app.uploadkit.dev/billing
RATE_LIMITED429Too many requests within the sliding windowWait for the window to reset (see Retry-After header)

Server Errors

CodeHTTP StatusDescriptionFix
INTERNAL_SERVER_ERROR500Unexpected server-side errorRetry with exponential backoff; report persistent issues at github.com/uploadkit/uploadkit

Rate Limit Headers

When rate-limited (429), the response includes headers to guide your retry logic:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
Retry-After: 23

{
  "error": {
    "code": "RATE_LIMITED",
    "message": "Rate limit exceeded. Retry after 23 seconds"
  }
}
HeaderDescription
X-RateLimit-LimitMaximum requests per window
X-RateLimit-RemainingRequests remaining in the current window (0 when limited)
Retry-AfterSeconds until the sliding window resets

Handling Errors in Code

const response = await fetch('https://api.uploadkit.dev/api/v1/upload/request', {
  method: 'POST',
  headers: {
    'x-api-key': process.env.UPLOADKIT_API_KEY!,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ fileName, fileSize, contentType, routeSlug }),
});

if (!response.ok) {
  const { error } = await response.json();

  switch (error.code) {
    case 'FILE_TOO_LARGE':
      throw new Error('Please upload a smaller file.');
    case 'FILE_TYPE_NOT_ALLOWED':
      throw new Error('This file type is not supported.');
    case 'RATE_LIMITED':
      const retryAfter = response.headers.get('Retry-After');
      throw new Error(`Too many requests. Try again in ${retryAfter}s.`);
    case 'TIER_LIMIT_EXCEEDED':
      throw new Error('Upload quota reached. Upgrade your plan.');
    default:
      throw new Error(error.message);
  }
}

When using the @uploadkitdev/core or @uploadkitdev/react SDK, errors are surfaced via the onError callback with the same code values. You do not need to parse the HTTP response manually.

On this page