Skip to content

API Reference

Acumen ERP provides a comprehensive REST API built with FastAPI, offering 2016+ endpoints across 9 business domains.

API Overview

Base URLs

Environment FastAPI Django Frontend
Development http://localhost:8001 http://localhost:8000 http://localhost:3000
Production https://api.acumen.restrat.co.za https://auth.acumen.restrat.co.za https://acumen.restrat.co.za

Interactive Documentation

FastAPI provides automatic interactive API documentation:

  • Swagger UI : http://localhost:8001/docs
  • ReDoc : http://localhost:8001/redoc
  • OpenAPI Schema : http://localhost:8001/openapi.json

Authentication

All API requests require authentication using JWT tokens.

Login

POST /api/auth/login
Content-Type: application/json

{
  "username": "your_username",
  "password": "your_password"
}

Response:

{
  "user": {
    "id": 1,
    "username": "john.doe",
    "email": "john@example.com",
    "role": "developer"
  },
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "modules": ["finance", "hr", "inventory"],
  "pinned_items": [...]
}

Using the Token

Include the token in all subsequent requests:

GET /api/company/company/
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Business Domains

Acumen's API is organized into business domains:

1. Company Domain

  • Endpoints : 8 entities
  • Base : /api/company/
  • Entities : Company, Organization, Branch, Department

2. Core Domain

  • Endpoints : 685+ entities
  • Base : /api/core/
  • Entities : Account, Address, Currency, Settings, System configuration

3. Finance Domain

  • Endpoints : 452+ entities
  • Base : /api/finance/
  • Entities : GL, AR, AP, Invoice, Payment, Journal

4. HR Domain

  • Base : /api/hr/
  • Entities : Employee, Payroll, Benefits, Attendance, Leave

5. Inventory Domain

  • Base : /api/inventory/
  • Entities : Items, Warehouses, Stock, Transfers, Adjustments

6. CRM Domain

  • Base : /api/crm/
  • Entities : Customers, Leads, Opportunities, Contacts, Activities

7. Manufacturing Domain

  • Base : /api/manufacturing/
  • Entities : BOMs, Work Orders, Production, Quality Control

8. Project Domain

  • Base : /api/project/
  • Entities : Projects, Tasks, Time Tracking, Resources

9. Business Domain

  • Base : /api/business/
  • Entities : Business metadata and workflows

Standard REST Endpoints

Every entity follows the same REST pattern:

List Records

GET /api/{domain}/{entity}/?skip=0&limit=100

Response:

[
  {"ID": 1, "Field1": "Value1", ...},
  {"ID": 2, "Field2": "Value2", ...}
]

Get Single Record

GET /api/{domain}/{entity}/{id}

Response:

{
  "ID": 1,
  "Field1": "Value1",
  "Field2": "Value2",
  ...
}

Create Record

POST /api/{domain}/{entity}/
Content-Type: application/json

{
  "Field1": "Value1",
  "Field2": "Value2"
}

Response:

{
  "ID": 123,
  "Field1": "Value1",
  "Field2": "Value2",
  ...
}

Update Record

PUT /api/{domain}/{entity}/{id}
Content-Type: application/json

{
  "Field1": "UpdatedValue1",
  "Field2": "UpdatedValue2"
}

Response:

{
  "ID": 123,
  "Field1": "UpdatedValue1",
  "Field2": "UpdatedValue2",
  ...
}

Delete Record

DELETE /api/{domain}/{entity}/{id}

Response:

{
  "status": "success"
}

Query Parameters

Pagination

GET /api/company/company/?skip=0&limit=25
Parameter Type Default Description
skip integer 0 Number of records to skip
limit integer 100 Maximum records to return

Sorting (Future)

GET /api/company/company/?sort=CompanyName&order=asc

Filtering (Future)

GET /api/company/company/?Active=true&BaseCuryID=USD

Response Formats

Success Response

HTTP 200 OK

{
  "CompanyID": 1,
  "CompanyCD": "MAIN",
  "CompanyName": "Main Company",
  "Active": true
}

Error Response

HTTP 404 Not Found

{
  "detail": "Company not found"
}

HTTP 422 Validation Error

{
  "detail": [
    {
      "loc": ["body", "CompanyCD"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

HTTP 500 Internal Server Error

{
  "detail": "Internal server error",
  "error": "Database connection failed"
}

HTTP Status Codes

Code Meaning When Used
200 OK Successful GET, PUT, PATCH
201 Created Successful POST
204 No Content Successful DELETE
400 Bad Request Invalid request format
401 Unauthorized Missing or invalid token
403 Forbidden Insufficient permissions
404 Not Found Resource doesn't exist
422 Unprocessable Entity Validation error
500 Internal Server Error Server error

Rate Limiting (Future)

Rate limiting will be implemented with the following limits:

  • Free tier : 100 requests/minute
  • Standard : 1000 requests/minute
  • Enterprise : Unlimited

Response headers will include:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640000000

Versioning

API versioning strategy (future):

  • URL versioning : /api/v2/company/company/
  • Header versioning : Accept: application/vnd.acumen.v2+json

Current version: v1 (implicit, no version in URL)

Common Endpoints

Health Check

GET /health

Response:
{
  "status": "healthy",
  "service": "Enterprise ERP API"
}

OpenAPI Schema

GET /openapi.json

Response: Full OpenAPI 3.0 specification

Example API Calls

Using cURL

# Login
curl -X POST http://localhost:8001/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "password"}'

# Get companies (with token)
curl http://localhost:8001/api/company/company/ \
  -H "Authorization: Bearer YOUR_TOKEN"

# Create company
curl -X POST http://localhost:8001/api/company/company/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "CompanyCD": "TEST",
    "CompanyName": "Test Company",
    "BaseCuryID": "USD"
  }'

Using JavaScript/Axios

import axios from 'axios';

const api = axios.create({
  baseURL: 'http://localhost:8001',
  headers: {
    'Content-Type': 'application/json'
  }
});

// Login
const login = async (username, password) => {
  const response = await api.post('/api/auth/login', {
    username,
    password
  });

  // Store token
  const token = response.data.token;
  localStorage.setItem('token', token);

  // Set default authorization header
  api.defaults.headers.common['Authorization'] = `Bearer ${token}`;

  return response.data;
};

// Get companies
const getCompanies = async () => {
  const response = await api.get('/api/company/company/');
  return response.data;
};

// Create company
const createCompany = async (companyData) => {
  const response = await api.post('/api/company/company/', companyData);
  return response.data;
};

// Update company
const updateCompany = async (id, companyData) => {
  const response = await api.put(`/api/company/company/${id}`, companyData);
  return response.data;
};

// Delete company
const deleteCompany = async (id) => {
  const response = await api.delete(`/api/company/company/${id}`);
  return response.data;
};

Using Python/requests

import requests

BASE_URL = "http://localhost:8001"

# Login
response = requests.post(f"{BASE_URL}/api/auth/login", json={
    "username": "admin",
    "password": "password"
})
token = response.json()["token"]

# Set up headers
headers = {
    "Authorization": f"Bearer {token}",
    "Content-Type": "application/json"
}

# Get companies
response = requests.get(f"{BASE_URL}/api/company/company/", headers=headers)
companies = response.json()

# Create company
response = requests.post(
    f"{BASE_URL}/api/company/company/",
    json={
        "CompanyCD": "TEST",
        "CompanyName": "Test Company",
        "BaseCuryID": "USD"
    },
    headers=headers
)
new_company = response.json()

API Documentation Sections

Tools and Resources

Postman Collection

Import the OpenAPI schema into Postman:

  1. Open Postman
  2. Import → Link → http://localhost:8001/openapi.json
  3. Create environment with BASE_URL and TOKEN variables

Testing Tools

  • Swagger UI : Built-in interactive testing
  • Postman : API client and testing
  • Insomnia : Alternative API client
  • HTTPie : Command-line HTTP client
  • pytest : Automated API testing

SDK Generation

Generate client SDKs from OpenAPI schema:

# JavaScript/TypeScript
npx openapi-generator-cli generate \
  -i http://localhost:8001/openapi.json \
  -g typescript-axios \
  -o ./src/api-client

# Python
pip install openapi-python-client
openapi-python-client generate \
  --url http://localhost:8001/openapi.json

Best Practices

  1. Always use HTTPS in production
  2. Store tokens securely (localStorage, secure cookies)
  3. Handle errors gracefully with try-catch
  4. Implement retry logic for network failures
  5. Use pagination for large datasets
  6. Cache responses when appropriate
  7. Log API calls for debugging
  8. Monitor rate limits (when implemented)
  9. Version your API requests (when versioning is implemented)
  10. Validate input before sending requests

Next Steps