# Certified invoicing in Portugal: a guide for developers

> Markdown edition of https://api.fiz.co/docs/portugal. Português: https://api.fiz.co/docs/portugal.md?lang=pt. Index: https://api.fiz.co/llms.txt

What makes an invoice valid in Portugal, what the tax authority (AT) expects from the software that issues it, and where each requirement lives in the FIZ API. Read it before you build invoicing into a store, an ERP or a SaaS.

## What certified software does

In Portugal an invoice is a fiscal document, not just a PDF. Issued through the FIZ API, it comes from FIZ, [invoicing software certified by the AT](https://api.fiz.co/docs/glossary#certified-software) (certificate no. 3041), which numbers it in a registered series, signs it, and keeps it unchanged: an issued document cannot be edited or deleted, only corrected by another document. Which businesses must invoice with certified software, and which may use other means, is set by law; this guide covers issuing from code through FIZ.

A PDF your own code generates is therefore not a certified invoice. With the FIZ API your system sends the data and FIZ, the certified software, issues the document: it assigns the number and the [ATCUD](https://api.fiz.co/docs/glossary#atcud), signs it, prints the [QR code](https://api.fiz.co/docs/glossary#qr-code) and, with the company’s AT connection on, reports it to the [AT](https://api.fiz.co/docs/glossary#at) (see [Reporting to the AT](#reporting-to-the-at-e-fatura)).

> You do not need your own certification to invoice through the API: your system never issues the document itself. An invoice starts as a **draft**, with no fiscal effect, and becomes fiscal on the issue call. A few calls are fiscal at once: a credit note is issued immediately unless you send `issue: false`, recording a payment issues the receipt, and a recurring schedule issues on its own.

## What every issued document carries

| Requirement | What it is | In the API |
| --- | --- | --- |
| [Series and number](https://api.fiz.co/docs/glossary#series) | Documents are numbered in sequence within a series, and each series is registered with the AT, which returns its validation code. | `GET /series`, `seriesId` on create (default series otherwise); `number` in the response, e.g. `FR FIZ2026/336` |
| [ATCUD](https://api.fiz.co/docs/glossary#atcud) | The document’s unique code: the series validation code and the document’s sequential number. | `atcud` in the issue response; `null` on a draft |
| [QR code](https://api.fiz.co/docs/glossary#qr-code) | The fiscal QR code with the document’s data, printed on it. | On the PDF (`GET /invoices/{id}/pdf`); `qrCode` in `GET /invoices/{id}` |
| [Signature and certification number](https://api.fiz.co/docs/glossary#certified-software) | The certified software signs each document; the printout shows part of that signature and the software’s certification number. | Done by FIZ on issue |
| [Customer NIF](https://api.fiz.co/docs/glossary#nif) | The buyer’s tax number. A document without one is issued to a final consumer. | `taxpayerNumber` on the customer |
| [VAT and exemption reason](https://api.fiz.co/docs/glossary#vat-exemption) | Each line has its VAT rate; a line without VAT states the legal reason for the exemption. | `vatRate`, `taxRate` and `vatExemptionReason` (e.g. `M01`) on items |

## Reporting to the AT (e-Fatura)

The AT receives the invoices a company issues, and they appear in [e-Fatura](https://api.fiz.co/docs/glossary#e-fatura) for the issuer and the buyer. Software reports them document by document through the AT’s webservice, or the company submits them in its monthly [SAF-T (PT)](https://api.fiz.co/docs/glossary#saf-t) file.

-   **Through FIZ.** With the company’s AT connection set up in FIZ (the credentials of an [AT sub-user](https://api.fiz.co/docs/glossary#at-subuser)), FIZ reports each issued invoice. The document shows the result in `syncWithAt`: its `status`, and the AT’s code and message when the AT refuses it.
-   **By monthly SAF-T.** With an API key, a company that submits the SAF-T itself issues normally; its documents carry no `syncWithAt` status, because that status records only what FIZ sends. Export the file with `GET /exports/saft-pt`. A registered partner app (OAuth) cannot issue this way: it needs the AT sync on and verified AT credentials.
-   **Receipts** ([recibos](https://api.fiz.co/docs/glossary#receipt)) are not reported to the AT, so they never have a `syncWithAt` status.
-   **Transport documents** ([guias de transporte](https://api.fiz.co/docs/glossary#transport-document)) are reported when issued, before the goods move, and receive the AT’s code (`atDocCodeID`).

Before issuing, `GET /company` answers whether the company is ready: `readiness.reasons` lists what is missing, such as `AT_CREDENTIALS_REQUIRED` or `SERIES_REQUIRED`, with the page in FIZ that fixes it. A registered app also gets `AT_SYNC_REQUIRED` while the company’s AT sync is off.

## Which document to issue

| Document | When | In the API |
| --- | --- | --- |
| [Fatura (invoice)](https://api.fiz.co/docs/glossary#invoice) | A sale or service paid later. | `POST /invoices` with `type: INVOICE`; record the payment later with `POST /invoices/{id}/pay`, which issues a receipt |
| [Fatura-recibo (invoice-receipt)](https://api.fiz.co/docs/glossary#invoice-receipt) | Paid at the moment of the sale, such as an online checkout or a card payment. | `type: INVOICE_RECEIPT` |
| [Fatura simplificada](https://api.fiz.co/docs/glossary#simplified-invoice) | Small sales, within the limits the VAT Code sets. | `type: SIMPLIFIED_INVOICE` |
| [Nota de crédito (credit note)](https://api.fiz.co/docs/glossary#credit-note) | Reduces or reverses an issued invoice: a return, a discount after the fact, a billing error. | `POST /invoices/credit-notes`, whole or by line; issued at once unless `issue: false` |
| [Guia de transporte](https://api.fiz.co/docs/glossary#transport-document) | Goods in transit, before the invoice or without one. | `POST /transport-documents` |
| [Pró-forma](https://api.fiz.co/docs/glossary#pro-forma) | A quote before the invoice. A commercial document: never reported to the AT. | `POST /proposals` |

Billing the same customer every month? A [recurring invoice](https://api.fiz.co/docs/api/recurring-invoices) (`POST /invoices/scheduled`) issues on its own schedule.

## Corrections: nothing is edited after issue

A draft can change as often as needed (`PATCH /invoices/{id}`) and be deleted. Once issued, the document is final:

-   **Wrong amount or a return:** issue a [credit note](https://api.fiz.co/docs/glossary#credit-note) for the whole invoice or for some lines.
-   **A document that should not exist** (the wrong customer, say): cancel it with a reason, `POST /invoices/{id}/cancel`, and issue the right one. The reason goes to the AT in the SAF-T. A document that already has issued credit notes cannot be cancelled.

To make sure the document you issue is the one you checked, send the draft’s `updatedAt` as `expectedUpdatedAt` in the issue body: a draft changed since is refused instead of issued.

## Checklist before going live

1.  The company is ready: `GET /company` answers `readiness.ready: true`. With an API key that takes a registered series, and the AT connection unless the company files its SAF-T by hand; a registered partner app also needs the AT sync on and verified AT credentials.
2.  You rehearsed the whole flow in the **sandbox**: a test copy of the company on the AT test environment, with `fiz_test_` keys, the same URLs and requests, and no fiscal effect.
3.  Every write sends an `Idempotency-Key`, such as your order or payment id. A retry with the same key returns the stored first response once that request has finished. While it is still running, the API answers `409` with `Retry-After`: retry with the same key. When its outcome is unknown, the API answers `409` too: check whether it took effect, then use a new key. Keys are kept 30 days, so before retrying anything older (a stuck queue, say), check the first attempt. Details in the [Idempotency section of the API overview](https://api.fiz.co/docs/api/overview#idempotency).
4.  Issuing sends `expectedUpdatedAt`, and your system stores the returned `id`, `number` and `atcud`.
5.  The customer receives the PDF (`GET /invoices/{id}/pdf`).

The VAT rate and any exemption on a line are the company’s tax decision. FIZ checks that a document is consistent before issuing it, but that is not tax advice.

- [Quickstart: your first invoice from code](https://api.fiz.co/docs/quickstart)
- [Build an app for many companies](https://api.fiz.co/docs/apps.md)

## Questions developers ask

### Can I issue invoices for many companies?

Yes. An API key issues for one company. Software that invoices for its customers registers an app and asks each company for consent with OAuth: see [Build an app](https://api.fiz.co/docs/apps.md).

### Is there a test environment?

Yes: the sandbox. Documents go to the AT test environment only and the PDFs are marked as test documents.

### Which languages can I use?

Any language that speaks HTTP and JSON. There are official [libraries for TypeScript, Python and PHP](https://api.fiz.co/docs/libraries); for other languages, generate a client from the [OpenAPI document](https://api.fiz.co/-json).

### Can an AI assistant issue invoices?

The [FIZ MCP connector](https://api.fiz.co/docs/mcp.md) lets Claude or ChatGPT prepare drafts and issue each one only after the user confirms it.
