Troubleshooting
Guide for resolving the most common errors when issuing NF-e through the NF-e SP connector.
Rejection 225 - XML Schema Failure
Message: Rejeicao: Falha no Schema XML do lote de NFe
This is the most common rejection. It means the XML generated from your JSON does not pass SEFAZ's XSD validation. Below are the most frequent causes.
Leading zeros in numeric fields
Fields like serie and n_nf do not accept leading zeros.
Valid patterns:
| Field | Pattern | Allowed values |
|---|---|---|
serie | 0 or 1-999 | "0", "1", "999" |
n_nf | 1-999999999 | "1", "74110", "999999999" |
imposto_devol in the wrong position
For return invoices, imposto_devol must be a sibling of imposto inside det, not a child of imposto or ipi.
Missing timezone in datetime fields
The dh_emi field requires a timezone offset.
Wrong decimal format
Decimal fields have strict formatting rules. The number of decimal places matters.
Decimal rules by field type:
| Fields | Integer digits | Decimal places | Example |
|---|---|---|---|
Values (v_bc, v_prod, v_icms, etc.) | up to 13 | exactly 2 | "519.92" |
Rates (p_icms, p_ipi, p_pis, etc.) | up to 3 | 2 to 4 | "12.0000" |
Quantities (q_com, q_trib) | up to 11 | 1 to 4 | "1.0000" |
Unit values (v_un_com, v_un_trib) | up to 11 | 1 to 10 | "519.9200" |
Multiple tax variants in the same item
Each tax group (ICMS, PIS, COFINS, IPI) accepts only one variant per item.
Invalid GTIN/EAN
The c_ean and c_ean_trib fields accept only specific formats.
Invalid CFOP
CFOP must be 4 digits and start with 1, 2, 3, 5, 6, or 7.
Text fields with leading/trailing spaces
Text fields (like x_nome, x_prod, nat_op) cannot start or end with spaces.
Rejection 502 - Access Key Mismatch
Message: Rejeicao: Erro na Chave de Acesso - campo ID
The manually provided access key doesn't match the concatenation of the NF-e fields.
Solution: Don't pass the id field manually. Let the connector generate the access key automatically:
Rejection 539 / 540 - Duplicate NF-e
Message: Rejeicao: Duplicidade de NF-e
An NF-e with the same access key (same serie + n_nf + emit CNPJ) was already authorized.
Solution: Increment the n_nf (invoice number) or use a different c_nf (random code).
Rejection 215 - Signature Error
Message: Rejeicao: Falha no Schema XML - elemento assinatura
Possible causes:
- Expired certificate
- Certificate without private key
- Certificate not issued by ICP-Brasil
Solution: Check your certificate configuration:
Authentication Errors
mTLS / Certificate not accepted
Cause: The SEFAZ server could not validate the digital certificate during the TLS handshake.
Solutions:
- Confirm the certificate password is correct
- Check if the certificate is not expired
- Make sure the certificate contains the full certification chain
- Verify the certificate is type A1 (PFX/P12 format)
General Tips
1. Use homologacao first
Set environment: "homologacao" in the connector configuration to test before production.
2. Start with minimal fields
Begin with only the required fields and add optional ones as needed. This makes it easier to identify which field is causing the rejection.
3. Check the connector's validation warnings
The connector performs XSD validation before sending to SEFAZ. If there are validation issues, they will appear in the response under _validation_warnings:
4. Parse the SEFAZ response
The SEFAZ response includes c_stat (status code) and x_motivo (reason):