Introduction
The Tambo360 API is a RESTful API that enables you to manage dairy farm production data programmatically. Built on Express.js, the API provides comprehensive endpoints for managing establishments, batches, costs, products, waste tracking, and real-time alerts.Base URL
All API requests should be made to:API Architecture
The Tambo360 API follows a modular architecture organized into functional domains:Available Endpoints
| Resource | Base Path | Description |
|---|---|---|
| Authentication | /auth | User registration, login, password recovery |
| Health | /health | API health checks and status |
| Establishments | /establecimiento | Farm establishment management |
| Batches | /lote | Production batch tracking |
| Waste | /mermas | Waste and loss tracking |
| Costs | /costos | Cost management and analysis |
| Products | /productos | Product catalog management |
| Alerts | /alertas | Real-time notification system |
| Dashboard | /dashboard | Aggregated metrics and analytics |
Request Format
All requests should include the appropriate headers:Set to
application/json for all POST, PUT, and PATCH requestsContains the JWT token for authenticated requests (automatically handled by browsers)
Example Request
Response Format
All API responses follow a consistent structure:Success Response
HTTP status code (200, 201, etc.)
Human-readable success message in Spanish
Response payload containing the requested data
Always
true for successful responsesSuccess Response Example
Error Response
HTTP error status code (400, 401, 404, 500, etc.)
Error message(s) describing what went wrong. Can be a string for single errors or an array for validation errors
Always
false for error responsesError Response Example
Validation Error Example
HTTP Status Codes
The API uses standard HTTP status codes:| Status Code | Meaning |
|---|---|
200 | OK - Request succeeded |
201 | Created - Resource successfully created |
400 | Bad Request - Invalid input or validation error |
401 | Unauthorized - Authentication required or token invalid |
403 | Forbidden - Authenticated but not authorized |
404 | Not Found - Resource doesn’t exist |
500 | Internal Server Error - Something went wrong on the server |
Rate Limiting
Currently, the Tambo360 API does not enforce rate limits. However, we recommend implementing exponential backoff in your client applications to handle potential future rate limiting.
CORS Configuration
The API supports Cross-Origin Resource Sharing (CORS) with credentials enabled. Allowed origins are configured via theCORS_ORIGIN environment variable.
For authenticated requests from web browsers:
- Set
credentials: 'include'in fetch requests - Use
withCredentials: truein Axios
Interactive API Documentation
Tambo360 provides an interactive Swagger UI for testing API endpoints:- Explore all available endpoints
- Test requests directly from your browser
- View request/response schemas
- Understand parameter requirements
Data Types
Common Field Types
User identifier in UUID v4 format
Establishment identifier in UUID v4 format
ISO 8601 timestamp (e.g.,
2024-03-15T10:30:00.000Z)Valid email address (5-50 characters)
Best Practices
1. Always Handle Errors
Implement comprehensive error handling for all API calls:javascript
2. Include Credentials for Protected Routes
Most endpoints require authentication. Always include credentials:javascript
3. Validate Input Before Sending
Reduce unnecessary API calls by validating data client-side:- Email format validation
- Required field checks
- Password strength requirements
- Data type validation
4. Use TypeScript for Type Safety
typescript
Next Steps
Authentication
Learn how to authenticate users and manage sessions
Establishments
Manage farm establishments and their data
Batches
Track production batches and inventory
Dashboard
Access aggregated metrics and analytics
