# Italy PA e-Invoicing Codes – Codice Univoco Ufficio (SDI) (`nobler_zirconia/italy-pa-einvoice-codes`) Actor

Find the Codice Univoco Ufficio (SDI destination code) needed to e-invoice any Italian public administration. Look up by tax code, IPA code, office code, name or location. 56,000+ invoicing offices with PEC, address and PEPPOL ID, from official AgID IPA open data (CC BY 4.0).

- **URL**: https://apify.com/nobler_zirconia/italy-pa-einvoice-codes.md
- **Developed by:** [Federico Rossi](https://apify.com/nobler_zirconia) (community)
- **Categories:** Business, Developer tools, Open source
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Italy PA e-Invoicing Codes – Codice Univoco Ufficio (SDI)

Every e-invoice to an Italian public administration goes through the SDI (Sistema di Interscambio) and carries the **Codice Univoco Ufficio**, the 6-character code of the receiving office. A wrong or inactive code can lead to rejection or misrouting, and to late payment.

This Actor **verifies codes in bulk** and finds the **candidate invoicing offices** of public bodies in the official **IPA registry** (AgID): 56,000+ offices of ~23,000 bodies, with the tax code to invoice, start date, PEPPOL ID, PEC and address. It reads the official IPA open-data API (**CC BY 4.0**) live at every run.

> **Limits of verification.** IPA tells you that an office exists and can receive e-invoices. It does **not** tell you which office a given invoice must go to. A registered code isn't necessarily the right office for your invoice: follow your purchase order or contract. Every result is a `CANDIDATE_OFFICE` and carries `requiresBillingInstructionConfirmation: true`.

*Fatturazione elettronica PA: verifica del codice univoco ufficio (codice destinatario PA per FatturaPA) e ricerca degli uffici di fatturazione di un ente.*

### Use cases

- **Accounting / billing teams**: check the codes in your customer master data before issuing FatturaPA invoices.
- **ERP & billing software**: validate `CodiceDestinatario` automatically via API or schedules.
- **Commercialisti / CAF**: verify a client's list of PA customers in one run.
- **Discovery**: list the invoicing offices of a body, a comune or a region.

### How it works

**Exact lookup** (any `officeCodes`, `fiscalCodes` or `ipaCodes`). Search, location and date filters are ignored (a warning is logged). Office codes are verified first. Every requested code gets a **free status row** (`resultType: "LOOKUP_STATUS"`): `FOUND`, `FOUND_NOT_RETURNED` (exists, but your Max results or maximum cost stopped it), `NOT_FOUND` (the official query completed with no match) or `INVALID_FORMAT_NOT_FOUND`. Codes are trimmed and upper-cased, and the `IT` prefix is removed from tax codes. The `VERIFICATION_REPORT` record has the counts. A code is never reported as missing unless it was actually checked.

**Search** (no codes): words matched as word-prefixes against **body name + office name combined** (`comune torino ragioneria` can match body "Comune di Torino" + office "Ragioneria"), plus regions, provinces, comuni and `updatedSince`.

> ⚠️ A tax-code or IPA-code lookup returns **every** invoicing office of the body. The City of Milan has 100+, and each one is a billed result. Keep *Max results* low, or use *central office only*.

Each candidate office has a `matchStatus`, computed against the **full IPA registry**, not just the returned rows:

| matchStatus | meaning |
|---|---|
| `EXACT_CODE_FOUND` | you asked for this office code and it exists |
| `BODY_HAS_ONE_REGISTERED_OFFICE` | the body has exactly one invoicing office in IPA (`bodyOfficeCount = 1`) |
| `MULTIPLE_REGISTERED_OFFICES` | the body has several (`bodyOfficeCount`); pick the one in your order/contract |

### Example tasks

Verify codes (UFRECE is the prefilled demo; ZZZZZZ shows a free NOT_FOUND status row):

```json
{ "officeCodes": ["UFRECE", "ZZZZZZ"] }
```

Central invoicing office of every local health authority in Piedmont:

```json
{ "search": "sanitaria locale", "regions": ["Piemonte"], "centralOfficeOnly": true }
```

Offices located in one comune:

```json
{ "comuni": ["Bergamo"], "maxResults": 200 }
```

#### Use it from code

**curl** (runs the Actor and returns the results in one call):

```bash
curl -X POST "https://api.apify.com/v2/acts/nobler_zirconia~italy-pa-einvoice-codes/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"officeCodes": ["UFRECE"]}'
```

**JavaScript** (`npm i apify-client`):

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('nobler_zirconia/italy-pa-einvoice-codes').call({"officeCodes": ["UFRECE"]});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient
client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("nobler_zirconia/italy-pa-einvoice-codes").call(run_input={"officeCodes": ["UFRECE"]})
items = client.dataset(run["defaultDatasetId"]).list_items().items
```

You can also use it from Make, Zapier, n8n, schedules, webhooks or the Apify MCP server for AI agents.

### Output

A candidate office (billed):

```json
{
  "resultType": "CANDIDATE_OFFICE",
  "matchStatus": "EXACT_CODE_FOUND",
  "bodyOfficeCount": 1,
  "bodyOfficeCountComplete": true,
  "requiresBillingInstructionConfirmation": true,
  "officeCode": "UFRECE",
  "officeName": "Uff_eFatturaPA",
  "isCentralOffice": true,
  "bodyName": "Azienda sanitaria Locale - ASL - Asti",
  "bodyFiscalCode": "01120620057",
  "ipaCode": "as_asti",
  "bodyCategory": "Aziende Sanitarie Locali",
  "invoiceFiscalCode": "01120620057",
  "einvoicingStartDate": "2015-03-31",
  "startDateReached": true,
  "fiscalCodeVerifiedOn": "2015-03-26",
  "peppolId": null,
  "primaryPec": "protocollo@pec.asl.at.it",
  "pec": [
    "protocollo@pec.asl.at.it"
  ],
  "otherEmails": [],
  "phone": null,
  "address": "Via Conte Verde, 125",
  "postalCode": "14100",
  "comune": "Asti",
  "comuneIstatCode": "005005",
  "province": "AT",
  "region": "Piemonte",
  "lastUpdated": "2025-03-17",
  "source": "IPA – Unità organizzative che ricevono fatture elettroniche (AgID)",
  "sourceUrl": "https://indicepa.gov.it/ipa-dati/dataset/unita-organizzative-che-ricevono-fatture-elettroniche",
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "attribution": "Fonte: IPA – AgID (CC BY 4.0); comuni: ISTAT (CC BY 4.0). Not endorsed by AgID or the Italian government.",
  "retrievedAt": "2026-10-15T09:28:15.009Z"
}
```

A status row for a code that does not exist (free):

```json
{
  "resultType": "LOOKUP_STATUS",
  "lookupType": "officeCode",
  "requestedValue": "ZZZZZZ",
  "validFormat": true,
  "status": "NOT_FOUND",
  "checked": true,
  "billable": false,
  "source": "IPA – Unità organizzative che ricevono fatture elettroniche (AgID)",
  "sourceUrl": "https://indicepa.gov.it/ipa-dati/dataset/unita-organizzative-che-ricevono-fatture-elettroniche",
  "license": "CC BY 4.0",
  "licenseUrl": "https://creativecommons.org/licenses/by/4.0/",
  "attribution": "Fonte: IPA – AgID (CC BY 4.0); comuni: ISTAT (CC BY 4.0). Not endorsed by AgID or the Italian government.",
  "retrievedAt": "2026-10-15T09:28:15.009Z"
}
```

| Field | Description |
|---|---|
| `resultType`, `matchStatus`, `bodyOfficeCount`, `bodyOfficeCountComplete` | See the table above. The count comes from the full registry. |
| `requiresBillingInstructionConfirmation` | Always `true`: confirm the destination with your order/contract |
| `officeCode` | **Codice Univoco Ufficio**, the value for `CodiceDestinatario` in FatturaPA |
| `officeName`, `isCentralOffice` | Office name; `true` for the "Uff_eFatturaPA" office |
| `bodyName`, `bodyFiscalCode`, `ipaCode`, `bodyCategory` | The public body |
| `invoiceFiscalCode` | Tax code to use for this office (can differ from the body's) |
| `einvoicingStartDate`, `startDateReached` | Start date of e-invoice reception, and whether that date has passed. IPA has no end date, so this does **not** prove the office is still active. |
| `fiscalCodeVerifiedOn`, `peppolId` | Verification date of the tax code; PEPPOL ID if any |
| `primaryPec`, `pec`, `otherEmails`, `phone`, `address`, `postalCode`, `comune`, `comuneIstatCode`, `province`, `region` | Contacts and location |
| `lastUpdated` | Last update in IPA |
| `source`, `sourceUrl`, `license`, `licenseUrl`, `attribution`, `retrievedAt` | Provenance on every item: data source, licence (CC BY 4.0), required attribution, and the UTC time the data was retrieved |

`SUMMARY` record: `complete`, `truncatedReason`, `recordsScanned`, `billableResults`, `datasetItemsWritten`, lookup counts.

### Pricing

**$0.005 per candidate office returned** (pay per event `result`). Status rows are free. Verifying 100 codes costs about $0.50. Zero matches cost nothing beyond Apify's start event. If the source fails, the run fails.

### Data source, licence and privacy

- Source: [IPA open data – AgID](https://indicepa.gov.it/ipa-dati/), dataset *Unità organizzative che ricevono fatture elettroniche*, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Attribution: "Fonte: IPA – AgID". Municipality data: ISTAT, CC BY 4.0.
- Institutional data only; names of officials are not included.

### FAQ

**Codice Univoco Ufficio vs private "codice destinatario"?** Private companies receive invoices through a 7-character recipient code or a PEC. Public administrations use the 6-character Codice Univoco Ufficio published in IPA. A *public body* (identified by its IPA code and codice fiscale) can have many *invoicing offices*, each with its own code.

**Which office should I invoice?** The one in your order or contract. The central `Uff_eFatturaPA` office is the usual starting point; confirm it with the body. *Central office only* returns nothing for bodies without such an office.

**Companion Actor:** [Italy IPA Directory – Public Bodies, PEC & Tax Codes](https://apify.com/nobler_zirconia/italy-pa-directory).

### Disclaimer

This Actor is an independent tool. It is **not affiliated with, endorsed by or sponsored by** AgID, the Agenzia delle Entrate or any Italian government body. The data is reproduced from official open data under its licence. It is provided "as is", may contain errors or delays from the source, and is not legal or fiscal advice.

# Actor input Schema

## `officeCodes` (type: `array`):

6-character SDI codes, e.g. UFRECE. Trimmed and upper-cased. Each code gets a free status row: FOUND, FOUND_NOT_RETURNED (cap reached), NOT_FOUND or INVALID_FORMAT_NOT_FOUND. The prefilled example returns exactly 1 office.

## `fiscalCodes` (type: `array`):

Returns EVERY invoicing office of each body (the City of Milan has 100+). Each office is one billed result, so keep Max results low or turn on central office only.

## `ipaCodes` (type: `array`):

e.g. c_f205, r_lazio. Returns every invoicing office of the body.

## `search` (type: `string`):

Each word must match the beginning of a word in the body name + office name combined, e.g. "sanitaria locale", "comune torino ragioneria".

## `regions` (type: `array`):

Empty = all of Italy.

## `provinces` (type: `array`):

e.g. MI, TO.

## `comuni` (type: `array`):

Names, ISTAT or cadastral codes.

## `updatedSince` (type: `string`):

Only offices whose IPA record was updated on/after this date. Selects by date; it does not report which fields changed.

## `centralOfficeOnly` (type: `boolean`):

Keep only offices named 'Uff_eFatturaPA'. Bodies without such an office return nothing. The central office is the usual starting point, not a guaranteed destination.

## `maxResults` (type: `integer`):

Maximum offices returned and billed. Lookup status rows are free and not counted.

## Actor input object example

```json
{
  "officeCodes": [
    "UFRECE"
  ],
  "centralOfficeOnly": false,
  "maxResults": 10
}
```

# Actor output Schema

## `results` (type: `string`):

Default dataset, overview table view. Each item includes source, licence, attribution and retrievedAt.

## `summary` (type: `string`):

SUMMARY record: result count, warnings, finish time.

## `notFound` (type: `string`):

NOT_FOUND record (only written when some requested codes were not found).

## `lookupStatus` (type: `string`):

Free LOOKUP_STATUS rows, one per requested code.

## `verificationReport` (type: `string`):

VERIFICATION_REPORT record with counts per status.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "officeCodes": [
        "UFRECE"
    ],
    "maxResults": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("nobler_zirconia/italy-pa-einvoice-codes").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "officeCodes": ["UFRECE"],
    "maxResults": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("nobler_zirconia/italy-pa-einvoice-codes").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "officeCodes": [
    "UFRECE"
  ],
  "maxResults": 10
}' |
apify call nobler_zirconia/italy-pa-einvoice-codes --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nobler_zirconia/italy-pa-einvoice-codes"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/HtAyZgdIRDb7zfNBg/builds/Hni4jjFNq3nsluTbj/openapi.json
