Account Zero REST API reference for developers integrating with the business management system.
http://localhost:3500/api
All API endpoints require authentication via NextAuth.js session cookies or API tokens.
{
"success": true,
"data": {},
"message": "Success message",
"error": null
}{
"success": false,
"data": null,
"message": "Error description",
"error": "ERROR_CODE"
}Login user with credentials.
Request:
{
"email": "user@example.com",
"password": "password"
}Get all customers with pagination.
Query Parameters:
page(number): Page number (default: 1)limit(number): Items per page (default: 10)search(string): Search term
Response:
{
"success": true,
"data": {
"customers": [...],
"total": 100,
"page": 1,
"totalPages": 10
}
}Create new customer.
Request:
{
"name": "Customer Name",
"email": "customer@example.com",
"phone": "+27123456789",
"address": "123 Main St",
"accountType": "CREDIT",
"creditLimit": 10000
}Get customer by ID with full details.
Update customer information.
Delete customer (soft delete).
Get all active products.
Query Parameters:
search(string): Search termcategory(string): Filter by categoryinStock(boolean): Filter by stock availability
Create new product.
Request:
{
"name": "Product Name",
"description": "Product description",
"price": 99.99,
"cost": 50.00,
"stockQuantity": 100,
"minimumStock": 10,
"category": "Electronics",
"barcode": "1234567890123"
}Update product information.
Get current inventory alerts.
Response:
{
"success": true,
"data": [
{
"id": "alert_id",
"productId": "product_id",
"productName": "Product Name",
"currentStock": 5,
"minimumStock": 10,
"severity": "WARNING",
"createdAt": "2025-01-01T00:00:00Z"
}
]
}Validate stock availability for products.
Request:
{
"items": [
{
"productId": "product_id",
"quantity": 5
}
]
}Adjust stock levels.
Request:
{
"productId": "product_id",
"adjustment": -5,
"reason": "Sale",
"reference": "INV-2025000001"
}Get all invoices with pagination.
Create new invoice.
Request:
{
"customerId": "customer_id",
"items": [
{
"productId": "product_id",
"quantity": 2,
"unitPrice": 99.99
}
],
"notes": "Invoice notes"
}Get invoice by ID.
Update invoice status.
Request:
{
"status": "PAID"
}Get all quotes.
Create new quote.
Convert quote to invoice.
Get calendar events.
Query Parameters:
start(string): Start date (ISO format)end(string): End date (ISO format)type(string): Event type filter
Create calendar event.
Request:
{
"title": "Event Title",
"description": "Event description",
"startDate": "2025-01-01T10:00:00Z",
"endDate": "2025-01-01T11:00:00Z",
"type": "MEETING",
"attendees": ["user1@example.com"]
}Get company settings.
Update company settings.
Request:
{
"name": "Company Name",
"address": "Company Address",
"phone": "+27123456789",
"email": "info@company.com",
"vatNumber": "4123456789",
"registrationNumber": "2021/123456/07"
}Get sales report.
Query Parameters:
startDate(string): Start dateendDate(string): End dategroupBy(string): Group by period (day, week, month)
Get inventory report.
Get customer report.
Get next document number.
Query Parameters:
type(string): Document type (INVOICE, QUOTE, CREDIT_NOTE, DELIVERY_NOTE)
WebSocket events via Socket.IO on port 5000:
join_room: Join user-specific roominventory_alert_dismissed: Dismiss inventory alert
inventory_alert: New inventory alertstock_updated: Stock level changeddocument_created: New document createdsystem_notification: System-wide notification
- 100 requests per minute per IP
- 1000 requests per hour per authenticated user
UNAUTHORIZED: Authentication requiredFORBIDDEN: Insufficient permissionsNOT_FOUND: Resource not foundVALIDATION_ERROR: Invalid request dataSTOCK_INSUFFICIENT: Not enough stock availableDUPLICATE_ENTRY: Resource already existsSERVER_ERROR: Internal server error
const response = await fetch('/api/customers', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'New Customer',
email: 'customer@example.com'
})
});
const result = await response.json();curl -X POST http://localhost:3500/api/customers \
-H "Content-Type: application/json" \
-d '{"name":"New Customer","email":"customer@example.com"}'Configure webhooks to receive real-time notifications:
invoice.createdinvoice.paidstock.lowcustomer.created
{
"event": "invoice.created",
"data": {...},
"timestamp": "2025-01-01T00:00:00Z"
}