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": {
    "type": "invalid_request",
    "code": "TIER_LIMIT_EXCEEDED",
    "message": "You have exceeded your file size limit",
    "suggestion": "Upgrade your plan at app.uploadkit.dev/billing"
  }
}
FieldDescription
typeBroad category — invalid_request, authentication_error, rate_limit_error, api_error
codeMachine-readable error code — use this in your error handling logic
messageHuman-readable description of what went wrong
suggestionOptional — actionable fix (shown on tier-limit and auth errors)
detailsOptional — field-level validation errors on VALIDATION_ERROR

Validation errors include a details field with per-field messages:

{
  "error": {
    "type": "invalid_request",
    "code": "VALIDATION_ERROR",
    "message": "Invalid request body",
    "details": {
      "fileName": ["String must contain at least 1 character(s)"],
      "fileSize": ["Expected number, received string"]
    }
  }
}

Error Codes

Authentication

CodeHTTPDescriptionFix
UNAUTHORIZED401API key is missing, malformed, or has been revokedSend Authorization: Bearer <key>; create a new key if revoked

Request Validation

CodeHTTPDescriptionFix
VALIDATION_ERROR400Request body failed schema validation — see detailsCorrect the offending fields
INVALID_FILE_TYPE400MIME type not in the route's allowedTypesCheck the route config in the dashboard
FILE_TOO_SMALL_FOR_MULTIPART400fileSize is ≤ 10 MB on /upload/multipart/initUse /upload/request for files under 10 MB
DUPLICATE_SLUG409A file router with the requested slug already existsChoose a different slug

Resources

CodeHTTPDescriptionFix
NOT_FOUND404Requested resource (file, project, route, key) does not exist or belongs to another accountCheck the ID/key and that your API key targets the correct project

Upload Verification

CodeHTTPDescriptionFix
FILE_NOT_IN_STORAGE422R2 object not found when confirming — the client-side PUT may have failedRetry the upload from /upload/request

Quota and Billing

CodeHTTPDescriptionFix
TIER_LIMIT_EXCEEDED403File size, monthly uploads, storage, project, or API key limit reachedUpgrade your plan at app.uploadkit.dev/billing
RATE_LIMITED429Too many requests — 10/min general, 30/min on /upload/*Back off and retry; the SDK does this automatically

Server

CodeHTTPDescriptionFix
INTERNAL_ERROR500Unexpected server-side errorRetry with exponential backoff; report persistent issues at github.com/drumst0ck/uploadkit

Handling Errors in Code

const response = await fetch('https://api.uploadkit.dev/api/v1/upload/request', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${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 'VALIDATION_ERROR':
      throw new Error(`Invalid request: ${JSON.stringify(error.details)}`);
    case 'INVALID_FILE_TYPE':
      throw new Error('This file type is not supported.');
    case 'TIER_LIMIT_EXCEEDED':
      throw new Error('Quota reached — upgrade your plan.');
    case 'RATE_LIMITED':
      throw new Error('Too many requests. Try again shortly.');
    case 'UNAUTHORIZED':
      throw new Error('API key missing or invalid.');
    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. Retryable failures (429, 5xx) are automatically retried with exponential backoff up to maxRetries.

On this page