Overview
The JOIP API uses standard HTTP status codes and returns consistent JSON error responses to help you handle errors gracefully.Error Response Format
All error responses follow a consistent structure:Response Fields
| Field | Type | Description |
|---|---|---|
error | string | Error category or type |
message | string | Human-readable error message |
code | string | Machine-readable error code (optional) |
details | object | Additional context (optional) |
HTTP Status Codes
Success Codes
| Code | Description | Usage |
|---|---|---|
200 | OK | Successful GET, PATCH, DELETE |
201 | Created | Successful POST creating resource |
302 | Found | Redirect after login/logout |
Client Error Codes (4xx)
400 Bad Request
Invalid request data or validation errors. Common causes:- Missing required fields
- Invalid data format
- Validation failures
401 Unauthorized
Missing or invalid authentication. Common causes:- No session cookie
- Expired session
- Invalid credentials
402 Payment Required
Insufficient credits for feature access. Example (server/routes.ts:1472-1479):403 Forbidden
Authenticated but lacking permissions. Common causes:- Non-admin accessing admin endpoints
- Accessing another user’s private resources
- Feature restricted to premium users
404 Not Found
Requested resource doesn’t exist. Example:429 Too Many Requests
Rate limit exceeded. Example (server/rateLimiter.ts:90-95):Server Error Codes (5xx)
500 Internal Server Error
Unexpected server error. Example (server/index.ts:187-193):- Database connection failures
- Unhandled exceptions
- External API failures
503 Service Unavailable
Service temporarily unavailable or not configured. Storage unreachable:Error Codes Reference
Authentication Errors
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Missing or invalid authentication |
FORBIDDEN | 403 | Insufficient permissions |
Validation Errors
| Code | Status | Description |
|---|---|---|
VALIDATION_ERROR | 400 | Input validation failed |
INVALID_INPUT | 400 | Invalid data format |
MISSING_FIELD | 400 | Required field missing |
Resource Errors
| Code | Status | Description |
|---|---|---|
NOT_FOUND | 404 | Resource doesn’t exist |
ALREADY_EXISTS | 400 | Resource already exists |
RESOURCE_DELETED | 404 | Resource has been deleted |
Credit System Errors
| Code | Status | Description |
|---|---|---|
INSUFFICIENT_CREDITS | 402 | Not enough credits |
PREMIUM_ONLY | 403 | Feature requires premium |
FEATURE_PRICING_MISSING | 503 | Feature pricing not configured |
Storage Errors
| Code | Status | Description |
|---|---|---|
STORAGE_CONFIG_ERROR | 503 | Storage not configured |
STORAGE_UNREACHABLE | 503 | Cannot connect to storage |
STORAGE_PREFLIGHT_FAILED | 503 | Storage health check failed |
UPLOAD_FAILED | 500 | File upload failed |
Rate Limit Errors
| Code | Status | Description |
|---|---|---|
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
Validation Errors
Zod Validation
The API uses Zod for request validation. Validation errors include detailed information:Input Sanitization
User inputs are sanitized before validation:Error Handling Examples
JavaScript/TypeScript
Python
cURL with Error Handling
Common Error Scenarios
Creating Session Without Authentication
Request:Invalid Session Data
Request:title field.
Accessing Non-Existent Resource
Request:Rate Limit Exceeded
Request (6th login attempt in 15 minutes):Storage Service Down
Request:Error Logging
All errors are logged server-side:Best Practices
1. Always Check Response Status
2. Handle Rate Limits Gracefully
3. Provide User-Friendly Messages
4. Implement Retry Logic
5. Log Errors for Debugging
Next Steps
- API Introduction - Overview of available endpoints
- Authentication - Handle authentication errors
- Rate Limiting - Avoid rate limit errors