FatturaPA (Italy / SdI)
00311
CodiceDestinatario non valido
What it means
The recipient code (DatiTrasmissione/CodiceDestinatario) is not valid. It must be 6 alphanumeric characters for transmissions to a PA (FormatoTrasmissione=FPA12) or 7 for private recipients (FPR12). '0000000' (7 zeros) is the wildcard used when delivery is via PEC.
How to fix it
Use the 6-char IPA code for a PA recipient, or the 7-char SDI channel code the buyer provided. If you don't have it and the buyer has a PEC, set CodiceDestinatario to 0000000 and fill PECDestinatario (FPR12 only).
Example
<CodiceDestinatario>ABC1234</CodiceDestinatario> <!-- or, with PEC --> <CodiceDestinatario>0000000</CodiceDestinatario>
Catch this before it reaches the SdI:
# CLI
npx @eleata/validate-einvoice validate invoice.xml --format fatturapa
# GitHub Action — fail the build on any invalid invoice
- uses: hernaninverso/validate-einvoice-action@v1
with:
files: invoices/**/*.xml
api-key: ${{ secrets.EINVOICE_API_KEY }}