TTN / El Fatoora API Integration with Your ERP: Complete Guide for Odoo, SAP, WooCommerce and Custom Systems
Electronic invoicing in Tunisia is no longer optional. With the extension to service providers (LdF 2026) and penalties up to 50,000 TND per fiscal year, integrating your management system with the TTN / El Fatoora API is now an operational priority.
This guide covers different integration scenarios — whether you use Odoo, SAP, a custom ERP, or an e-commerce platform — with detailed architectures, code examples, and pitfalls to avoid.
TTN API Overview
General Architecture
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Your ERP │────▶│ Middleware │────▶│ Signature │
│ (invoicing) │ │ (validation │ │ TUNTRUST │
│ │ │ + TEIF) │ │ (ANCE) │
└──────────────┘ └──────────────┘ └──────┬───────┘
│
┌──────────────┐ ┌───────▼───────┐
│ Response │◀────│ TTN API │
│ (status, │ │ El Fatoora │
│ PDF, QR) │ │ │
└──────────────┘ └───────────────┘
Key Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/v1/invoice/submit | POST | Submit a signed TEIF invoice |
/api/v1/invoice/{id}/status | GET | Check invoice status |
/api/v1/invoice/{id}/pdf | GET | Get official PDF (with QR) |
/api/v1/invoice/bulk | POST | Bulk submission |
Authentication
TTN API uses mutual TLS with client certificates:
import https from 'https';
import fs from 'fs';
const agent = new https.Agent({
cert: fs.readFileSync('/path/to/tuntrust-cert.pem'),
key: fs.readFileSync('/path/to/private-key.pem'),
ca: fs.readFileSync('/path/to/ance-ca.pem'),
});
const response = await fetch('https://api.elfatoora.digital/api/v1/invoice/submit', {
method: 'POST',
headers: { 'Content-Type': 'application/xml' },
body: teifXml,
agent
});Scenario 1: Odoo Integration
Odoo is the most deployed ERP in Tunisia for SMEs. We recommend a middleware-based approach:
Custom Odoo Module
# odoo_elfatoora/models/account_move.py
from odoo import models, fields
import requests
class AccountMove(models.Model):
_inherit = 'account.move'
elfatoora_status = fields.Selection([
('draft', 'Draft'),
('submitted', 'Submitted'),
('accepted', 'Accepted'),
('rejected', 'Rejected'),
], string='El Fatoora Status', default='draft')
elfatoora_id = fields.Char('El Fatoora ID')
def action_submit_elfatoora(self):
self.ensure_one()
teif_data = self._generate_teif_xml()
response = requests.post(
'https://middleware.noqta.tn/api/v1/invoice/submit',
json={'invoice_data': teif_data, 'company_tax_id': self.company_id.vat},
headers={'Authorization': f'Bearer {self.env["ir.config_parameter"].get_param("elfatoora.api_key")}'}
)
if response.status_code == 200:
result = response.json()
self.write({'elfatoora_status': 'submitted', 'elfatoora_id': result['invoice_id']})Scenario 2: SAP, Sage, and Other ERPs
For proprietary ERPs, a dedicated middleware translates between your ERP's data format and TEIF XML. The middleware handles validation, digital signature, submission, and retry logic.
Scenario 3: Custom Systems (Direct API)
For custom-built systems, see our full TTN API integration tutorial with a complete TypeScript client.
Scenario 4: E-commerce (WooCommerce, PrestaShop)
E-commerce platforms can integrate via a webhook-based approach: on order completion, the plugin extracts invoice data and sends it to the middleware for TEIF conversion and TTN submission.
Common Pitfalls
- Amount format: TTN requires exactly 3 decimal places for TND amounts
- Tax ID format: Must be exactly
XXXXXXXXA/M/NNN - Certificate expiry: TUNTRUST certificates expire after 2 years
- Error handling: Implement retry with exponential backoff
- Invoice numbering: TTN checks sequential continuity
- Credit notes: Must reference the original El Fatoora ID
Noqta: Your TTN Integration Partner
We've integrated the TTN API into 20+ different systems. Our offering:
- El Fatoora Middleware as-a-Service — Unified REST API for all your ERPs
- Turnkey ERP Modules — Odoo, SAP, WooCommerce, PrestaShop
- Custom Integration — For bespoke systems
- Training & Support — For your IT and accounting teams
📩 Contact us for a free TTN integration quote.
FAQ
How long does TTN integration take?
Standard ERP with our middleware: 2-4 weeks. Custom system: 4-8 weeks.
What does the TUNTRUST certificate cost?
200-500 TND depending on the accredited provider. Valid for 2 years.
Can I test before going live?
Yes. TTN provides a sandbox environment. We configure your integration in sandbox first.
Does El Fatoora accept foreign currency invoices?
TEIF format is in TND. Foreign currency invoices must include the converted TND amount.
Related articles:
Discuss Your Project with Us
We're here to help with your web development needs. Schedule a call to discuss your project and how we can assist you.
Let's find the best solutions for your needs.