Sales Invoices Guide
Document Type: Sales Invoice
Document Type ID: 5 (verify with /document-type)
Overviewβ
Sales Invoices are definitive fiscal documents that:
- π§Ύ Prove the sale of goods or services
- π AFFECT stock (outbound)
- π° Generate accounts receivable
- π Registered for tax and accounting purposes
- β Official fiscal document
When to Useβ
- β Definitive sale of products/services
- β Issuing fiscal document
- β Recording company revenue
- β VAT accounting
Invoice Characteristicsβ
| Characteristic | Value | Description |
|---|---|---|
| Affects Stock | β Yes | Stock outbound |
| Requires Payment | β Yes | Generates receivable |
| Can be Closed | β Yes | Mandatory finalization |
| Fiscal Validation | β Yes | Official fiscal document |
| Allows Editing | β οΈ Limited | Only before closing |
| Cancellation | β οΈ Via Credit Note | Cannot be deleted |
Create Invoiceβ
Complete Exampleβ
POST /api/v1/invoices
Content-Type: application/json
Authorization: Bearer {token}
{
"serieId": 1,
"documentTypeId": 5,
"entityKeyId": "CLI001",
"entityDescription": "Example Client, Ltd",
"entityVat": "PT123456789",
"entityAddress": "123 Example Street",
"entityPostalCode": "1000-000",
"entityCity": "Lisbon",
"entityCountry": "Portugal",
"obs": "Invoice for order PO-2025-001",
"docReference": "PO-2025-001",
"dueDate": "2025-12-31",
"paymentModeId": 1,
"documentBodies": [
{
"itemKeyId": "PROD001",
"itemDescription": "Product 1",
"quantity": 2.0,
"retailPrice": 50.00,
"taxId": 1,
"paymentType": 1,
"stockFlow": 1, // Stock outbound
"stockBehavior": 1, // Normal behavior
"secondTaxId": 0
}
]
}
Invoice with Discountβ
{
"serieId": 1,
"documentTypeId": 5,
"entityKeyId": "CLI001",
"documentBodies": [
{
"itemKeyId": "PROD001",
"quantity": 10.0,
"retailPrice": 100.00,
"discountValue": 10.00, // Line discount
"taxId": 1,
"paymentType": 1,
"stockFlow": 1,
"stockBehavior": 1,
"secondTaxId": 0
}
]
}
VAT Exempt Invoiceβ
{
"serieId": 1,
"documentTypeId": 5,
"entityKeyId": "CLI001",
"exemptionCode": "M01", // Exemption code
"exemptionReason": "Exempt under article 9 of VAT Code",
"documentBodies": [
{
"itemKeyId": "PROD001",
"quantity": 1.0,
"retailPrice": 100.00,
"taxId": 2, // Exemption tax rate
"paymentType": 1,
"stockFlow": 1,
"stockBehavior": 1,
"secondTaxId": 0
}
]
}
Update Invoiceβ
Update Observationsβ
PUT /api/v1/invoices/123
Content-Type: application/json
Authorization: Bearer {token}
{
"id": 123,
"obs": "Updated observations",
"docReference": "PO-2025-001-REV"
}
Close Invoiceβ
PUT /api/v1/invoices/123
Content-Type: application/json
Authorization: Bearer {token}
{
"id": 123,
"close": true
}
Attention
After closing the invoice, it cannot be edited. To correct, use a Credit Note.
Get Invoiceβ
By IDβ
GET /api/v1/invoices/123
Authorization: Bearer {token}
By Numberβ
GET /api/v1/invoices/5/1/1
Authorization: Bearer {token}
Parameters: documentTypeId=5, serieId=1, number=1
List Invoicesβ
GET /api/v1/invoices?documentTypeId=5&status=Open&pageNumber=1&pageSize=20
Authorization: Bearer {token}
Invoice Lifecycleβ
graph LR
A[Create Invoice] --> B[Status: Open]
B --> C[Edit if needed]
C --> D[Close Invoice]
D --> E[Status: Closed]
E --> F{Need correction?}
F -->|Yes| G[Create Credit Note]
F -->|No| H[End]
- Create: Invoice created with status
Open - Edit: Possible to edit while
Open - Close: Finalize invoice (status
Closed) - Correction: Only via Credit Note
Important Validationsβ
Required Dataβ
- β
serieId- Series configured for invoices - β
documentTypeId- Document type ID (5) - β
entityKeyId- Valid customer - β
documentBodies- At least 1 line - β
stockFlow = 1- Stock outbound
Fiscal Validationsβ
- β Customer Tax ID/VAT (if PT)
- β Complete address
- β Exemption code (if applicable)
- β Correct VAT rate per line
Stock Validationsβ
- β Product exists
- β
Stock available (if
stockBehavior = 1) - β Valid warehouse
Best Practicesβ
β Recommendedβ
- Validate stock before creating invoice
- Include complete customer address
- Set due date
- Reference previous documents (QT, ORD)
- Close invoice as soon as confirmed
- Include payment information
β Avoidβ
- Creating invoice without validating stock
- Leaving invoices open indefinitely
- Trying to edit closed invoice
- Creating duplicate invoices
- Forgetting fiscally required fields
Common Use Casesβ
Simple Invoiceβ
Direct sale with cash payment.
Credit Invoiceβ
Sale with payment terms (30/60/90 days).
Services Invoiceβ
Service provision (no stock).
Recurring Invoiceβ
Monthly invoice for contracted services.
Corrections and Cancellationsβ
Scenario: Invoice Errorβ
β WRONG: Try to edit closed invoice
β CORRECT: Create Credit Note
POST /api/v1/invoices
Content-Type: application/json
{
"serieId": 3,
"documentTypeId": 7, // Credit Note
"entityKeyId": "CLI001",
"docReference": "INV A/123", // Reference to original invoice
"obs": "Cancellation of invoice INV A/123",
"documentBodies": [
{
"itemKeyId": "PROD001",
"quantity": -2.0, // Negative quantity
"retailPrice": 50.00,
"taxId": 1,
"paymentType": 1,
"stockFlow": -1, // Stock inbound
"stockBehavior": 1,
"secondTaxId": 0
}
]
}
Integration with Other Documentsβ
From Quote to Invoiceβ
See Quotes Guide
From Order to Invoiceβ
See Orders Guide
Invoice to Receiptβ
See Receipts Guide
Next Stepsβ
- Receipts Guide - Register payments
- Credit Notes Guide - Corrections and returns
- Usage Guide - General API information
Last Updated: December 2, 2025