API Documentation
This document provides an overview of the API endpoints available in the application, focusing on the Convex backend.Convex API Structure
Our Convex API is organized into several functional areas:- Auth: User authentication and authorization
- Messages: Message sending and retrieval
- Security: Security event logging and monitoring
- Users: User management
- Admin: Admin-specific functionality
Authentication
Authentication is handled through Convex’s authentication system. Most endpoints require authentication.User Authentication Flow
- User signs in with email/password or OAuth provider
- Authentication token is stored in the client
- Subsequent requests include the authentication token
- Token is validated on each request
Endpoints
Auth API
Messages API
Security API
Users API
Admin API
Data Models
User
Message
SecurityEvent
SystemMetrics
Working with Pagination
Many endpoints that return lists support pagination through thePaginationOpts parameter:
Error Handling
API errors follow a standard format:unauthorized: User is not authenticatedforbidden: User does not have permission to perform the actionnot_found: Requested resource was not foundvalidation_error: Request data failed validationinternal_error: Server encountered an unexpected error
Client Usage
React Hooks
React components can use the provided hooks to interact with the API:Astro Components
Astro components can fetch data during server-side rendering:Development
When developing new API endpoints:- Define your function in the appropriate file under
convex/ - Use the new function syntax with proper argument and return type validation
- Add proper error handling and validation
- Document the endpoint in this API documentation