# NFE-502

Source: https://xmlvalid.com/rules/NFE-502

> Rejeição: Erro na Chave de Acesso - Campo Id não corresponde à concatenação dos campos correspondentes (Id …, campos NFe……).

- Level: error
- Rule sets: SEFAZ authorisation rules of NF-e 4.00 MOC 7.0 Anexo I, NTs up to 2026.010
- Context: `nfe:infNFe`
- Test: `@Id = concat('NFe', $key43, $ide/nfe:cDV)`

In English: The access key in infNFe/@Id is not "NFe" followed by cUF, the year and month of dhEmi, the issuer's CNPJ or CPF, mod, serie, nNF, tpEmis, cNF and cDV.

## Why it fails

- A field of ide (serie, nNF, cNF, tpEmis or dhEmi) changed after the key was built.
- The CPF of an issuer is not padded with three zeros to 14 digits in the key.

## How to fix it

- Build the key from the fields as they stand: cUF (2), AAMM of dhEmi (4), CNPJ or 000 + CPF (14), mod (2), serie (3), nNF (9), tpEmis (1), cNF (8) and the check digit cDV.

Validate a document against these rules: https://xmlvalid.com/validate
