> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invopop.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Italy archiving guide

> Preserve the invoices you exchange through SDI under Italy's certified archiving rules.

export const itArchiveDocumentWorkflow = {
  "name": "Archive document",
  "description": "Preserve a document under conservazione a norma",
  "schema": "bill/invoice",
  "steps": [{
    "id": "6023d8e0-7ab4-11f1-8f97-792526fe02d9",
    "name": "Archive document",
    "provider": "gov-it.archive.store",
    "summary": "Preserve the document and attach its receipt"
  }],
  "rescue": []
};

export const itRegisterPartyWorkflow = {
  "name": "Register party with SDI",
  "description": "Register a company to receive invoices and enable archiving",
  "schema": "org/party",
  "steps": [{
    "id": "d0a624c0-7ab3-11f1-bcdd-79d761bdaace",
    "name": "Register party with SDI",
    "provider": "gov-it.sdi.register",
    "summary": "Claim the company's fiscal ID for this workspace"
  }, {
    "id": "f19737f0-7ab3-11f1-bcdd-79d761bdaace",
    "name": "Register party for e-archiving",
    "provider": "gov-it.archive.register",
    "summary": "Enable certified preservation for this company"
  }],
  "rescue": []
};

export const WorkflowDiagram = ({workflow}) => {
  const stateColors = {
    processing: "yellow",
    sent: "blue",
    received: "blue",
    registered: "green",
    completed: "green",
    error: "red"
  };
  const StateChip = ({state, label}) => <Badge size="sm" color={stateColors[state] || "gray"} icon="square-small" iconType="solid">
      {label.charAt(0).toUpperCase() + label.slice(1)}
    </Badge>;
  const providerIcons = {
    "silo.state": "https://silo.invopop.com/images/status.svg",
    "silo.close": "https://silo.invopop.com/images/check-badge.svg",
    "silo.if": "https://assets.invopop.com/apps/silo/if.svg",
    "silo.folder": "https://silo.invopop.com/images/folder.svg",
    "silo.modify": "https://silo.invopop.com/images/modify.svg",
    "silo.correct": "https://silo.invopop.com/images/replace.svg",
    "silo.sleep": "https://assets.invopop.com/icons/sleep.svg",
    silo: "https://assets.invopop.com/apps/silo/icon.svg",
    "sequence.enumerate": "https://sequence.invopop.com/images/enumerate.svg",
    "transform.job.create": "https://transform.invopop.com/images/jobs.svg",
    webhook: "https://webhook.invopop.com/icon.svg",
    lookup: "https://lookup.invopop.com/icon.png",
    dropbox: "https://dropbox.invopop.com/icon.png",
    pdf: "https://pdf.invopop.com/file-pdf.svg",
    peppol: "https://assets.invopop.com/apps/peppol/icon.svg",
    ubl: "https://assets.invopop.com/apps/ubl/logo.svg",
    cii: "https://assets.invopop.com/apps/cii/logo.svg",
    "gov-dk": "https://assets.invopop.com/flags/dk.svg",
    "gov-fi": "https://assets.invopop.com/flags/fi.svg",
    "gov-fr": "https://assets.invopop.com/flags/fr.svg",
    "chorus-pro": "https://assets.invopop.com/apps/chroruspro/icon.svg",
    "gov-es": "https://assets.invopop.com/apps/gov-es/icon.svg",
    "gov-es.sii": "https://assets.invopop.com/apps/sii/icon.svg",
    "gov-es.ticketbai": "https://assets.invopop.com/apps/ticketbai/icon.svg",
    "gov-es.facturae": "https://assets.invopop.com/apps/facturae/icon.svg",
    verifactu: "https://assets.invopop.com/apps/verifactu/icon.svg",
    "gov-pl": "https://assets.invopop.com/apps/ksef/icon.svg",
    "gov-sa": "https://assets.invopop.com/apps/zatca/icon.svg",
    "gov-ar": "https://assets.invopop.com/apps/arca/icon.svg",
    "at-pt": "https://assets.invopop.com/apps/at-pt/icon.svg",
    "sat-mx": "https://assets.invopop.com/apps/sat-mexico/icon.svg",
    "sw-sapien": "https://assets.invopop.com/apps/sw-sapien/icon.svg",
    "sdi-it": "https://assets.invopop.com/apps/sdi-italy/icon.svg",
    "ticket-it": "https://assets.invopop.com/apps/agenzia-entrate/icon.svg",
    "nfe-br": "https://assets.invopop.com/apps/notas-fiscais-eletronicas-brazil/icon.svg",
    chargebee: "https://assets.invopop.com/apps/chargebee/icon.svg",
    stripe: "https://assets.invopop.com/apps/stripe/icon.svg",
    email: "https://assets.invopop.com/apps/email/icon.svg",
    cron: "https://assets.invopop.com/apps/cron/icon.svg",
    ilyda: "https://assets.invopop.com/apps/ilyda/icon.svg",
    invoicexpress: "https://assets.invopop.com/apps/invoicexpress/icon.svg",
    plemsi: "https://assets.invopop.com/flags/co.svg"
  };
  const iconFor = provider => {
    const parts = (provider || "").split(".");
    for (let i = parts.length; i > 0; i--) {
      const url = providerIcons[parts.slice(0, i).join(".")];
      if (url) return url;
    }
    return null;
  };
  const StepIcon = ({provider}) => {
    const url = iconFor(provider);
    return <span title={provider} className="flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-gray-950/10 bg-white dark:border-white/10 dark:bg-white/5">
        {url ? <img src={url} alt="" className="h-4 w-4" /> : null}
      </span>;
  };
  const renderSummary = summary => {
    const nodes = [];
    const re = /`([^`]+)`(\{[^}]*\})?/g;
    let last = 0;
    let m;
    let k = 0;
    while ((m = re.exec(summary)) !== null) {
      if (m.index > last) nodes.push(summary.slice(last, m.index));
      const attrs = m[2] || "";
      if (attrs.indexOf(".state") >= 0) {
        const state = (attrs.match(/\.state\s+\.([\w-]+)/) || [])[1] || m[1];
        nodes.push(<StateChip key={k++} state={state} label={m[1]} />);
      } else if (attrs) {
        nodes.push(<span key={k++} className="text-sm font-medium text-gray-700 dark:text-gray-300">
            {m[1]}
          </span>);
      } else {
        nodes.push(<code key={k++} className="text-sm rounded bg-gray-100 px-1 font-mono text-sm dark:bg-white/10">
            {m[1]}
          </code>);
      }
      last = m.index + m[0].length;
    }
    if (last < summary.length) nodes.push(summary.slice(last));
    return nodes;
  };
  const NoteRow = ({text}) => <div className="mt-4 mb-1 font-mono text-sm leading-5 text-gray-400 dark:text-gray-500">{"// " + text}</div>;
  const renderSteps = (steps, counter) => (steps || []).map(step => {
    counter.n += 1;
    const n = counter.n;
    const branches = (step.next || []).filter(b => b.steps && b.steps.length > 0);
    return <div key={step.id || "step-" + n}>
          {step.notes ? <NoteRow text={step.notes} /> : null}
          <div className="mt-2.5 flex items-center">
            <span className="absolute left-0 w-10 text-center font-mono text-sm text-gray-400 select-none dark:text-gray-500">
              {n}
            </span>
            <div className="flex min-w-0 flex-1 items-center gap-2 rounded-xl border border-gray-950/5 bg-white px-2 py-2 dark:border-white/10 dark:bg-gray-900">
              <StepIcon provider={step.provider} />
              <span className="text-sm shrink-0 font-medium text-gray-900 dark:text-gray-100">{step.name}</span>
              {step.summary ? <span className="text-sm min-w-0 truncate text-gray-500 dark:text-gray-400">{renderSummary(step.summary)}</span> : null}
            </div>
          </div>
          {branches.length > 0 ? <div className="ml-5 border-l border-gray-200 -my-1 py-1 pl-6 dark:border-white/10">
              {branches.map((branch, bi) => <div key={branch.code || branch.status || bi}>
                  <div className="mt-4">
                    <span className="rounded-md bg-gray-200/70 px-2 py-1 font-mono text-sm text-gray-600 dark:bg-white/10 dark:text-gray-300">
                      {branch.code || branch.status}
                    </span>
                  </div>
                  {renderSteps(branch.steps, counter)}
                </div>)}
            </div> : null}
        </div>;
  });
  const counter = {
    n: 0
  };
  const wf = workflow || ({});
  return <div className="not-prose relative my-5 rounded-2xl border border-gray-950/5 bg-gray-50 py-3 pr-4 pb-5 pl-12 dark:border-white/10 dark:bg-white/[0.03]">
      {renderSteps(wf.steps, counter)}
      {wf.rescue && wf.rescue.length > 0 ? <div className="mt-6 border-t border-dashed border-gray-300 dark:border-white/10">
          <NoteRow text="If any step fails" />
          {renderSteps(wf.rescue, counter)}
        </div> : null}
    </div>;
};

## Introduction

Sending an invoice through SDI is not the end of its legal life. Italian businesses must also preserve their electronic invoices long-term through a certified process known as *conservazione a norma* (also called *conservazione sostitutiva*). Keeping a copy of the XML on your own systems does not satisfy it: preservation has to follow the rules set by the Italian authorities, which in practice means an accredited provider.

Invopop handles this through [A-Cube](https://www.acubeapi.com), whose preservation service performs the certified archiving and issues a signed receipt for every preserved document. What gets preserved is the exact FatturaPA file exchanged with SDI, so the archived document matches what the tax authority saw.

Archiving covers both directions. The rules apply to the invoices you issue and the invoices you receive, and both are preserved the same way — only the metadata differs, recording each document as issued or received.

| -                        | Sandbox                | Live                   |
| ------------------------ | ---------------------- | ---------------------- |
| **Preservation service** | Test environment       | Production             |
| **Legal validity**       | None, for testing only | Certified preservation |

## Setup

Archiving takes two things: the company has to be enabled for preservation, and each document has to be archived.

<Steps>
  <Step title="Enable the company for preservation">
    Before any of its invoices can be preserved, a company must be registered with the preservation service. The **Register party for e-archiving** step does this, and the registration workflow from the [receiving invoices](/guides/it-sdi-reception) guide already includes it — one registration covers both directions.

    <Card iconType="duotone" title="Italy register party workflow" icon="code-branch" href="https://console.invopop.com/redirect/workflows/new?template=it-italy-register-party" horizontal>
      Add to my workspace →
    </Card>

    <Tabs>
      <Tab title="Workflow">
        <WorkflowDiagram workflow={itRegisterPartyWorkflow} />
      </Tab>

      <Tab title="Code">
        ```json Example register party workflow theme={"system"}
        {
          "name": "Register party with SDI",
          "description": "Register a company to receive invoices and enable archiving",
          "schema": "org/party",
          "steps": [
            {
              "id": "d0a624c0-7ab3-11f1-bcdd-79d761bdaace",
              "name": "Register party with SDI",
              "provider": "gov-it.sdi.register",
              "summary": "Claim the company's fiscal ID for this workspace"
            },
            {
              "id": "f19737f0-7ab3-11f1-bcdd-79d761bdaace",
              "name": "Register party for e-archiving",
              "provider": "gov-it.archive.register",
              "summary": "Enable certified preservation for this company"
            }
          ],
          "rescue": []
        }
        ```
      </Tab>
    </Tabs>

    The step reads the company's Italian tax ID from the party, so the party must carry one. Re-running it on an already-enabled company completes without doing anything.
  </Step>

  <Step title="Archive the documents">
    Add the **Archive document** step to your invoice workflows, after the step that exchanges the document with SDI — after **Send invoice to SDI** when issuing, after **Import invoice from SDI** when receiving. It preserves the FatturaPA file that step put on the entry, so it has nothing to work with if it runs first.

    You can equally run it on its own, as a separate workflow over invoices that are already exchanged:

    <Card iconType="duotone" title="Italy archive document workflow" icon="code-branch" href="https://console.invopop.com/redirect/workflows/new?template=it-italy-archive-document" horizontal>
      Add to my workspace →
    </Card>

    <Tabs>
      <Tab title="Workflow">
        <WorkflowDiagram workflow={itArchiveDocumentWorkflow} />
      </Tab>

      <Tab title="Code">
        ```json Example archive document workflow theme={"system"}
        {
          "name": "Archive document",
          "description": "Preserve a document under conservazione a norma",
          "schema": "bill/invoice",
          "steps": [
            {
              "id": "6023d8e0-7ab4-11f1-8f97-792526fe02d9",
              "name": "Archive document",
              "provider": "gov-it.archive.store",
              "summary": "Preserve the document and attach its receipt"
            }
          ],
          "rescue": []
        }
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## How the archive step works

The step needs no configuration. It works out whether the document is issued or received from the file it finds on the entry — an invoice that arrived from SDI is preserved as received, anything else as issued — and records the right party as the document's owner either way.

When it runs, it:

1. Uploads the exact FatturaPA bytes exchanged with SDI.
2. Sends the preservation metadata built from the GOBL invoice.
3. Records the preservation service's identifier for the document as an indexed `archive-uuid` field on the entry, so it can be traced later.
4. Waits for the service to confirm the document is preserved and its receipt is ready.
5. Attaches the receipt to the entry in both formats the service provides.

Preservation is asynchronous, so the step stays `Queued` while it waits, then completes with `OK`. The document itself is usually preserved within seconds, though the receipt can take a few minutes to become available. It is safe to retry: re-running it on an already-archived invoice completes without uploading again or duplicating attachments.

The step returns:

* `OK` when the invoice was preserved and its receipt stored
* `KO` when there is no FatturaPA file on the entry — the invoice was never exchanged with SDI, or the step ran before the send or import step

## What ends up on the entry

| Attachment            | What it is                                        |
| --------------------- | ------------------------------------------------- |
| `archive-receipt.pdf` | The preservation receipt, readable                |
| `archive-receipt.xml` | The preservation receipt as a signed XML document |

| Metadata       | What it is                                                                                                    |
| -------------- | ------------------------------------------------------------------------------------------------------------- |
| `archive-uuid` | The preservation service's identifier for the archived document. Indexed, so the entry can be looked up by it |

## Troubleshooting

| Symptom                                           | Cause                                                                                                                                                            |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| The step fails saying no FatturaPA file was found | It ran before the send or import step, or on an invoice never exchanged with SDI. Archiving preserves the transmitted file, so the exchange has to happen first. |
| Registering the company fails on its tax ID       | The party has no Italian tax ID. Preservation is only available for Italian companies.                                                                           |
| The step stays `Queued` longer than expected      | The receipt is not ready yet. The step keeps checking and completes on its own once it is.                                                                       |

## FAQ

<AccordionGroup>
  <Accordion title="How does certified archiving (conservazione a norma) work with Invopop?">
    Add the **Archive document** step to your workflows, after the step that exchanges the document with SDI. It uploads the exact FatturaPA file, waits for the preservation service to confirm the document is preserved, and attaches the signed receipt to the entry. See the [archiving guide](/guides/it-sdi-archiving) for the full setup.
  </Accordion>

  <Accordion title="Do received invoices need to be archived too?">
    Yes. Italian preservation rules cover both the invoices you issue and the ones you receive, and both are preserved the same way — add the **Archive document** step after the import step in your receiving workflow.
  </Accordion>

  <Accordion title="What happens to archived invoices when I unregister a company?">
    Nothing — unregistering only stops receiving. Invoices already preserved under *conservazione a norma* stay preserved, as the law requires.
  </Accordion>
</AccordionGroup>

More available in our [Italy FAQ](/faq/italy) section

***

<AccordionGroup>
  <Accordion title="🇮🇹 Invopop resources for Italy">
    |            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
    | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | Compliance | <Icon icon="https://assets.invopop.com/flags/it.svg" /> [Invoicing compliance in Italy](/compliance/italy)<br /> <Icon icon="timeline" /> [Compliance timeline](/timelines/italy)                                                                                                                                                                                                                                                                                                                                                             |
    | Apps       | <Icon icon="https://assets.invopop.com/flags/it.svg" /> [Italy](/apps/italy)<br /><Icon icon="https://assets.invopop.com/apps/sdi-italy/icon.svg" /> [SDI Italy](/apps/sdi-italy)<br /><Icon icon="https://assets.invopop.com/apps/agenzia-entrate/icon.svg" /> [Smart Receipts Italy](/apps/smart-receipts-italy)                                                                                                                                                                                                                            |
    | Guides     | <Icon icon="book" /> SDI — [Issuing invoices](/guides/it-sdi-invoicing) · [Status](/guides/it-sdi-status) · [Receiving invoices](/guides/it-sdi-reception) · [Archiving](/guides/it-sdi-archiving)<br /><Icon icon="book" /> [SDI sending guide (legacy)](/guides/it-sdi-sending)<br /><Icon icon="book" /> [SDI receiving guide (legacy)](/guides/it-sdi-receiving)<br /><Icon icon="book" /> [Smart Receipts supplier registration](/guides/it-ticket-supplier)<br /><Icon icon="book" /> [Smart Receipts issuing guide](/guides/it-ticket) |
    | FAQ        | <Icon icon="square-question" /> [Italy FAQ](/faq/italy)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
    | GOBL       | <Icon icon="https://assets.invopop.com/icons/gobl.svg" />  [Italy Tax Regime](https://docs.gobl.org/regimes/it)<br /> <Icon icon="https://assets.invopop.com/icons/gobl.svg" /> [Italy SDI FatturaPA Addon](https://docs.gobl.org/addons/it-sdi-v1)<br /> <Icon icon="https://assets.invopop.com/icons/gobl.svg" /> [Italy AdE Ticket Addon](https://docs.gobl.org/addons/it-ticket-v1)                                                                                                                                                       |
    | GitHub     | <Icon icon="github" /> [gobl.fatturapa](https://github.com/invopop/gobl.fatturapa)                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
  </Accordion>
</AccordionGroup>

<Card title="Participate in our community" icon="forumbee" href="https://community.invopop.com" arrow="true" horizontal>
  Ask and answer questions about invoicing in Italy →
</Card>
