build_transmission_header
Builds the validated DatiTrasmissione block for FatturaPA invoices, checking format and recipient code to produce SDI-ready header data. Returns XML-ready DatiTrasmissione or an error.
Instructions
Build the DatiTrasmissione block required in every FatturaPA header.
Use this as step 3 in the invoice generation workflow, after generate_progressivo_invio() and before validate_cedente_prestatore(). Use lookup_codice_destinatario() first to confirm the recipient code format.
Validates: formato_trasmissione must be 'FPA12' or 'FPR12'; progressivo_invio must be 1–10 alphanumeric characters; pec_destinatario is required when codice_destinatario is '0000000'.
On success returns {'DatiTrasmissione': {...}} ready to pass to generate_fattura_xml(). On failure returns {'error': ''} — do not proceed to XML generation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id_paese | Yes | Two-letter ISO 3166-1 country code of the transmitter (e.g. 'IT'). Usually 'IT' for Italian entities. | |
| id_codice | Yes | Tax identifier of the transmitter: Partita IVA (11 digits) for Italian entities, or foreign tax ID (max 28 chars) for cross-border. | |
| pec_destinatario | No | PEC (certified email) address of the recipient. Required only when codice_destinatario is '0000000'. | |
| progressivo_invio | Yes | Unique sequential send identifier, max 10 alphanumeric characters. Use generate_progressivo_invio() to obtain one automatically. | |
| codice_destinatario | Yes | SDI recipient code: 6-char for PA offices (IPA code, FPA12), 7-char for B2B intermediaries (FPR12), or '0000000' (7 zeros) for PEC routing. Use lookup_codice_destinatario() to validate the code first. | |
| formato_trasmissione | Yes | Transmission format: 'FPA12' for invoices to Public Administration (PA), 'FPR12' for invoices to private parties (B2B / B2C). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||