Environment:
Skip to main content

Foreign counterparts and self-invoices

When you create an invoice via API, the request body is the FatturaPA format (JSON or XML): the fields you send are transmitted to the SDI and used to derive the counterpart. Because of this, some payload details โ€” irrelevant for an Italian counterpart โ€” become critical with foreign counterparts and with self-invoices.

This guide explains how to fill in those fields correctly.

IdFiscaleIVA: country and number must be separateโ€‹

In the FatturaPA format the VAT number is split into two distinct fields inside IdFiscaleIVA:

  • IdPaese โ†’ the 2-letter ISO country code (e.g. DE)
  • IdCodice โ†’ the number only, without the country prefix (e.g. 123456789)

The most common mistake with foreign counterparts is putting the VAT number with its prefix (DE123456789) into IdCodice, while IdPaese is also DE. The result is a duplicated country code.

IdPaeseIdCodiceHow it renders
โœ… CorrectDE123456789DE123456789
โŒ WrongDEDE123456789DEDE123456789
Why it is a problem

The Agenzia delle Entrate fiscal-drawer viewer concatenates IdPaese + IdCodice. If IdCodice already contains the prefix, the VAT number is shown doubled (e.g. DEDE123456789). An Italian VAT number is an 11-digit number that never starts with IT, so the problem only occurs with foreign counterparts whose VAT starts with the country code.

info

Rule of thumb: IdCodice must always contain the plain number, without the country code. The country code goes only in IdPaese.

vatNumber vs taxNumberโ€‹

Do not confuse the two identifiers:

  • vatNumber โ†’ IdFiscaleIVA (VAT number): this is the one that must be split into IdPaese + IdCodice as explained above.
  • taxNumber โ†’ CodiceFiscale: a separate field, a unique identifier with no country prefix.

Avoiding duplicate counterpartsโ€‹

When you create an invoice via API, Sibill recognises an already-existing counterpart only if all of these fields match those of a counterpart of the company:

company_id ยท country ยท tax_number ยท vat_number ยท company_name

This is an exact match on the combination of the five fields. As a result, if compared to a previous invoice even one of country, tax_number, vat_number or company_name changes โ€” e.g. the VAT written with or without the country prefix, the name with or without KFT/GmbH, or a different IdPaese โ€” the invoice is not linked to the existing counterpart and a new one is created.

How to avoid duplicates

Send the counterpart's identifying data consistently across all invoices:

  • IdPaese = the correct ISO country code of the counterpart (not IT for foreign counterparts).
  • IdCodice = VAT number without prefix, always in the same format.
  • Company name always written the same way.

Example: invoice to a foreign counterpart (JSON)โ€‹

Excerpt of the cessionario_committente (recipient) of an invoice to a private German company:

{
"fattura_elettronica_header": {
"dati_trasmissione": {
"formato_trasmissione": "FPR12",
"codice_destinatario": "XXXXXXX"
},
"cessionario_committente": {
"dati_anagrafici": {
"id_fiscale_iva": {
"id_paese": "DE",
"id_codice": "123456789"
},
"anagrafica": {
"denominazione": "Muster GmbH"
}
},
"sede": {
"indirizzo": "Musterstrasse 1",
"cap": "10115",
"comune": "Berlin",
"nazione": "DE"
}
}
}
}

The same excerpt in XML:

<FatturaElettronicaHeader>
<DatiTrasmissione>
<FormatoTrasmissione>FPR12</FormatoTrasmissione>
<CodiceDestinatario>XXXXXXX</CodiceDestinatario>
</DatiTrasmissione>
<CessionarioCommittente>
<DatiAnagrafici>
<IdFiscaleIVA>
<IdPaese>DE</IdPaese>
<IdCodice>123456789</IdCodice>
</IdFiscaleIVA>
<Anagrafica>
<Denominazione>Muster GmbH</Denominazione>
</Anagrafica>
</DatiAnagrafici>
<Sede>
<Indirizzo>Musterstrasse 1</Indirizzo>
<CAP>10115</CAP>
<Comune>Berlin</Comune>
<Nazione>DE</Nazione>
</Sede>
</CessionarioCommittente>
</FatturaElettronicaHeader>

Self-invoices (TipoDocumento)โ€‹

A self-invoice (or reverse-charge integration) is an invoice you issue to yourself to record a purchase โ€” typically from a foreign supplier or under reverse charge. It differs from a normal invoice by the TipoDocumento (tipo_documento) field in the document's general data.

The most common TipoDocumento codes for self-invoices are:

CodeTypical use
TD16Internal reverse-charge integration
TD17Integration/self-invoice for purchase of services from abroad
TD18Integration for intra-community purchase of goods
TD19Integration/self-invoice for purchase of goods under art. 17 c. 2
note

In addition to these, Sibill also treats codes TD20โ€“TD23 and TD27โ€“TD29 as self-invoices (and TD26 only when seller and buyer are the same party). For the complete, official list of TipoDocumento codes, refer to the Agenzia delle Entrate FatturaPA specification.

Who is the counterpart in a self-invoiceโ€‹

In a self-invoice the document is a purchase (direction RECEIVED) and the roles map as follows:

  • Your company is the cessionario/committente (the buyer).
  • The counterpart (the supplier) is the cedente/prestatore.

So make sure your company's data is in cessionario_committente and the supplier's data is in cedente_prestatore, applying here too the IdPaese/IdCodice rules seen above if the supplier is foreign.

In shortโ€‹

  • IdPaese = country code; IdCodice = number only (never DE123456789).
  • Private counterparts (including foreign): always send formato_trasmissione: "FPR12".
  • Consistent identifying data across all invoices to avoid duplicates.
  • Self-invoice = TipoDocumento TD16โ€“TD19 (and others): your company is the buyer, the counterpart is the seller.