Request Format
The API accepts Excel files for batch invoice generation.Endpoint
Content Type
multipart/form-dataRequest Body
Excel file (.xlsx) containing invoice data
The API processes the uploaded Excel file using FastAPI’s
UploadFile mechanism, reads it into memory with pandas, and generates JSON invoice files for each row.Excel File Requirements
The Excel file must contain the following columns:Data Processing
The API performs the following transformations:Numeric Rounding
- Bolivares amounts: Rounded to 2 decimals
- USD amounts: Rounded to 0 decimals
- VAT calculations: Rounded to 2 decimals (BSD) and 0 decimals (USD)
Response Format
Content Type
application/zipResponse Headers
YYYYMMDD is the current date (e.g., FAC-20250309.zip)The API generates the ZIP file in memory using Python’s
io.BytesIO and streams it back to the client without writing to disk.ZIP File Structure
The response ZIP file contains a hierarchical folder structure:The structure groups invoices into batches of 100 files per folder for easier management.
Folder Naming Convention
Root Folder
FAC= Fixed prefix for invoicesYYYYMMDD= Current date (e.g.,20250309)
Batch Folders
J408185431= Fixed company RIF/tax IDYYYYMMDD= Current dateNNN= Batch number (zero-padded to 3 digits)
Batch Calculation
Batch number is calculated as:
(row_index // 100) + 1Examples:- Rows 0-99 → Batch 001
- Rows 100-199 → Batch 002
- Rows 200-299 → Batch 003
Invoice File Naming
0= Fixed prefixNNNNNN= Correlativo (invoice number) zero-padded to 6 digits
Examples
| Correlativo | Filename |
|---|---|
| 1 | 0000001.json |
| 42 | 0000042.json |
| 6746 | 0006746.json |
| 123456 | 0123456.json |
JSON File Format
Each invoice JSON file contains a completeDocumentoElectronico object as described in the Invoice Document Structure page.
File Encoding
JSON files are written with:
- 4-space indentation (
indent=4) - UTF-8 encoding (
ensure_ascii=False) - Pretty-printed for readability
Example File Content
0006746.json (abbreviated)
Complete Request/Response Example
Response Processing
Error Handling
Invalid File Format
Invalid File Format
If the uploaded file is not a valid Excel file:Status Code: 400 Bad Request
Missing Required Columns
Missing Required Columns
If required columns are missing from the Excel file:Status Code: 500 Internal Server Error
Invalid Date Format
Invalid Date Format
If dates cannot be parsed:The
fmt_fecha() function returns the original value or None if parsing fails, and processing continues.Invalid Numeric Values
Invalid Numeric Values
If numeric fields contain non-numeric values:Status Code: 500 Internal Server Error