REST API
Complete reference for the ERPX REST API endpoints.
Common Endpoints
All document types follow the same CRUD pattern:
| Method | Endpoint | Description |
|---|---|---|
GET | /api/v1/{resource} | List all records |
GET | /api/v1/{resource}/{id} | Get a single record |
POST | /api/v1/{resource} | Create a new record |
PUT | /api/v1/{resource}/{id} | Update a record |
DELETE | /api/v1/{resource}/{id} | Delete a record |
Items API
List Items
GET /api/v1/items?page=1&perPage=20&category=ElectronicsQuery Parameters:
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
perPage | integer | Items per page (default: 20, max: 100) |
search | string | Search in name/code |
category | string | Filter by category |
itemType | string | Filter: Product, Service, Consumable |
sort | string | Sort field (default: createdAt) |
order | string | Sort order: asc, desc |
Response:
{
"success": true,
"data": [
{
"id": "itm_001",
"itemCode": "LAPTOP-001",
"itemName": "Business Laptop 15\"",
"category": "Electronics",
"itemType": "Product",
"uom": "pcs",
"sellingPrice": 999.99,
"costPrice": 650.0,
"currentStock": 45,
"reorderLevel": 10,
"isActive": true,
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
],
"meta": {
"page": 1,
"perPage": 20,
"total": 150,
"totalPages": 8
}
}Create Item
POST /api/v1/items
Content-Type: application/json{
"itemCode": "MOUSE-001",
"itemName": "Wireless Mouse",
"category": "Electronics",
"itemType": "Product",
"uom": "pcs",
"sellingPrice": 29.99,
"costPrice": 12.0,
"reorderLevel": 50,
"reorderQty": 200,
"description": "Ergonomic wireless mouse with USB receiver",
"images": ["https://storage.erpx.io/items/mouse-001.jpg"]
}Customers API
List Customers
GET /api/v1/customersCreate Customer
POST /api/v1/customers{
"name": "Acme Corporation",
"email": "billing@acme.com",
"phone": "+1-555-0123",
"type": "Company",
"address": {
"street": "123 Business Ave",
"city": "San Francisco",
"state": "CA",
"zipCode": "94105",
"country": "US"
},
"creditLimit": 50000,
"paymentTerms": "Net 30",
"taxId": "12-3456789"
}Sales Orders API
Create Sales Order
POST /api/v1/sales-orders{
"customer": "cust_001",
"orderDate": "2024-01-15",
"deliveryDate": "2024-01-30",
"items": [
{
"item": "itm_001",
"quantity": 10,
"rate": 999.99,
"discount": 5
},
{
"item": "itm_002",
"quantity": 20,
"rate": 29.99
}
],
"paymentTerms": "Net 30",
"notes": "Deliver to main office"
}Update Order Status
PUT /api/v1/sales-orders/{id}/status{
"status": "submitted"
}Invoices API
Generate Invoice from Sales Order
POST /api/v1/invoices/from-order{
"salesOrder": "so_001",
"invoiceDate": "2024-01-20"
}Search API
Full-Text Search
GET /api/v1/search?q=laptop&types=items,customers&limit=10Response:
{
"success": true,
"data": {
"items": [
{ "id": "itm_001", "name": "Business Laptop 15\"", "score": 0.95 }
],
"customers": [
{ "id": "cust_042", "name": "Laptop World Inc.", "score": 0.72 }
]
}
}Pagination
All list endpoints support cursor-based and offset pagination:
Offset Pagination
GET /api/v1/items?page=2&perPage=50Filtering
Use query parameters for filtering:
# Multiple filters
GET /api/v1/items?category=Electronics&sellingPrice[gte]=100&sellingPrice[lte]=500
# Date range
GET /api/v1/sales-orders?orderDate[gte]=2024-01-01&orderDate[lte]=2024-01-31
# Status filter
GET /api/v1/invoices?status=unpaidFilter Operators
| Operator | Description | Example |
|---|---|---|
eq | Equal (default) | status=active |
ne | Not equal | status[ne]=cancelled |
gt | Greater than | price[gt]=100 |
gte | Greater than or equal | price[gte]=100 |
lt | Less than | price[lt]=500 |
lte | Less than or equal | price[lte]=500 |
in | In list | status[in]=draft,submitted |
like | Pattern match | name[like]=laptop |
All API responses include X-Request-Id headers for debugging and support
purposes.