Base URL
All API requests should be made to:API Information
- Title: Torn - Facturador Electrónico
- Description: Sistema de facturación electrónica para el SII de Chile
- Version: 0.1.0
- Framework: FastAPI
Multi-Tenant Architecture
Torn uses a multi-tenant SaaS architecture with schema-based isolation. Each tenant (company) has its own database schema, ensuring complete data separation.Tenant Context Header
Most API endpoints require theX-Tenant-ID header to specify which tenant’s data you’re accessing:
Global endpoints like authentication (
/auth/*) and tenant management (/saas/*) do not require the X-Tenant-ID header.Common Conventions
Request Format
The API accepts JSON request bodies for POST and PUT operations:Response Format
All responses are returned in JSON format with appropriate HTTP status codes. Successful Response Example:Date/Time Format
All timestamps follow ISO 8601 format with UTC timezone:HTTP Status Codes
The API uses standard HTTP status codes:| Code | Meaning | Description |
|---|---|---|
200 | OK | Request succeeded |
201 | Created | Resource created successfully |
204 | No Content | Request succeeded with no response body |
400 | Bad Request | Invalid request parameters or body |
401 | Unauthorized | Missing or invalid authentication token |
403 | Forbidden | Insufficient permissions |
404 | Not Found | Resource not found |
409 | Conflict | Resource conflict (e.g., duplicate RUT) |
500 | Internal Server Error | Server error |
Error Responses
When an error occurs, the API returns a JSON object with error details:Common Error Examples
CORS Configuration
The API is configured to accept requests from the following origins:http://localhost:3000http://localhost:3001http://localhost:3002http://localhost:8000http://127.0.0.1:3000http://127.0.0.1:3001http://127.0.0.1:3002http://127.0.0.1:8000
Rate Limiting
Currently, the API does not implement rate limiting. This may be added in future versions.Available Endpoints
The API is organized into the following endpoint groups:- Authentication (
/auth) - User login and session management - SaaS Management (
/saas) - Tenant and user management - Health - Health check endpoints
- Customers - Customer management
- Products - Product catalog
- Sales - Sales and invoicing
- Purchases - Purchase orders
- Inventory - Stock management
- Cash - Cash register operations
- Reports - Business reports
- Users - User management within tenants
- Roles - Role and permissions
- Configuration - System settings and taxes
- Folios - DTE folio management
For detailed information on authentication and authorization, see the Authentication guide.
Interactive Documentation
FastAPI provides interactive API documentation:- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc