Overview
The Catafract API provides endpoints for image generation, file uploads, project management, authentication, and payment processing. All API endpoints require authentication unless otherwise specified.Base URL
Authentication
All API endpoints use NextAuth.js for authentication with Google OAuth. Requests must include a valid session cookie obtained through the authentication flow.Authentication Flow
- User visits
/login - Clicks “Sign in with Google”
- NextAuth redirects to Google OAuth
- Google redirects back to
/api/auth/callback/google - Session cookie is set automatically
Protected Routes
The following routes require authentication:/api/image- AI image generation/api/upload- File uploads/api/user- User data/api/user/project- Project management/api/user/project/canvas- Canvas state management/api/checkout- Payment checkout/api/portal- Customer portal
Rate Limits
Currently, there are no explicit rate limits implemented. However, AI image generation is limited by:- Gemini API quotas
- Azure Blob Storage limits
- Session-based authentication
Error Responses
All endpoints return standard HTTP status codes:Success Codes
200- Success201- Created
Client Error Codes
400- Bad Request (missing or invalid parameters)401- Unauthorized (no valid session)404- Not Found
Server Error Codes
500- Internal Server Error
Endpoints Overview
Image Generation
POST /api/image- Generate AI images using Gemini
File Management
POST /api/upload- Upload images to Azure Blob Storage
User Management
GET /api/user- Get current user data
Project Management
POST /api/user/project- Create a new projectGET /api/user/project- Get user’s projects
Canvas Management
POST /api/user/project/canvas- Save canvas stateGET /api/user/project/canvas- Load canvas state
Authentication
GET/POST /api/auth/[...nextauth]- NextAuth.js endpoints
Payments (Polar)
GET /api/checkout- Create checkout sessionGET /api/portal- Access customer portalPOST /api/webhook/polar- Handle Polar webhooks
Video (Mux)
GET /api/mux/asset- Get Mux asset status
SDK and Tools
Currently, Catafract does not provide an official SDK. All endpoints can be accessed using standard HTTP clients like:fetch(JavaScript/TypeScript)axioscurl- Any HTTP client library