Introduction
The Inventario API is a RESTful web service built with Django that provides inventory management capabilities including products, sales, purchases, clients, and suppliers management.Base URL
All API requests should be made to your Inventario installation’s base URL:API Architecture
The Inventario API follows Django’s URL routing structure with the following main endpoints:/productos/- Product management/ventas/- Sales and transactions/compras/- Purchase orders/clientes/- Client management/proveedores/- Supplier management/usuarios/- User management/reportes/- Reports and analytics/configuracion/- System configuration
Request Format
The API accepts both form-encoded data and JSON payloads depending on the endpoint:Form-Encoded (Standard Django Views)
JSON (AJAX/API Endpoints)
Response Format
HTML Responses
Standard Django views return rendered HTML templates with server-side rendering.JSON Responses
API endpoints (typically under/api/ paths) return JSON responses:
Error Response
HTTP Status Codes
The API uses standard HTTP status codes:Request successful
Resource created successfully
Redirect (common in Django form submissions)
Invalid request parameters or validation error
Authentication required
Insufficient permissions (e.g., vendedor accessing admin-only endpoint)
Resource not found
Server error
Common Error Codes
| Error Code | Description |
|---|---|
CSRF_TOKEN_MISSING | CSRF token not provided |
INVALID_CREDENTIALS | Authentication failed |
PERMISSION_DENIED | User lacks required role/permissions |
VALIDATION_ERROR | Form validation failed |
RESOURCE_NOT_FOUND | Requested resource doesn’t exist |
PROTECTED_ERROR | Cannot delete resource with dependencies |
Pagination
List endpoints support pagination with query parameters:Page number to retrieve
has_next- Boolean indicating more pageshas_previous- Boolean indicating previous pagesnumber- Current page numbernum_pages- Total number of pages
Filtering and Sorting
Many list endpoints support filtering and sorting:Filtering
Sorting
Date/Time Format
All timestamps use ISO 8601 format in America/Bogota timezone:Decimal Fields
Monetary values use Decimal type with 2 decimal places:User Roles and Permissions
Inventario implements role-based access control:Admin Role
- Full CRUD operations on all resources
- Can create/manage vendedor users
- Access to all reports and analytics
Vendedor Role
- Read-only access to products
- Can create and view sales
- Limited access to reports
- Cannot modify products, purchases, or system settings