Overview
jshERP provides a comprehensive RESTful API built on Spring Boot that allows you to interact with all core ERP functionalities including inventory management, sales, purchasing, financial operations, and more. The API follows REST principles and returns JSON responses for all endpoints.Base URL
The API base URL is configured inapplication.properties:
In production environments, replace
localhost with your actual domain name and ensure proper SSL/TLS configuration.API Structure
The API is organized into logical resource groups:Core Resources
/user- User management and authentication/material- Product/material management/depotHead- Warehouse document management (orders, receipts)/depot- Warehouse/depot operations/supplier- Supplier management/role- Role and permissions management/organization- Organization structure management
Inventory Management
/depotItem- Warehouse item details/materialCategory- Product categories/serialNumber- Serial number tracking/unit- Unit of measure management
Financial Operations
/accountHead- Financial transaction headers/accountItem- Financial transaction line items/account- Account management
System Configuration
/systemConfig- System configuration settings/function- Function/menu management/log- System logging/tenant- Multi-tenant management
Request & Response Format
Request Format
All requests should include:Standard Response Format
Response Codes
| Code | Description |
|---|---|
200 | Success - Request completed successfully |
500 | Error - Request failed, check error message |
501 | Special condition (e.g., WeChat not bound) |
jshERP uses a simplified response code structure. Most responses use code 200 for success and 500 for errors, with detailed messages in the data field.
Common Patterns
Pagination
List endpoints support pagination through query parameters:pageNum- Page number (starting from 1)pageSize- Number of records per page
Search Filtering
Many endpoints accept asearch parameter with JSON-encoded search criteria:
Batch Operations
Batch operations use comma-separated IDs:Data Operations
CRUD Operations
Standard endpoints follow consistent patterns:| Operation | Method | Endpoint Pattern | Example |
|---|---|---|---|
| Get by ID | GET | /{resource}/info?id={id} | /material/info?id=1 |
| List | GET | /{resource}/list | /material/list |
| Create | POST | /{resource}/add | /material/add |
| Update | PUT | /{resource}/update | /material/update |
| Delete | DELETE | /{resource}/delete?id={id} | /material/delete?id=1 |
| Batch Delete | DELETE | /{resource}/deleteBatch?ids={ids} | /material/deleteBatch?ids=1,2,3 |
Existence Checks
Many resources provide existence check endpoints:Session Management
jshERP uses Redis-backed session management:- Session data is stored in Redis with configurable timeout
- Default session timeout: 10 hours (36000 seconds)
- Token is passed via
X-Access-Tokenheader - Session automatically expires after the configured timeout
Multi-Tenant Support
jshERP includes built-in multi-tenant capabilities:- Each user belongs to a tenant
- Tenant configuration includes user limits and trial periods
- Data isolation is enforced at the application level
- Tenant information is stored in user sessions
When working with the API, all operations are automatically scoped to the authenticated user’s tenant.
Swagger Documentation
jshERP includes Swagger UI for interactive API exploration:- Complete endpoint documentation
- Request/response schemas
- Interactive API testing
- API version information
Swagger UI is accessible without authentication for ease of development.
Error Handling
Common Error Scenarios
Session Expired:data field for details.
Error Codes in Business Operations
Some operations return specific status codes in the response data:0- Operation failed1- Operation succeeded2- Specific condition (e.g., wrong password)3- Exception occurred
Rate Limiting
Session timeout is configured to 10 hours. Each authenticated request automatically extends the session timeout.Best Practices
- Always include the X-Access-Token header for authenticated requests
- Handle session expiration gracefully and redirect to login
- Use batch operations when performing multiple similar operations
- Implement proper error handling for all API calls
- Encode search parameters properly when using JSON in query strings
- Check existence before creating resources to avoid duplicates
- Validate input data on the client side before sending requests
Next Steps
Authentication
Learn how to authenticate and manage user sessions
Swagger API Docs
Explore the interactive API documentation