Skip to content

Error Codes

API error responses include a JSON body with error (message) and optionally code (machine-readable). Use code for programmatic handling.

Error codes table

CodeHTTP StatusDescription
MISSING_AUTH401Missing or invalid Authorization header
INVALID_OR_EXPIRED_TOKEN401Invalid or expired token
EMAIL_NOT_VERIFIED403Email not verified; check your inbox for the confirmation link
RATE_LIMITED429Too many requests
FILE_TOO_LARGE413File too large
FILE_NOT_FOUND404File not found
NOT_FOUND404Resource not found
STORAGE_LIMIT_REACHED403Storage limit reached
FILE_COUNT_LIMIT_REACHED403File count limit reached
TRIAL_ENDED403Trial ended; upgrade or your files will be removed in 15 days
IMAGE_OPS_LIMIT_REACHED429Image operations limit reached for this period
ORIGIN_READS_LIMIT_REACHED429Origin reads limit reached for this period
SERVER_BUSY503Server busy; try again shortly
CONTENT_TYPE_NOT_ALLOWED400Content-Type not allowed for upload
CONTENT_VERIFICATION_FAILED400File content does not match declared type
INVALID_REQUEST400Invalid request

Response format

json
{
  "error": "Human-readable message",
  "statusCode": 400,
  "code": "MACHINE_READABLE_CODE"
}

Handling errors

javascript
const res = await fetch('https://api.atiru.io/files', { ... })
const data = await res.json()
if (!res.ok) {
  switch (data.code) {
    case 'MISSING_AUTH':
    case 'INVALID_OR_EXPIRED_TOKEN':
      // Re-authenticate
      break
    case 'RATE_LIMITED':
      const retryAfter = res.headers.get('Retry-After')
      await sleep(parseInt(retryAfter || '60') * 1000)
      // Retry
      break
    case 'FILE_TOO_LARGE':
      // Show size limit to user
      break
    default:
      console.error(data.error)
  }
}
python
res = requests.post(...)
if not res.ok:
    data = res.json()
    if data.get('code') == 'RATE_LIMITED':
        retry_after = int(res.headers.get('Retry-After', 60))
        time.sleep(retry_after)
        # Retry
    elif data.get('code') == 'FILE_TOO_LARGE':
        # Show size limit to user
        pass
    else:
        print(data.get('error'))