API Reference

Complete API documentation for developers integrating with Decconz Multi-ERP Suite.

API Authentication

All API requests require authentication using Bearer tokens. Generate your API keys from Settings → API → Generate Key.

Authentication

cURL Example
# Get authentication token
curl -X POST https://your-erp.com/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "admin@example.com", "password": "your_password"}'

# Response
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
  "user": { ... }
}

API Endpoints

Users

Endpoint Method Description Parameters
/api/v1/users GET List all users page, limit, search
/api/v1/users POST Create new user name, email, role, etc.
/api/v1/users/{id} GET Get user details id (path parameter)
/api/v1/users/{id} PUT Update user id, name, email, etc.
/api/v1/users/{id} DELETE Delete user id (path parameter)

Invoices

Create Invoice Example
// JavaScript Example
const createInvoice = async (invoiceData) => {
  const response = await fetch('https://your-erp.com/api/v1/invoices', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + authToken,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(invoiceData)
  });
  
  return await response.json();
};

// Example invoice data
const invoiceData = {
  customer_id: 12345,
  invoice_number: 'INV-2024-001',
  date: '2024-01-15',
  due_date: '2024-02-15',
  items: [
    {
      description: 'ERP Software License',
      quantity: 1,
      unit_price: 299.00,
      tax_rate: 8.5
    },
    {
      description: 'Implementation Services',
      quantity: 10,
      unit_price: 150.00,
      tax_rate: 8.5
    }
  ],
  notes: 'Annual subscription with implementation'
};

Inventory

Python Example
# Python Example
import requests

class DecconzERP:
    def __init__(self, base_url, api_key):
        self.base_url = base_url
        self.headers = {
            'Authorization': f'Bearer {api_key}',
            'Content-Type': 'application/json'
        }
    
    def get_products(self, page=1, limit=50):
        response = requests.get(
            f'{self.base_url}/api/v1/products',
            headers=self.headers,
            params={'page': page, 'limit': limit}
        )
        return response.json()
    
    def update_stock(self, product_id, quantity, warehouse_id=1):
        data = {
            'product_id': product_id,
            'quantity': quantity,
            'warehouse_id': warehouse_id,
            'adjustment_type': 'add' if quantity > 0 else 'subtract'
        }
        response = requests.post(
            f'{self.base_url}/api/v1/inventory/adjustments',
            headers=self.headers,
            json=data
        )
        return response.json()

# Usage
erp = DecconzERP('https://your-erp.com', 'your-api-key')
products = erp.get_products()
print(products)

Error Codes

Code Message Description
400 Bad Request Invalid request parameters
401 Unauthorized Missing or invalid authentication
403 Forbidden Insufficient permissions
404 Not Found Resource doesn't exist
422 Unprocessable Entity Validation errors
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server-side error