Skip to main content
The Bags API uses standardized error responses to help you handle issues in your applications.

Error Response Format

All errors return JSON with a consistent structure:
Success responses use a different format:

Common Status Codes

Error Examples

Validation Error (400)

Authentication Error (401)

Permission Error (403)

Rate Limit Error (429)

When you exceed rate limits, the API returns additional information:

File Upload Error (413)

Server Error (500)

SDK Error Handling

When using the Bags TypeScript SDK, errors are automatically handled and thrown as exceptions. The SDK wraps API responses and throws errors for failed requests:
The SDK automatically handles the success: false responses and throws errors, so you don’t need to manually check the success field. Successful responses return the data directly from the response field.

Best Practices

Error Handling in Code

Retry Logic

Implement exponential backoff for rate limit and server errors:
  1. 429 (Rate Limited): Wait based on resetTime or implement exponential backoff
  2. 500/502/503: Retry with exponential backoff (max 5 attempts)
  3. 400/401/403/404: Don’t retry - fix the request first
Check the X-RateLimit-* headers to proactively avoid rate limits rather than handling them reactively.