Getting Started
Welcome to the Accounting System REST API. This guide will help you integrate with our platform quickly.
Base URL
All API requests are made to the following base URL. The {tenant} parameter is required for all authenticated endpoints.
https://your-domain.com/api/{tenant}/
Multi-Tenancy
This API uses path-based multitenancy. Every request must include the tenant identifier in the URL path.
Important
You must detect the tenant first using POST /api/detect-tenant before making authenticated requests.
# Examples:
GET /api/acme-corp/invoices
GET /api/acme-corp/products/42
POST /api/acme-corp/customers
Request Format
Headers
Content-Type: application/json
Accept: application/json
Authorization: Bearer {token}
Query Parameters
| page | Page number (default: 1) |
| per_page | Items per page (default: 15) |
| search | Search query string |
Response Format
Single Resource (200)
{
"id": 1,
"name": "Example Resource",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Collection (Paginated)
{
"data": [ ... ],
"links": {
"first": "...?page=1",
"last": "...?page=5",
"prev": null,
"next": "...?page=2"
},
"meta": {
"current_page": 1,
"last_page": 5,
"per_page": 15,
"total": 75
}
}
Error Handling
Validation Error (422)
{
"message": "The given data was invalid.",
"errors": {
"name": ["The name field is required."],
"email": ["The email must be valid."]
}
}
Unauthorized (401)
{
"message": "Unauthenticated."
}
HTTP Status Codes
| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 204 | No Content (successful delete) |
| 401 | Unauthenticated — invalid or missing token |
| 403 | Forbidden — insufficient permissions |
| 404 | Resource not found |
| 422 | Validation error |
| 500 | Server error |
Rate Limiting & Pagination
- Collection endpoints are paginated by default (15 items per page).
- Maximum 200 items per page for customer/supplier listings.
- Use
?page=N&per_page=Nto control pagination. - Use
?search=queryfor full-text search on supported endpoints.
Authentication
The API uses Laravel Sanctum for token-based authentication. All authenticated endpoints require a Bearer token in the Authorization header.
Authentication Flow
Detect Tenant
Send user's email to discover which tenant they belong to.
POST /api/detect-tenant
Login
Authenticate with email & password to receive a Bearer token.
POST /api/login
Make Requests
Use the token in all subsequent API requests.
Authorization: Bearer {token}
Detect Tenant
/api/detect-tenant
Public
Detects the tenant associated with a given email address. Call this before login to determine the correct tenant path.
Request
POST /api/detect-tenant
Content-Type: application/json
{
"email": "user@company.com"
}
Response (200)
{
"tenant_id": 1,
"domain": "acme-corp"
}
Login
/api/login
Public
Authenticates a user and returns a Sanctum bearer token for subsequent API calls.
Request
POST /api/login
Content-Type: application/json
{
"email": "user@company.com",
"password": "your-password"
}
Response (200)
{
"user": {
"id": 1,
"name": "John Doe",
"email": "user@company.com"
},
"token": "1|abc123xyz..."
}
Store the returned token securely. Include it in the Authorization header for all authenticated requests: Bearer 1|abc123xyz...
Forgot Password
/api/forgot-password
Public
POST /api/forgot-password
Content-Type: application/json
{
"email": "user@company.com"
}
// Response (200):
{
"message": "Password reset link sent."
}
Get Current User
/api/{tenant}/user
Authenticated
Returns the currently authenticated user object with permissions.
GET /api/acme-corp/user
Authorization: Bearer 1|abc123xyz...
// Response (200):
{
"id": 1,
"name": "John Doe",
"email": "user@company.com",
"created_at": "2024-01-15T10:30:00Z"
}
Get User Permissions
/api/{tenant}/user/permissions
Authenticated
Returns a list of permission names assigned to the current user.
// Response (200):
[
"view invoices",
"create invoices",
"edit invoices",
"delete invoices",
"view products",
"manage users"
]
Customers API
Manage customer records. Customers are linked to accounting via their assigned account.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/customers | List all customers (paginated) |
| POST | /api/{tenant}/customers | Create a new customer |
| GET | /api/{tenant}/customers/{id} | Get a single customer |
| PUT | /api/{tenant}/customers/{id} | Update a customer |
| DELETE | /api/{tenant}/customers/{id} | Delete a customer |
Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| name | string | required | max: 255 |
| string | optional | valid email format | |
| phone | string | optional | max: 255 |
| address | string | optional | max: 255 |
| account_id | integer | required | Must exist in accounts table |
| status_id | integer | optional | Must exist in statuses table |
| description | string | optional | max: 255 |
Create Customer
Request
POST /api/acme-corp/customers
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "ABC Trading Ltd",
"email": "info@abctrading.com",
"phone": "+254700123456",
"address": "123 Main Street, Nairobi",
"account_id": 15,
"status_id": 1,
"description": "Key wholesale customer"
}
Response (201)
{
"id": 12,
"name": "ABC Trading Ltd",
"email": "info@abctrading.com",
"phone": "+254700123456",
"address": "123 Main Street, Nairobi",
"account_id": 15,
"status_id": 1,
"description": "Key wholesale customer",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
List Customers
Supports search and pagination. Maximum 200 items per page.
GET /api/acme-corp/customers?search=ABC&page=1&per_page=25
Authorization: Bearer {token}
// Response (200):
{
"data": [
{
"id": 12,
"name": "ABC Trading Ltd",
"email": "info@abctrading.com",
"phone": "+254700123456",
...
}
],
"meta": {
"current_page": 1,
"last_page": 1,
"per_page": 25,
"total": 1
}
}
Suppliers API
Manage supplier records for purchasing. Suppliers are linked to accounts payable via their assigned account.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/suppliers | List all suppliers (paginated) |
| POST | /api/{tenant}/suppliers | Create a new supplier |
| GET | /api/{tenant}/suppliers/{id} | Get a single supplier |
| PUT | /api/{tenant}/suppliers/{id} | Update a supplier |
| DELETE | /api/{tenant}/suppliers/{id} | Delete a supplier |
Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| name | string | required | max: 255 |
| string | optional | valid email format | |
| phone | string | optional | max: 255 |
| address | string | optional | max: 255 |
| account_id | integer | required | Must exist in accounts table |
| status_id | integer | optional | Must exist in statuses table |
| description | string | optional | max: 255 |
Create Supplier — Example
Request
POST /api/acme-corp/suppliers
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "Global Parts Inc",
"email": "sales@globalparts.com",
"phone": "+254711222333",
"address": "456 Industrial Ave",
"account_id": 22,
"status_id": 1,
"description": "Primary parts supplier"
}
Response (201)
{
"id": 8,
"name": "Global Parts Inc",
"email": "sales@globalparts.com",
"phone": "+254711222333",
"address": "456 Industrial Ave",
"account_id": 22,
"status_id": 1,
"description": "Primary parts supplier",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Products API
Manage product catalog, categories, units, and barcode lookups.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/products | List all products (paginated) |
| POST | /api/{tenant}/products | Create a new product |
| GET | /api/{tenant}/products/{id} | Get a single product |
| PUT | /api/{tenant}/products/{id} | Update a product |
| DELETE | /api/{tenant}/products/{id} | Delete a product |
| GET | /api/{tenant}/products/by-code/{code} | Get product by barcode |
Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| name | string | required | max: 255 |
| barcode | string | required | Unique product identifier / SKU |
| description | string | required | Product description |
| selling_price | numeric | optional | Selling price per unit |
| buying_price | numeric | optional | Purchase/cost price per unit |
| discount | numeric | optional | Default discount amount |
| status_id | integer | required | Must exist in statuses |
| category_id | integer | optional | Must exist in categories |
| unit_id | integer | optional | Must exist in units |
| account_id | integer | optional | Revenue account |
| inventory_account_id | integer | optional | Inventory asset account |
| vat_applied | boolean | optional | Whether VAT applies to this product |
| sell_type | string | optional | Sale classification type |
Create Product — Example
Request
POST /api/acme-corp/products
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "Office Chair",
"barcode": "SKU-12345",
"description": "Ergonomic office chair",
"buying_price": 150.00,
"selling_price": 250.00,
"unit_id": 1,
"status_id": 1,
"category_id": 3,
"discount": 10.00,
"vat_applied": true
}
Response (201)
{
"id": 23,
"name": "Office Chair",
"barcode": "SKU-12345",
"description": "Ergonomic office chair",
"buying_price": 150.00,
"selling_price": 250.00,
"unit_id": 1,
"status_id": 1,
"category_id": 3,
"discount": 10.00,
"vat_applied": true,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Categories & Units
Categories
| GET | /api/{tenant}/categories |
| POST | /api/{tenant}/categories |
| GET | /api/{tenant}/categories/{id} |
| PUT | /api/{tenant}/categories/{id} |
| DEL | /api/{tenant}/categories/{id} |
Also: GET /api/{tenant}/categories/{id}/products
Units
| GET | /api/{tenant}/units |
| POST | /api/{tenant}/units |
| GET | /api/{tenant}/units/{id} |
| PUT | /api/{tenant}/units/{id} |
| DEL | /api/{tenant}/units/{id} |
Barcode Lookup
GET /api/acme-corp/products/by-code/SKU-12345
Authorization: Bearer {token}
// Response (200):
{
"id": 23,
"name": "Office Chair",
"barcode": "SKU-12345",
"selling_price": 250.00,
"buying_price": 150.00,
...
}
Invoices API
Manage sales invoices. Creating an invoice auto-generates journal entries for Accounts Receivable, Revenue, and VAT.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/invoices | List all invoices (paginated) |
| POST | /api/{tenant}/invoices | Create a new invoice |
| GET | /api/{tenant}/invoices/{id} | Get invoice with full details |
| PUT | /api/{tenant}/invoices/{id} | Update an invoice |
| DELETE | /api/{tenant}/invoices/{id} | Delete an invoice |
| POST | /api/{tenant}/approvals/invoices/{id}/approve | Approve an invoice |
Validation Rules
| Field | Type | Required | Description |
|---|---|---|---|
| customer_id | integer | optional | Linked customer ID |
| customer_name | string | optional | Customer display name |
| date_from | date | optional | Invoice start date |
| date_to | date | optional | Invoice end / due date |
| sub_total | numeric | optional | Subtotal before tax & discount |
| discount | numeric | optional | Discount amount |
| vat | numeric | optional | VAT / tax amount |
| amount_total | numeric | optional | Total invoice amount |
| amount_paid | numeric | optional | Amount already paid |
| description | string | optional | max: 255 |
Create Invoice — Example
Request
POST /api/acme-corp/invoices
Authorization: Bearer {token}
Content-Type: application/json
{
"customer_id": 5,
"customer_name": "ABC Trading Ltd",
"date_from": "2024-01-01",
"date_to": "2024-01-31",
"sub_total": 1250.00,
"discount": 100.00,
"vat": 150.00,
"amount_total": 1300.00,
"amount_paid": 500.00,
"description": "Monthly sales invoice"
}
Response (201)
{
"id": 42,
"customer_id": 5,
"customer_name": "ABC Trading Ltd",
"date_from": "2024-01-01",
"date_to": "2024-01-31",
"sub_total": 1250.00,
"discount": 100.00,
"vat": 150.00,
"amount_total": 1300.00,
"amount_paid": 500.00,
"balance": 800.00,
"status": "pending",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Automatic Journal Entries
When an invoice is created and approved, the system automatically generates the following journal entries via the GL Integration Service.
| Account | Debit | Credit |
|---|---|---|
| Accounts Receivable (AR) | amount_total | — |
| Sales Revenue | — | sub_total |
| VAT Payable | — | vat |
Additionally, if inventory items are included, a COGS entry is created: Debit COGS / Credit Inventory.
Approve Invoice
POST /api/acme-corp/approvals/invoices/42/approve
Authorization: Bearer {token}
// Response (200):
{
"message": "Invoice approved successfully."
}
Inventory API
Manage stock records including purchases, adjustments, transfers, and expiry tracking.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/stocks | List all stock records (paginated) |
| POST | /api/{tenant}/stocks | Create a new stock entry |
| GET | /api/{tenant}/stocks/{id} | Get stock details |
| PUT | /api/{tenant}/stocks/{id} | Update a stock record |
| DELETE | /api/{tenant}/stocks/{id} | Delete a stock record |
Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| product_id | integer | required | Must exist in products table |
| quantity | numeric | required | min: 0 |
| unit_id | integer | optional | Must exist in units table |
| supplier_id | integer | optional | Must exist in suppliers table |
| warehouse_id | integer | optional | Must exist in warehouses table |
| branch_id | integer | optional | Must exist in branches table |
| buying_price | numeric | optional | min: 0 |
| selling_price | numeric | optional | min: 0 |
| discount | numeric | optional | min: 0 |
| vat | numeric | optional | min: 0 |
| expires_at | date | optional | Must be a future date |
| description | string | optional | max: 1000 |
| location | string | optional | max: 255, shelf/bin location |
Stock Types
Each stock record has a type that classifies the movement:
Create Stock Entry
Request
POST /api/acme-corp/stocks
Authorization: Bearer {token}
Content-Type: application/json
{
"product_id": 23,
"quantity": 100,
"unit_id": 1,
"supplier_id": 5,
"warehouse_id": 2,
"buying_price": 150.00,
"selling_price": 250.00,
"expires_at": "2026-12-31",
"description": "Q1 bulk purchase",
"location": "Shelf A-12"
}
Response (201)
{
"id": 45,
"product_id": 23,
"quantity": 100,
"balance": 100,
"unit_id": 1,
"supplier_id": 5,
"warehouse_id": 2,
"buying_price": 150.00,
"selling_price": 250.00,
"expires_at": "2026-12-31",
"description": "Q1 bulk purchase",
"location": "Shelf A-12",
"type": "STOCK_PURCHASE",
"status_id": 1,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
List Stock Records
Supports search and pagination. Maximum 200 items per page.
GET /api/acme-corp/stocks?search=Office+Chair&page=1&per_page=25
Authorization: Bearer {token}
// Response (200):
{
"data": [
{
"id": 45,
"product_id": 23,
"quantity": 100,
"balance": 100,
"warehouse_id": 2,
"type": "STOCK_PURCHASE",
...
}
],
"meta": {
"current_page": 1,
"last_page": 3,
"per_page": 25,
"total": 68
}
}
Approvals API
Retrieve pending approval items and approve or reject invoices, credit notes, purchase orders, and stock adjustments.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/approvals | List all pending approvals |
| POST | /api/{tenant}/approvals/invoices/{id}/approve | Approve an invoice |
| POST | /api/{tenant}/approvals/invoice-returns/{id}/approve | Approve a credit note |
| POST | /api/{tenant}/approvals/orders/{id}/approve | Approve a purchase order |
| POST | /api/{tenant}/approvals/stock-adjustments/{id}/items/{item}/approve | Approve a stock adjustment item |
Approval Types
Each approval item includes a type field indicating the document category:
| Type | Description |
|---|---|
| invoice | Sales invoices pending approval |
| invoice_return | Credit notes / invoice returns pending approval |
| order | Purchase orders (typically over a threshold amount) |
| stock_adjustment | Stock adjustment items requiring approval |
| adjustment_request | General adjustment requests |
| transfer | Stock transfers between warehouses |
List Pending Approvals
Returns all pending approvals filtered by the authenticated user's permissions.
GET /api/acme-corp/approvals
Authorization: Bearer {token}
// Response (200):
{
"success": true,
"data": [
{
"id": 34,
"type": "invoice",
"reference": "INV-2024-0034",
"title": "Sales Invoice #34",
"description": "Invoice for ABC Trading Ltd",
"amount": 15000.00,
"created_at": "2024-01-15T10:30:00Z",
"status_id": 2,
"created_by": "John Doe",
"approval_url": "/api/acme-corp/approvals/invoices/34/approve",
"rejection_url": "/api/acme-corp/approvals/invoices/34/reject"
},
{
"id": 12,
"type": "order",
"reference": "PO-2024-0012",
"title": "Purchase Order #12",
"description": "Office supplies from XYZ Suppliers",
"amount": 5200.00,
"created_at": "2024-01-14T09:15:00Z",
"status_id": 2,
"created_by": "Jane Smith",
"approval_url": "/api/acme-corp/approvals/orders/12/approve",
"rejection_url": "/api/acme-corp/approvals/orders/12/reject"
}
]
}
Approve an Invoice
Request
POST /api/acme-corp/approvals/invoices/34/approve
Authorization: Bearer {token}
Content-Type: application/json
Response (200)
{
"success": true,
"message": "Invoice approved successfully",
"data": {
"id": 34,
"status_id": 1,
"approved_by": 5,
"approved_at": "2024-01-15T11:00:00Z"
}
}
Users & Roles API
Manage users, roles, and permissions. Assign roles to users and permissions to roles for access control.
User Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/users | List all users (paginated) |
| POST | /api/{tenant}/users | Create a new user |
| GET | /api/{tenant}/users/{id} | Get user details |
| PUT | /api/{tenant}/users/{id} | Update a user |
| DELETE | /api/{tenant}/users/{id} | Delete a user |
| GET | /api/{tenant}/user/permissions | Get current user's permissions |
Role & Permission Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/roles | List all roles (paginated) |
| POST | /api/{tenant}/roles | Create a new role |
| GET | /api/{tenant}/roles/{id} | Get role details with permissions |
| PUT | /api/{tenant}/roles/{id} | Update a role |
| DELETE | /api/{tenant}/roles/{id} | Delete a role |
| GET | /api/{tenant}/permissions | List all permissions |
| POST | /api/{tenant}/permissions | Create a permission |
| PUT | /api/{tenant}/permissions/{id} | Update a permission |
| DELETE | /api/{tenant}/permissions/{id} | Delete a permission |
User Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| name | string | required | max: 255 |
| string | required | Valid email, unique per tenant | |
| phone | string | optional | max: 255 |
| password | string | optional | Stored hashed; required on create |
| status_id | integer | optional | Must exist in statuses table |
| branch_id | integer | optional | Must exist in branches table |
| warehouse_id | integer | optional | Must exist in warehouses table |
| roles | array | optional | Array of role IDs to assign |
| warehouses | array | optional | Array of warehouse IDs (many-to-many) |
Role Validation Rules
| Field | Type | Required | Rules |
|---|---|---|---|
| name | string | required | max: 32, unique |
| permissions | array | optional | Array of permission IDs |
Create User
Request
POST /api/acme-corp/users
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "Jane Smith",
"email": "jane@acme-corp.com",
"phone": "+254700987654",
"password": "securePassword123",
"branch_id": 1,
"warehouse_id": 2,
"roles": [1, 3],
"warehouses": [2, 5]
}
Response (201)
{
"id": 8,
"name": "Jane Smith",
"email": "jane@acme-corp.com",
"phone": "+254700987654",
"branch_id": 1,
"warehouse_id": 2,
"status_id": 1,
"roles": [
{ "id": 1, "name": "admin" },
{ "id": 3, "name": "manager" }
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Create Role
Request
POST /api/acme-corp/roles
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "warehouse-manager",
"permissions": [10, 11, 12, 15, 20]
}
Response (201)
{
"id": 5,
"name": "warehouse-manager",
"permissions": [
{ "id": 10, "name": "view-stock" },
{ "id": 11, "name": "create-stock" },
{ "id": 12, "name": "edit-stock" },
{ "id": 15, "name": "view-warehouse" },
{ "id": 20, "name": "approve-transfer" }
],
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
List Users
Supports search and pagination. Maximum 200 items per page.
GET /api/acme-corp/users?search=jane&page=1&per_page=25
Authorization: Bearer {token}
// Response (200):
{
"data": [
{
"id": 8,
"name": "Jane Smith",
"email": "jane@acme-corp.com",
"phone": "+254700987654",
"branch_id": 1,
"roles": [
{ "id": 1, "name": "admin" }
],
...
}
],
"meta": {
"current_page": 1,
"last_page": 1,
"per_page": 25,
"total": 1
}
}
Settings API
Manage tenant-level configuration including company details, currencies, tax types, and email settings.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/currencies | List all currencies |
| POST | /api/{tenant}/currencies | Create a currency |
| GET | /api/{tenant}/currencies/{id} | Get currency details |
| PUT | /api/{tenant}/currencies/{id} | Update a currency |
| DELETE | /api/{tenant}/currencies/{id} | Delete a currency |
| GET | /api/{tenant}/tax-types | List all tax types |
| POST | /api/{tenant}/tax-types | Create a tax type |
| PUT | /api/{tenant}/tax-types/{id} | Update a tax type |
| DELETE | /api/{tenant}/tax-types/{id} | Delete a tax type |
| GET | /api/{tenant}/tax-brackets | List tax brackets |
| POST | /api/{tenant}/tax-brackets | Create a tax bracket |
| PUT | /api/{tenant}/tax-brackets/{id} | Update a tax bracket |
| DELETE | /api/{tenant}/tax-brackets/{id} | Delete a tax bracket |
Currency — Create Example
Request
POST /api/acme-corp/currencies
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "US Dollar",
"code": "USD",
"symbol": "$",
"exchange_rate": 1.00,
"is_default": false
}
Response (201)
{
"id": 3,
"name": "US Dollar",
"code": "USD",
"symbol": "$",
"exchange_rate": 1.00,
"is_default": false,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
Tax Type — Create Example
Request
POST /api/acme-corp/tax-types
Authorization: Bearer {token}
Content-Type: application/json
{
"name": "VAT",
"rate": 16.5,
"description": "Value Added Tax"
}
Response (201)
{
"id": 2,
"name": "VAT",
"rate": 16.5,
"description": "Value Added Tax",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
List Currencies
Returns all configured currencies for the tenant.
GET /api/acme-corp/currencies
Authorization: Bearer {token}
// Response (200):
{
"data": [
{
"id": 1,
"name": "Malawi Kwacha",
"code": "MWK",
"symbol": "MK",
"exchange_rate": 1.00,
"is_default": true
},
{
"id": 3,
"name": "US Dollar",
"code": "USD",
"symbol": "$",
"exchange_rate": 0.00058,
"is_default": false
}
],
"meta": {
"current_page": 1,
"last_page": 1,
"per_page": 25,
"total": 2
}
}
Dashboard API
Retrieve aggregated financial statistics for the tenant dashboard, including revenue, expenses, cash position, and recent activity.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/{tenant}/dashboard | Get dashboard statistics |
Response Fields
| Field | Type | Description |
|---|---|---|
| totalRevenue | numeric | Sum of all revenue account balances |
| totalExpenses | numeric | Sum of all expense account balances |
| netIncome | numeric | totalRevenue − totalExpenses |
| cash | numeric | Cash & bank accounts (code 11xx) |
| accountsReceivable | numeric | Accounts receivable balance (code 12xx) |
| accountsPayable | numeric | Accounts payable balance (code 21xx) |
| inventory | numeric | Inventory asset value (code 13xx) |
| recentInvoices | array | Last 5 invoices with customer and amount |
How Calculations Work
- Revenue — Aggregated from GL accounts classified as revenue.
- Expenses — Aggregated from GL accounts classified as expense.
- Cash — Sum of accounts with code prefix
11*(Cash & Bank). - Accounts Receivable — Sum of accounts with code prefix
12*. - Accounts Payable — Sum of accounts with code prefix
21*. - Inventory — Sum of accounts with code prefix
13*.
Get Dashboard
Request
GET /api/acme-corp/dashboard
Authorization: Bearer {token}
Response (200)
{
"totalRevenue": 1250000.00,
"totalExpenses": 870000.00,
"netIncome": 380000.00,
"cash": 425000.00,
"accountsReceivable": 312000.00,
"accountsPayable": 198000.00,
"inventory": 567000.00,
"recentInvoices": [
{
"id": 102,
"customer_name": "ABC Trading Ltd",
"amount_total": 15000.00,
"created_at": "2024-01-15T10:30:00Z"
},
{
"id": 101,
"customer_name": "XYZ Corp",
"amount_total": 8500.00,
"created_at": "2024-01-14T14:20:00Z"
}
]
}