FEL Official Resources & XSD Schemas
π Official SAT Resourcesβ
1. SAT XSD Schema Repositoryβ
Official XSD Files:
- URL: https://cat.desa.sat.gob.gt/xsd/alfa/
- Purpose: Official XML Schema Definitions (XSD) for FEL documents
- Contains: Schema definitions for all FEL document types (FACT, NCRE, NDEB, ANULACION, etc.)
Usage:
- Validate XML structure before sending to certifier
- Reference for exact field requirements
- Ensure compliance with SAT specifications
2. Official FEL SAT GitHub Repositoryβ
Repository: https://github.com/fel-sat-gob-gt/cat
Contains:
- Official FEL schemas
- Documentation
- Reference implementations
- Updates and changes
3. XML Digital Signature Schemaβ
W3C XML Signature Schema:
- URL: https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
- Purpose: Required for FEL document signatures
- Note: FEL documents must be digitally signed (handled by certifier)
π Reference Implementationβ
FELgt Repositoryβ
Repository: https://github.com/krudos/FELgt
Description:
- C# implementation of FEL schema
- Can be used as reference for XML structure
- Shows how to build FEL documents programmatically
Note: While this is a C# implementation, the XML structure is language-agnostic and can be used as a reference for our TypeScript/Node.js implementation.
π XSD Schema Files Referenceβ
Document Typesβ
Based on SAT's XSD repository, the following document types are supported:
- FACT - Factura (Invoice)
- NCRE - Nota de CrΓ©dito (Credit Note)
- NDEB - Nota de DΓ©bito (Debit Note)
- ANULACION - AnulaciΓ³n de Factura (Invoice Cancellation)
- FESP - Factura Especial (Special Invoice)
- FACE - Factura ElectrΓ³nica (Legacy Electronic Invoice)
Key XSD Elementsβ
Common Structure (All Document Types)β
<dte:GTDocumento>
<dte:SAT>
<dte:DTE>
<dte:DatosEmision>
<dte:DatosGenerales Tipo="FACT|NCRE|NDEB|ANULACION" />
<dte:Emisor />
<dte:Receptor />
<dte:Frases />
<dte:Items /> <!-- Not for ANULACION -->
<dte:Totales /> <!-- Not for ANULACION -->
</dte:DatosEmision>
<dte:Certificacion />
</dte:DTE>
<dte:Adenda /> <!-- Optional -->
</dte:SAT>
<ds:Signature /> <!-- Digital signature -->
</dte:GTDocumento>
Credit Note (NCRE) Specificβ
Complement: <ReferenciasNota>
<dte:Complementos>
<dte:Complemento NombreComplemento="ReferenciasNota">
<cno:ReferenciasNota>
<cno:ReferenciaTipoDTE>FACT</cno:ReferenciaTipoDTE>
<cno:ReferenciaNumero>UUID_ORIGINAL</cno:ReferenciaNumero>
<cno:MotivoAjuste>DevoluciΓ³n</cno:MotivoAjuste>
</cno:ReferenciasNota>
</dte:Complemento>
</dte:Complementos>
Debit Note (NDEB) Specificβ
Complement: <AjustesFactura>
<dte:Complementos>
<dte:Complemento NombreComplemento="AjustesFactura">
<cno:AjustesFactura>
<cno:ReferenciaTipoDTE>FACT</cno:ReferenciaTipoDTE>
<cno:ReferenciaNumero>UUID_ORIGINAL</cno:ReferenciaNumero>
<cno:MotivoAjuste>Cobro adicional</cno:MotivoAjuste>
</cno:AjustesFactura>
</dte:Complemento>
</dte:Complementos>
Cancellation (ANULACION) Specificβ
Structure: Different from other documents
<dte:GTDocumento>
<dte:SAT>
<dte:AnulacionDocumento ID="DatosAnulacion">
<dte:DatosGenerales
FechaEmisionDocumentoAnulado="2025-02-18T10:20:00-06:00"
FechaHoraAnulacion="2025-02-18T10:25:00-06:00"
ID="ANULACION"
MotivoAnulacion="Error en la factura"
/>
<dte:DocumentoAnulado
NumeroDocumento="UUID_ORIGINAL"
NITEmisor="1234567-8"
NITReceptor="CF"
/>
</dte:AnulacionDocumento>
</dte:SAT>
</dte:GTDocumento>
π οΈ Using XSD for Validationβ
Option 1: XML Validation Libraryβ
Node.js Libraries:
libxmljs2- XML parsing and validationxmldom+xsd-schema-validator- XSD validation
Example:
import { validateXML } from 'xsd-schema-validator';
async function validateFelXml(xmlContent: string, xsdPath: string): Promise<boolean> {
try {
await validateXML(xmlContent, xsdPath);
return true;
} catch (error) {
console.error('XSD Validation Error:', error);
return false;
}
}
Option 2: Download XSD Filesβ
Download from SAT:
# Download FEL XSD schemas
wget -r https://cat.desa.sat.gob.gt/xsd/alfa/
# Download XML Signature schema
wget https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
Store in project:
docs/fel/xsd/
βββ dte.xsd
βββ fact.xsd
βββ ncre.xsd
βββ ndeb.xsd
βββ anulacion.xsd
βββ xmldsig-core-schema.xsd
Option 3: Runtime Validation (Recommended)β
For Development:
- Use XSD validation in development/staging
- Log validation errors
- Don't block certification (certifier will validate anyway)
For Production:
- Rely on certifier validation
- Log XML for debugging
- Monitor certifier error responses
π Schema Namespacesβ
Common Namespacesβ
xmlns:dte="http://www.sat.gob.gt/dte/fel/0.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:dtecomm="https://www.digifact.com.gt/dtecomm"
xmlns:cno="http://www.sat.gob.gt/dte/fel/CompCambiaria/0.1.0"
Namespace Usageβ
dte:- Main FEL document elementsds:- Digital signature elementsdtecomm:- Digifact addendum (optional)cno:- Complements (ReferenciasNota, AjustesFactura)
π Useful Linksβ
-
SAT Portal:
-
XSD Repository:
-
Official GitHub:
-
Reference Implementation:
-
W3C XML Signature:
π‘ Recommendationsβ
1. Download XSD Files Locallyβ
Store XSD files in your project for:
- Reference during development
- Optional validation in development
- Documentation purposes
2. Use XSD as Referenceβ
Even if not validating, use XSD files to:
- Understand exact field requirements
- Check data types and formats
- Ensure compliance
3. Monitor SAT Updatesβ
- Check official repository for schema changes
- Subscribe to SAT notifications
- Update XSD files when schemas change
4. Test with XSD Validationβ
In development/staging:
- Validate XML before sending to certifier
- Catch structural errors early
- Reduce certifier API calls
π― Next Stepsβ
-
Download XSD Files:
mkdir -p docs/fel/xsd
cd docs/fel/xsd
wget -r --no-parent https://cat.desa.sat.gob.gt/xsd/alfa/ -
Review Schema Files:
- Check
ncre.xsdfor credit note structure - Check
ndeb.xsdfor debit note structure - Check
anulacion.xsdfor cancellation structure
- Check
-
Update XML Generation:
- Use XSD as reference for exact structure
- Ensure all required fields are included
- Match namespace declarations exactly
-
Add Optional Validation:
- Implement XSD validation in development
- Log validation errors
- Don't block certification (certifier is source of truth)
Last Updated: 2025-12-18
References: