API Routes
Velocity includes API routes for form handling.
Available Endpoints
Section titled “Available Endpoints”| Endpoint | Method | Purpose |
|---|---|---|
/api/contact | POST | Contact form submission |
/api/newsletter | POST | Newsletter subscription |
Request Format
Section titled “Request Format”All endpoints accept FormData:
const formData = new FormData(form);const response = await fetch('/api/contact', { method: 'POST', body: formData,});const result = await response.json();Response Format
Section titled “Response Format”Success
Section titled “Success”{ "success": true}Validation Error
Section titled “Validation Error”{ "success": false, "errors": { "email": ["Please enter a valid email address"], "message": ["Message must be at least 10 characters"] }}Next Steps
Section titled “Next Steps”- Contact API — Contact form endpoint
- Newsletter API — Newsletter subscription endpoint