Skip to main content

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

HTTP Status Codes

Success Codes

Client Error Codes (4xx)

400 Bad Request

Invalid request data or validation errors. Common causes:
  • Missing required fields
  • Invalid data format
  • Validation failures
Example:
Example from Zod validation:

401 Unauthorized

Missing or invalid authentication. Common causes:
  • No session cookie
  • Expired session
  • Invalid credentials
Example:
From authentication middleware (server/localAuth.ts:573-581):

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
Example:
Premium-only feature (server/routes.ts:1484-1489):

404 Not Found

Requested resource doesn’t exist. Example:
Unknown API routes (server/index.ts:166-168):

429 Too Many Requests

Rate limit exceeded. Example (server/rateLimiter.ts:90-95):
With headers:

Server Error Codes (5xx)

500 Internal Server Error

Unexpected server error. Example (server/index.ts:187-193):
Common causes:
  • Database connection failures
  • Unhandled exceptions
  • External API failures

503 Service Unavailable

Service temporarily unavailable or not configured. Storage unreachable:
Feature not configured:

Error Codes Reference

Authentication Errors

Validation Errors

Resource Errors

Credit System Errors

Storage Errors

Rate Limit Errors

Validation Errors

Zod Validation

The API uses Zod for request validation. Validation errors include detailed information:
Example validation error:

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:
Response (401):
Solution: Include session cookie from login.

Invalid Session Data

Request:
Response (400):
Solution: Include required title field.

Accessing Non-Existent Resource

Request:
Response (404):
Solution: Verify session ID exists.

Rate Limit Exceeded

Request (6th login attempt in 15 minutes):
Response (429):
Solution: Wait 15 minutes or use rate limit headers to track usage.

Storage Service Down

Request:
Response (503):
Solution: Check Supabase service status and configuration.

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