Certified invoicing
Certified invoicing in Portugal: a guide for developers
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 (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, signs it, prints the QR code and, with the company’s AT connection on, reports it to the AT (see Reporting to the AT).
What every issued document carries
| Requirement | What it is | In the API |
|---|---|---|
| Series and number | 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 | 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 | 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 | 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 | The buyer’s tax number. A document without one is issued to a final consumer. | taxpayerNumber on the customer |
| VAT and exemption reason | 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 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) file.
- Through FIZ. With the company’s AT connection set up in FIZ (the credentials of an AT sub-user), FIZ reports each issued invoice. The document shows the result in
syncWithAt: itsstatus, 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
syncWithAtstatus, because that status records only what FIZ sends. Export the file withGET /exports/saft-pt. A registered partner app (OAuth) cannot issue this way: it needs the AT sync on and verified AT credentials. - Receipts (recibos) are not reported to the AT, so they never have a
syncWithAtstatus. - Transport documents (guias de transporte) 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) | 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) | Paid at the moment of the sale, such as an online checkout or a card payment. | type: INVOICE_RECEIPT |
| Fatura simplificada | Small sales, within the limits the VAT Code sets. | type: SIMPLIFIED_INVOICE |
| Nota de crédito (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 | Goods in transit, before the invoice or without one. | POST /transport-documents |
| Pró-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 (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 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
- The company is ready:
GET /companyanswersreadiness.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. - 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. - 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 answers409withRetry-After: retry with the same key. When its outcome is unknown, the API answers409too: 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. - Issuing sends
expectedUpdatedAt, and your system stores the returnedid,numberandatcud. - 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.
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.
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; for other languages, generate a client from the OpenAPI document.
Can an AI assistant issue invoices?
The FIZ MCP connector lets Claude or ChatGPT prepare drafts and issue each one only after the user confirms it.