Introduction
The KnowledgeCheckr API provides a comprehensive set of endpoints for creating, managing, and interacting with knowledge checks, questions, and examinations. Built with Next.js and TypeScript, the API uses Zod for robust schema validation and Drizzle ORM for database operations.Base URL
All API requests are made to:Authentication
The KnowledgeCheckr API uses Better Auth for authentication. Most endpoints require authentication using session-based authentication.Authentication Methods
Login
Authenticate users with email and password:- Email must be a valid email address
- Password must be at least 8 characters long
- Callback URL is optional and defaults to
/
Signup
Register new users:- Name must be at least 1 character long
- Email must be a valid email address
- Password must be at least 8 characters long
Protected Endpoints
Most API endpoints require authentication and will return a401 Unauthorized error if accessed without valid credentials. The authentication is handled server-side using the requireAuthentication() function.
Request Format
All POST requests must include aContent-Type: application/json header and provide data in JSON format.
Response Format
API responses are returned in JSON format.Success Response
Error Response
Validation
All API endpoints use Zod schemas for request validation. Invalid requests will return a400 Bad Request response with detailed validation errors.
Common Validation Errors
- Invalid UUID: IDs must be valid UUIDs
- Required fields: Missing required fields will be rejected
- Type mismatch: Fields must match expected types
- Range constraints: Numeric values must fall within specified ranges
- Date validation: Dates must be valid and follow constraints (e.g., closeDate cannot be before openDate)
Rate Limiting
Rate limiting policies should be configured based on your deployment environment.
Error Codes
| Status Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid input or validation error |
401 | Unauthorized - Authentication required |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource does not exist |
500 | Internal Server Error |
API Versioning
The current API version can be checked at:Next Steps
Schemas
Learn about Zod validation schemas
Database Operations
Explore CRUD operations