API reference

Invoices

Invoices, invoice-receipts, simplified invoices, receipts and credit notes: drafts, issuing, payments, cancellation and PDFs. 10 operations.

List invoices

GET /invoices

Returns a paginated, filterable list of invoices. By default returns 20 invoices starting at offset 0.

Authentication: an API key (x-api-key) or an OAuth access token.

Parameters

NameInTypeDescription
offsetquerynumberNumber of records to skip (offset)
limitquerynumberMaximum number of records to return
sortquerystringSort field and order (e.g. date:desc, number:asc)
searchquerystringGlobal search term (number, customer, etc.)
documentTypequerystringFilter by document type
One of: CREDIT_NOTE, DEBIT_NOTE, INVOICE, INVOICE_RECEIPT, RECEIPT, SIMPLIFIED_INVOICE
statusquerystringFilter by status
One of: CANCELED, CREATED, DRAFT, ISSUED, PAID, PROCESSING, SCHEDULED
aggregatedStatusquerystringFilter by aggregated status
One of: DRAFT, OVERDUE, PAID, PENDING, SCHEDULED, UNPAID
datequerystringFilter by a specific date (ISO 8601 with timezone)
dueDatequerystringFilter by a specific due date (ISO 8601 with timezone)
fromDatequerystringFilter from this date (ISO 8601 with timezone)
toDatequerystringFilter up to this date (ISO 8601 with timezone)
currencyquerystringFilter by currency
descriptionquerystringFilter by description
notesquerystringFilter by notes
parentInvoiceIdquerystringFilter by the documents spawned from the given invoice (receipts, credit notes and debit notes). Combine with documentType to select a single kind, e.g. the receipts issued for an invoice.
scheduleTemplateIdquerystringFilter by the documents issued by a recurring invoice (the id returned by POST /invoices/scheduled). This is how to reconcile a schedule with the documents that went out.
filterAllStatusesByDatequerybooleanApply the date filter to all statuses
includeATInvoicesquerybooleanInclude invoices imported from the AT
curl 'https://api.fiz.co/invoices' \
  --header "x-api-key: $FIZ_API_KEY"
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.list();
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.list()
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->list();

Response 200

List of invoices returned successfully

FieldTypeDescription
[].idstring
[].numberstring · can be null
[].documentTypestring · can be null
[].statusstring
[].datestring (date-time) · can be null
[].taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
[].dueDatestring (date-time) · can be null
[].currencystring · can be null
[].parentInvoiceIdstring · can be nullThe invoice that spawned this document. Populated on receipts, credit notes and debit notes; null on an invoice.
[].parentInvoiceNumberstring · can be nullNumber of the originating invoice
[].parentInvoiceDatestring (date-time) · can be nullDate of the originating invoice
[].parentInvoiceTypestring · can be nullDocument type of the originating invoice
[].scheduleTemplateIdstring · can be nullRecurring invoice that issued this document. Null on a manually created document.
[].summaryobject · can be null
[].summary.amountWithoutTaxnumber · can be null
[].summary.amountWithTaxnumber · can be null
[].summary.taxAmountnumber · can be null
[].summary.totalnumber · can be null
[].customerobject · can be null
[].customer.refstring · can be null
[].customer.dataobject · can be null
[].customer.data.namestring · can be null
[].customer.data.taxpayerNumberstring · can be null
[].customer.data.emailstring · can be null

Errors

  • 400 Invalid parameters
  • 401 Unauthorized - API key missing or invalid
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Create draft invoice

POST /invoices

Creates a draft invoice without issuing it

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Request body

Data required to create the draft invoice

FieldTypeDescription
datestringInvoice issue date (optional). Defaults to the current date and time when omitted. Determines the tax period the document falls in.
dueDatestringInvoice due date (optional). When omitted, the issue date is used — which is what is expected on documents settled on issue, such as an invoice-receipt.
taxPointDatestringDate of supply: the date on which the goods were made available to the acquirer or on which the services were performed (art. 36.º n.º 5 al. f) CIVA). Optional — when omitted, the issue date is used. It cannot be later than the issue date. On credit/debit notes it is ignored, since they inherit the date of supply of the original document.
cae requiredstringCAE code (Portuguese classification of economic activities)
type requiredstringDocument type
One of: CREDIT_NOTE, DEBIT_NOTE, INVOICE, INVOICE_RECEIPT, RECEIPT, SIMPLIFIED_INVOICE
customerId requiredstringCustomer identifier
seriesIdstringSeries identifier (optional). Use the "id" returned by GET /series. If omitted, the account's default series is used.
notesstringInvoice notes (optional)
items requiredobject[]List of invoice items
items[].id requiredstringItem identifier
items[].quantity requirednumberItem quantity
items[].unitPricenumberUnit price before VAT for this line (optional). Overrides the item's price on this document only: the catalogue item keeps its price. Send unitPrice OR unitPriceWithVat, not both.
items[].unitPriceWithVatnumberUnit price including VAT for this line (optional), instead of unitPrice. Converted to the price before VAT at the item's VAT rate, without rounding, so the VAT-inclusive total matches to the cent. Like unitPrice, it applies to this document only. Cannot be combined with an amount discount (discountType=AMOUNT), which is before VAT: use a percentage discount.
items[].discountTypestringDiscount type for this line (optional). Overrides the discount set on the catalogue item. Applied before the invoice's global discount.
One of: AMOUNT, PERCENT
items[].discountPercentnumberDiscount percentage for this line (e.g. 10 for 10%). Requires discountType=PERCENT.
items[].discountAmountnumberAbsolute per-unit discount amount for this line, before VAT. Requires discountType=AMOUNT.
items[].withholdingTaxEnabledbooleanApply withholding tax on this line (optional). If omitted, the line follows the item (withholdingTaxAvailable). With true, withholding applies to this document only, at withholdingTaxPercent or, without it, the item's percentage; the type is IRS for a sole trader and IRC for a company. With false, the line has no withholding. The catalogue item is not changed.
items[].withholdingTaxPercentnumberWithholding tax percentage for this line (optional, e.g. 25). Turns withholding on for the line; cannot be sent with withholdingTaxEnabled=false. Applies to this document only.
summaryobjectInvoice summary with global discount (optional)
summary.globalDiscountTypestringGlobal discount type
One of: AMOUNT, PERCENT
summary.globalDiscountPercentnumberGlobal discount percentage (e.g. 10 for 10%)
summary.globalDiscountAmountnumberAbsolute global discount amount
paymentobjectPayment (optional). Only allowed for the INVOICE_RECEIPT and SIMPLIFIED_INVOICE types.
payment.method requiredstringPayment method
One of: cash, card, bankTransfer, mbWay, multibanco, spin, other
payment.date requiredstringPayment date
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request POST 'https://api.fiz.co/invoices' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "cae": "1234",
  "type": "INVOICE",
  "customerId": "6863b1513117c5892ff55296",
  "items": [
    {
      "id": "68483e978073231c3947077c",
      "quantity": 1,
      "discountType": "PERCENT",
      "discountPercent": 10
    }
  ]
}'
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.create({
  cae: '1234',
  type: 'INVOICE',
  customerId: '6863b1513117c5892ff55296',
  items: [
    {
      id: '68483e978073231c3947077c',
      quantity: 1,
      discountType: 'PERCENT',
      discountPercent: 10,
    },
  ],
});
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.create({
    "cae": "1234",
    "type": "INVOICE",
    "customerId": "6863b1513117c5892ff55296",
    "items": [
        {
            "id": "68483e978073231c3947077c",
            "quantity": 1,
            "discountType": "PERCENT",
            "discountPercent": 10,
        },
    ],
})
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->create([
    'cae' => '1234',
    'type' => 'INVOICE',
    'customerId' => '6863b1513117c5892ff55296',
    'items' => [
        [
            'id' => '68483e978073231c3947077c',
            'quantity' => 1,
            'discountType' => 'PERCENT',
            'discountPercent' => 10,
        ],
    ],
]);

Response 201

Draft invoice created successfully

FieldTypeDescription
idstringUnique invoice identifier
numberstring · can be nullDocument number. Null on a draft — it is assigned on issue.
atcudstring · can be nullUnique document code (ATCUD). Null on a draft — it is assigned on issue.
shortHashstring · can be nullDocument hash summary (4 characters). Null on a draft — it is assigned on issue.
documentTypestring · can be nullDocument type
statusstringInvoice status
updatedAtstring (date-time) · can be nullDraft revision (updatedAt). Send it as expectedUpdatedAt when issuing: a draft changed in the meantime is refused.
notesstring · can be nullInvoice notes
seriesobject · can be nullInvoice series
series.refstring · can be nullSeries identifier
series.namestring · can be nullSeries name
paymentobject · can be nullPayment
payment.methodstring · can be nullPayment method
payment.datestring · can be nullPayment date
customerobject · can be nullCustomer
customer.refstring · can be nullCustomer identifier
customer.dataobject · can be nullCustomer data
customer.data.taxpayerNumberstring · can be nullTax number (NIF)
customer.data.namestring · can be nullCustomer name
customer.data.emailstring · can be nullCustomer email
customer.data.countrystring · can be nullCustomer country
customer.data.phonestring · can be nullCustomer phone
dueDatestring · can be nullInvoice due date
datestring · can be nullInvoice issue date
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
itemsobject[] · can be nullInvoice items
items[].idstringIdentifier of the item on the invoice
items[].refstring · can be nullItem reference
items[].metaobject · can be nullItem metadata
items[].meta.quantitynumber · can be nullItem quantity
items[].meta.amountWithoutTaxnumber · can be nullAmount without tax
items[].meta.amountWithTaxnumber · can be nullAmount with tax
items[].meta.taxAmountnumber · can be nullTax amount
items[].meta.discountAmountnumber · can be nullDiscount amount applied to the item
items[].meta.unitAmountWithoutTaxnumber · can be nullUnit amount without tax
items[].meta.unitAmountWithTaxnumber · can be nullUnit amount with tax
items[].meta.withholdingTaxAmountnumber · can be nullWithholding tax amount
items[].meta.withholdingTaxEnabledboolean · can be nullWithholding tax enabled
items[].dataobject · can be nullItem data
items[].data.namestring · can be nullItem name
items[].data.descriptionstring · can be nullItem description
items[].data.typestringItem type
items[].data.unitPricenumber · can be nullUnit price
items[].data.taxRatenumber · can be nullTax rate
items[].data.vatRatestring · can be nullVAT rate
items[].data.vatTerritorystring · can be nullVAT territory
items[].data.vatExemptionReasonstring · can be nullVAT exemption reason
items[].data.isAutoVATEnabledboolean · can be nullAutomatic VAT enabled
items[].noteChangeKindstring · can be nullOnly on the lines of partial credit/debit notes: what the line changes on the corrected invoice line — the quantity (QUANTITY) or the unit price (PRICE). Absent on other lines and on older notes.
One of: QUANTITY, PRICE
items[].noteChangeFromnumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line before this note.
items[].noteChangeTonumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line after this note.

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Create credit note (full or partial)

POST /invoices/credit-notes

Creates a credit note on the invoice referenced by parentInvoiceId. Without items it reverses the invoice in full: the items and the customer are copied from the original invoice. With items it is partial: each listed line credits the returned quantity or the difference to a new unit price, like the document correction in the FIZ app. By default the credit note is issued (issue=true). Use it only for real changes to the operation (e.g. a return, a discount or the cancellation of the deal); for formal errors or invoices issued by mistake, annul the invoice (POST /invoices/{id}/cancel).

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Request body

Data required to create the credit note

FieldTypeDescription
parentInvoiceId requiredstringIdentifier of the invoice to correct (the credit note reverses this document). Without items, the items are copied from this invoice in full (full reversal).
reasonCode requiredstringCredit note reason (Annex 40 / Art. 78 of the Portuguese VAT Code). A credit note records a real change to the operation (return, cancellation of the deal, discount, wrong amount or VAT rate). Formal errors that change neither the taxable amount nor the VAT (NIF, name, address, description) and invoices of operations that never took place are corrected by annulling the invoice (POST /invoices/{id}/cancel), not with a credit note (Ofício Circulado 25120/2026). On an advance invoice (isAdvance), a credit note is accepted only with ADVANCE_REFUND (the advance returned to the customer), up to the balance left to deduct (advanceBalance.remaining).
One of: ACCOUNTING_SYNC_ERROR, ADVANCE_REFUND, BAD_DEBT_UNDER_750, CORPORATE_REORGANIZATION, DEATH_NO_ASSETS, DEDUCTION_RIGHT_ALTERATION, DEDUCTION_RIGHT_CHANGE, DISCOUNT_BONUS, FINAL_CREDIT_REDUCTION, FIXED_ASSET_REGULARIZATION, INCORRECT_VAT_RATE, INSOLVENCY_CLOSED, INVOICE_EMISSION_ERROR, LEGAL_PROVISION_CHANGE, MERGER_INCORPORATION, OPERATION_CANCELLATION, OTHER_LEGAL_REGULARIZATIONS, PROPERTY_OUT_OF_BUSINESS, PRORATA_ADJUSTMENT, RATEIO_FINAL_NO_PAYMENT, REAL_AFFECTATION_CHANGE, RETURN_GOODS_SERVICES, SPLIT_PATRIMONY_TRANSFER, TAX_RATE_CHANGE, TECHNICAL_CORRECTION, VAT_REGIME_CHANGE, VAT_REGIME_CHANGE_ART25, WRONG_INVOICE
reasonstringText description of the reason (required). If omitted, the reasonCode's default description is used.
issuebooleanIssue the credit note immediately (true) or leave it as a draft (false). Issued by default.
itemsobject[]Partial credit note: the invoice lines to correct and, on each, the returned quantity (quantity) or the new unit price (unitPrice). Lines not listed stay as they are. Quantities and prices start from the line as it stands after the credit/debit notes already issued on this invoice. If omitted, the note reverses the invoice in full.
items[].itemId requiredstringIdentifier of the item on the invoice line to correct (the invoice’s items[].ref). Each invoice line may appear only once. Advance deduction lines (kind ADVANCE_DEDUCTION) are never listed: on an item with a deduction, the note credits at most the item’s amount net of its deductions.
items[].taxRatenumberVAT rate of the line (e.g. 23). Only needed when the same item appears on the invoice on more than one line at different rates.
items[].quantitynumberReturned quantity (to credit), at the line’s current unit price. Cannot exceed the quantity still on the line after earlier credit notes. Give quantity OR unitPrice, not both.
items[].unitPricenumberNew unit price (before VAT) of the line. The note credits the difference to the current price on the whole quantity still on the line. Must be below the current price by at least 0.01. Give quantity OR unitPrice, not both.
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request POST 'https://api.fiz.co/invoices/credit-notes' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "parentInvoiceId": "6900afc7e9a04d2adc897c68",
  "reasonCode": "OPERATION_CANCELLATION"
}'
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.creditNotes.create({
  parentInvoiceId: '6900afc7e9a04d2adc897c68',
  reasonCode: 'OPERATION_CANCELLATION',
}, { idempotencyKey });
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.credit_notes.create({
    "parentInvoiceId": "6900afc7e9a04d2adc897c68",
    "reasonCode": "OPERATION_CANCELLATION",
}, idempotency_key=idempotency_key)
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->creditNotes->create([
    'parentInvoiceId' => '6900afc7e9a04d2adc897c68',
    'reasonCode' => 'OPERATION_CANCELLATION',
], ['idempotencyKey' => $idempotencyKey]);

Response 201

Credit note created successfully

FieldTypeDescription
idstringUnique credit note identifier
numberstring · can be nullCredit note number. Null when created as a draft (issue: false); assigned on issue.
atcudstring · can be nullUnique document code (ATCUD). Null when created as a draft (issue: false); assigned on issue.
documentTypestring · can be nullDocument type
statusstringDocument status
creditNoteReasonCodestring · can be nullCredit note reason
One of: ACCOUNTING_SYNC_ERROR, ADVANCE_REFUND, BAD_DEBT_UNDER_750, CORPORATE_REORGANIZATION, DEATH_NO_ASSETS, DEDUCTION_RIGHT_ALTERATION, DEDUCTION_RIGHT_CHANGE, DISCOUNT_BONUS, FINAL_CREDIT_REDUCTION, FIXED_ASSET_REGULARIZATION, INCORRECT_VAT_RATE, INSOLVENCY_CLOSED, INVOICE_EMISSION_ERROR, LEGAL_PROVISION_CHANGE, MERGER_INCORPORATION, OPERATION_CANCELLATION, OTHER_LEGAL_REGULARIZATIONS, PROPERTY_OUT_OF_BUSINESS, PRORATA_ADJUSTMENT, RATEIO_FINAL_NO_PAYMENT, REAL_AFFECTATION_CHANGE, RETURN_GOODS_SERVICES, SPLIT_PATRIMONY_TRANSFER, TAX_RATE_CHANGE, TECHNICAL_CORRECTION, VAT_REGIME_CHANGE, VAT_REGIME_CHANGE_ART25, WRONG_INVOICE
parentInvoiceIdstring · can be nullIdentifier of the reversed invoice
parentInvoiceNumberstring · can be nullNumber of the reversed invoice
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
customerobject · can be nullCustomer
customer.refstring · can be nullCustomer identifier
customer.dataobject · can be nullCustomer data
customer.data.taxpayerNumberstring · can be nullTax number (NIF)
customer.data.namestring · can be nullCustomer name
customer.data.emailstring · can be nullCustomer email
customer.data.countrystring · can be nullCustomer country
customer.data.phonestring · can be nullCustomer phone
itemsobject[] · can be nullCredit note items
items[].idstringIdentifier of the item on the invoice
items[].refstring · can be nullItem reference
items[].metaobject · can be nullItem metadata
items[].meta.quantitynumber · can be nullItem quantity
items[].meta.amountWithoutTaxnumber · can be nullAmount without tax
items[].meta.amountWithTaxnumber · can be nullAmount with tax
items[].meta.taxAmountnumber · can be nullTax amount
items[].meta.discountAmountnumber · can be nullDiscount amount applied to the item
items[].meta.unitAmountWithoutTaxnumber · can be nullUnit amount without tax
items[].meta.unitAmountWithTaxnumber · can be nullUnit amount with tax
items[].meta.withholdingTaxAmountnumber · can be nullWithholding tax amount
items[].meta.withholdingTaxEnabledboolean · can be nullWithholding tax enabled
items[].dataobject · can be nullItem data
items[].data.namestring · can be nullItem name
items[].data.descriptionstring · can be nullItem description
items[].data.typestringItem type
items[].data.unitPricenumber · can be nullUnit price
items[].data.taxRatenumber · can be nullTax rate
items[].data.vatRatestring · can be nullVAT rate
items[].data.vatTerritorystring · can be nullVAT territory
items[].data.vatExemptionReasonstring · can be nullVAT exemption reason
items[].data.isAutoVATEnabledboolean · can be nullAutomatic VAT enabled
items[].noteChangeKindstring · can be nullOnly on the lines of partial credit/debit notes: what the line changes on the corrected invoice line — the quantity (QUANTITY) or the unit price (PRICE). Absent on other lines and on older notes.
One of: QUANTITY, PRICE
items[].noteChangeFromnumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line before this note.
items[].noteChangeTonumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line after this note.
summaryobject · can be nullDocument summary
summary.amountWithoutTaxnumber · can be nullAmount without tax
summary.amountWithTaxnumber · can be nullAmount with tax
summary.amountWithoutTaxWithoutDiscountnumber · can be nullAmount without tax and discount
summary.taxAmountnumber · can be nullTax amount
summary.globalDiscountTypestring · can be nullGlobal discount type
One of: AMOUNT, PERCENT
summary.globalDiscountPercentnumber · can be nullGlobal discount percentage
summary.globalDiscountAmountnumber · can be nullGlobal discount amount
summary.totalnumber · can be nullTotal
summary.totalToPaynumber · can be nullTotal payable
summary.withholdingTaxAmountnumber · can be nullWithholding tax amount
summary.creditNotesTotalnumber · can be nullTotal of credit notes

Errors

  • 400 Invalid data, or the named line is not on the invoice, the quantity exceeds what is left, the price is not below the current one, or the note total exceeds what the invoice has left to credit
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice to correct (parentInvoiceId) not found
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Get invoice by ID

GET /invoices/{id}

Returns a single invoice by its unique identifier

Authentication: an API key (x-api-key) or an OAuth access token.

Parameters

NameInTypeDescription
id requiredpathstringUnique invoice identifier
curl 'https://api.fiz.co/invoices/ID' \
  --header "x-api-key: $FIZ_API_KEY"
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.retrieve('ID');
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.retrieve("ID")
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->retrieve('ID');

Response 200

Invoice found

FieldTypeDescription
idstring
numberstring · can be null
atcudstring · can be null
shortHashstring · can be null
documentTypestring · can be null
statusstring
updatedAtstring (date-time) · can be nullDraft revision to pass as expectedUpdatedAt when issuing.
datestring (date-time) · can be null
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
dueDatestring (date-time) · can be null
currencystring · can be null
descriptionstring · can be null
notesstring · can be null
caestring · can be null
createdAtstring (date-time) · can be null
issuedAtstring (date-time) · can be null
parentInvoiceIdstring · can be nullThe invoice that spawned this document. Populated on receipts, credit notes and debit notes; null on an invoice.
parentInvoiceNumberstring · can be nullNumber of the originating invoice
parentInvoiceDatestring (date-time) · can be nullDate of the originating invoice
parentInvoiceTypestring · can be nullDocument type of the originating invoice
isAdvanceboolean · can be nullAdvance invoice (an FT or FR recording a payment received in advance), to be deducted later in a final invoice.
advanceBalanceobject · can be nullAdvance invoices only: computed balance (not stored). remaining = total − deducted in live final invoices − refunded by ADVANCE_REFUND credit notes.
advanceBalance.totalnumberTaxable base of the advance
advanceBalance.deductednumber
advanceBalance.refundednumber
advanceBalance.remainingnumber
advanceBalance.byRateobject[]
advanceBalance.byRate[].vatRatestring · can be null
advanceBalance.byRate[].taxRatenumber
advanceBalance.byRate[].exemptionCodestring · can be null
advanceBalance.byRate[].basenumber
advanceBalance.byRate[].remainingnumber
syncWithAtobject · can be null
syncWithAt.statusstring · can be null
syncWithAt.atCodestring · can be null
syncWithAt.atMessagestring · can be null
seriesobject · can be null
series.refstring · can be null
series.namestring · can be null
customerobject · can be null
customer.refstring · can be null
customer.dataobject · can be null
customer.data.namestring · can be null
customer.data.taxpayerNumberstring · can be null
customer.data.emailstring · can be null
customer.data.addressstring · can be null
customer.data.postalCodestring · can be null
customer.data.citystring · can be null
customer.data.countrystring · can be null
customer.data.phonestring · can be null
customer.data.mobilestring · can be null
summaryobject · can be null
summary.amountWithoutTaxnumber · can be null
summary.amountWithTaxnumber · can be null
summary.amountWithoutTaxWithoutDiscountnumber · can be null
summary.taxAmountnumber · can be null
summary.globalDiscountTypestring · can be nullOne of: PERCENT, AMOUNT
summary.globalDiscountPercentnumber · can be null
summary.globalDiscountAmountnumber · can be null
summary.totalnumber · can be null
summary.totalToPaynumber · can be null
summary.withholdingTaxAmountnumber · can be null
summary.creditNotesTotalnumber · can be null
itemsobject[] · can be null
items[].idstring
items[].refstring · can be null
items[].noteChangeKindstring · can be nullOnly on the lines of partial credit/debit notes: what the line changes on the corrected invoice line — the quantity (QUANTITY) or the unit price (PRICE). Absent on other lines and on older notes.
One of: QUANTITY, PRICE
items[].noteChangeFromnumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line before this note.
items[].noteChangeTonumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line after this note.
items[].metaobject · can be null
items[].meta.quantitynumber · can be null
items[].meta.amountWithoutTaxnumber · can be null
items[].meta.amountWithTaxnumber · can be null
items[].meta.taxAmountnumber · can be null
items[].meta.discountAmountnumber · can be null
items[].meta.unitItemDiscountPercentnumber · can be null
items[].meta.unitItemDiscountAmountnumber · can be null
items[].meta.unitDiscountPercentnumber · can be null
items[].meta.unitDiscountAmountnumber · can be null
items[].meta.unitAmountWithoutTaxnumber · can be null
items[].meta.unitAmountWithTaxnumber · can be null
items[].meta.withholdingTaxAmountnumber · can be null
items[].meta.withholdingTaxEnabledboolean · can be null
items[].dataobject · can be null
items[].data.namestring · can be null
items[].data.descriptionstring · can be null
items[].data.typestring
items[].data.unitPricenumber · can be null
items[].data.vatRatestring · can be null
items[].data.unitDiscountTypestring · can be nullOne of: PERCENT, AMOUNT
items[].data.unitDiscountPercentnumber · can be null
items[].data.unitDiscountAmountnumber · can be null
items[].kindstring · can be nullADVANCE_DEDUCTION: an advance deduction line. Its amounts are negative, it belongs to the item line parentItemId of the same document and has no catalogue item (ref). Do not copy it into a new draft or list it in a partial credit note. Absent on ordinary lines.
One of: ADVANCE_DEDUCTION
items[].parentItemIdstring · can be nullWith kind ADVANCE_DEDUCTION: the id of the item line the deduction belongs to.
items[].advanceRefobject · can be nullWith kind ADVANCE_DEDUCTION: the advance invoice deducted.
items[].advanceRef.invoiceIdstring
items[].advanceRef.numberstring
items[].advanceRef.datestring (date-time)
items[].advanceRef.paymentDatestring (date-time) · can be nullPayment date of the advance: the FR's own date, or the date of the FT's latest receipt or recorded payment. null on an FT with no recorded payment.
paymentobject · can be null
payment.methodstring · can be null
payment.datestring (date-time) · can be null
qrCodeobject · can be null
qrCode.urlstring · can be null
qrCode.datastring
qrCode.imageDatastring
issuerobject · can be null
issuer.refstring · can be null
issuer.dataobject · can be null
issuer.data.namestring · can be null
issuer.data.taxPayerNumberstring · can be null
issuer.data.addressstring · can be null
issuer.data.citystring · can be null
issuer.data.postalCodestring · can be null
issuer.data.countrystring · can be null

Errors

  • 400 Invalid ID
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice not found
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Update draft invoice

PATCH /invoices/{id}

Updates the fields of a draft invoice. Only the provided fields are changed.

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Parameters

NameInTypeDescription
id requiredpathstringUnique invoice identifier

Request body

Fields to update on the draft invoice

FieldTypeDescription
datestringInvoice issue date. When omitted, the date already stored on the invoice is kept. Determines the tax period the document falls in.
dueDatestringInvoice due date (optional). When omitted, the issue date is used — which is what is expected on documents settled on issue, such as an invoice-receipt.
caestringCAE code (Portuguese classification of economic activities)
customerIdstringCustomer identifier
seriesIdstringSeries identifier (optional). Use the "id" returned by GET /series. If omitted, the account's default series is used.
notesstringInvoice notes (optional)
itemsobject[]List of invoice items
items[].id requiredstringItem identifier
items[].quantity requirednumberItem quantity
items[].unitPricenumberUnit price before VAT for this line (optional). Overrides the item's price on this document only: the catalogue item keeps its price. Send unitPrice OR unitPriceWithVat, not both.
items[].unitPriceWithVatnumberUnit price including VAT for this line (optional), instead of unitPrice. Converted to the price before VAT at the item's VAT rate, without rounding, so the VAT-inclusive total matches to the cent. Like unitPrice, it applies to this document only. Cannot be combined with an amount discount (discountType=AMOUNT), which is before VAT: use a percentage discount.
items[].discountTypestringDiscount type for this line (optional). Overrides the discount set on the catalogue item. Applied before the invoice's global discount.
One of: AMOUNT, PERCENT
items[].discountPercentnumberDiscount percentage for this line (e.g. 10 for 10%). Requires discountType=PERCENT.
items[].discountAmountnumberAbsolute per-unit discount amount for this line, before VAT. Requires discountType=AMOUNT.
items[].withholdingTaxEnabledbooleanApply withholding tax on this line (optional). If omitted, the line follows the item (withholdingTaxAvailable). With true, withholding applies to this document only, at withholdingTaxPercent or, without it, the item's percentage; the type is IRS for a sole trader and IRC for a company. With false, the line has no withholding. The catalogue item is not changed.
items[].withholdingTaxPercentnumberWithholding tax percentage for this line (optional, e.g. 25). Turns withholding on for the line; cannot be sent with withholdingTaxEnabled=false. Applies to this document only.
summaryobjectInvoice summary with global discount (optional)
summary.globalDiscountTypestringGlobal discount type
One of: AMOUNT, PERCENT
summary.globalDiscountPercentnumberGlobal discount percentage (e.g. 10 for 10%)
summary.globalDiscountAmountnumberAbsolute global discount amount
taxPointDatestring · can be nullDate of supply (art. 36.º n.º 5 al. f) CIVA). Send null to clear the recorded date and fall back to the issue date. If omitted, the date already stored on the invoice is kept.
paymentobjectPayment
payment.method requiredstringPayment method
One of: cash, card, bankTransfer, mbWay, multibanco, spin, other
payment.date requiredstringPayment date
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request PATCH 'https://api.fiz.co/invoices/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "date": "2025-10-15T07:00:00.000Z",
  "dueDate": "2025-11-04T07:00:00.000Z",
  "cae": "1234"
}'
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.update('ID', {
  date: '2025-10-15T07:00:00.000Z',
  dueDate: '2025-11-04T07:00:00.000Z',
  cae: '1234',
});
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.update("ID", {
    "date": "2025-10-15T07:00:00.000Z",
    "dueDate": "2025-11-04T07:00:00.000Z",
    "cae": "1234",
})
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->update('ID', [
    'date' => '2025-10-15T07:00:00.000Z',
    'dueDate' => '2025-11-04T07:00:00.000Z',
    'cae' => '1234',
]);

Response 200

Draft invoice updated successfully

FieldTypeDescription
idstringUnique invoice identifier
numberstring · can be nullDocument number. Null on a draft — it is assigned on issue.
atcudstring · can be nullUnique document code (ATCUD). Null on a draft — it is assigned on issue.
shortHashstring · can be nullDocument hash summary (4 characters). Null on a draft — it is assigned on issue.
documentTypestring · can be nullDocument type
statusstringInvoice status
updatedAtstring (date-time) · can be nullDraft revision (updatedAt). Send it as expectedUpdatedAt when issuing: a draft changed in the meantime is refused.
notesstring · can be nullInvoice notes
seriesobject · can be nullInvoice series
series.refstring · can be nullSeries identifier
series.namestring · can be nullSeries name
paymentobject · can be nullPayment
payment.methodstring · can be nullPayment method
payment.datestring · can be nullPayment date
customerobject · can be nullCustomer
customer.refstring · can be nullCustomer identifier
customer.dataobject · can be nullCustomer data
customer.data.taxpayerNumberstring · can be nullTax number (NIF)
customer.data.namestring · can be nullCustomer name
customer.data.emailstring · can be nullCustomer email
customer.data.countrystring · can be nullCustomer country
customer.data.phonestring · can be nullCustomer phone
dueDatestring · can be nullInvoice due date
datestring · can be nullInvoice issue date
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
itemsobject[] · can be nullInvoice items
items[].idstringIdentifier of the item on the invoice
items[].refstring · can be nullItem reference
items[].metaobject · can be nullItem metadata
items[].meta.quantitynumber · can be nullItem quantity
items[].meta.amountWithoutTaxnumber · can be nullAmount without tax
items[].meta.amountWithTaxnumber · can be nullAmount with tax
items[].meta.taxAmountnumber · can be nullTax amount
items[].meta.discountAmountnumber · can be nullDiscount amount applied to the item
items[].meta.unitAmountWithoutTaxnumber · can be nullUnit amount without tax
items[].meta.unitAmountWithTaxnumber · can be nullUnit amount with tax
items[].meta.withholdingTaxAmountnumber · can be nullWithholding tax amount
items[].meta.withholdingTaxEnabledboolean · can be nullWithholding tax enabled
items[].dataobject · can be nullItem data
items[].data.namestring · can be nullItem name
items[].data.descriptionstring · can be nullItem description
items[].data.typestringItem type
items[].data.unitPricenumber · can be nullUnit price
items[].data.taxRatenumber · can be nullTax rate
items[].data.vatRatestring · can be nullVAT rate
items[].data.vatTerritorystring · can be nullVAT territory
items[].data.vatExemptionReasonstring · can be nullVAT exemption reason
items[].data.isAutoVATEnabledboolean · can be nullAutomatic VAT enabled
items[].noteChangeKindstring · can be nullOnly on the lines of partial credit/debit notes: what the line changes on the corrected invoice line — the quantity (QUANTITY) or the unit price (PRICE). Absent on other lines and on older notes.
One of: QUANTITY, PRICE
items[].noteChangeFromnumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line before this note.
items[].noteChangeTonumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line after this note.

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice not found
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Delete invoice

DELETE /invoices/{id}

Deletes the invoice with the given ID.

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Parameters

NameInTypeDescription
id requiredpathstringUnique invoice identifier
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request DELETE 'https://api.fiz.co/invoices/ID' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}"
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.delete('ID');
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.delete("ID")
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->delete('ID');

Response 200

Invoice deleted successfully

FieldTypeDescription
idstringUnique invoice identifier
createdAtstring · can be nullInvoice creation date

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice not found
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Issue invoice

POST /invoices/{id}/issue

Issues the invoice with the given ID.

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Parameters

NameInTypeDescription
id requiredpathstring

Request body

FieldTypeDescription
expectedUpdatedAtstring (date-time)Draft revision (updatedAt). Issuance is refused if the document has changed.
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request POST 'https://api.fiz.co/invoices/ID/issue' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "expectedUpdatedAt": "2026-01-31T10:00:00.000Z"
}'
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.invoices.issue('ID', {
  expectedUpdatedAt: '2026-01-31T10:00:00.000Z',
}, { idempotencyKey });
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.invoices.issue("ID", {
    "expectedUpdatedAt": "2026-01-31T10:00:00.000Z",
}, idempotency_key=idempotency_key)
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->invoices->issue('ID', [
    'expectedUpdatedAt' => '2026-01-31T10:00:00.000Z',
], ['idempotencyKey' => $idempotencyKey]);

Response 200

Invoice issued successfully

FieldTypeDescription
idstringUnique invoice identifier
numberstring · can be nullDocument number
atcudstring · can be nullUnique document code (ATCUD)
shortHashstring · can be nullDocument hash summary (4 characters) printed on the PDF
documentTypestring · can be nullDocument type
statusstringInvoice status
notesstring · can be nullInvoice notes
seriesobject · can be nullInvoice series
series.refstring · can be nullSeries identifier
series.namestring · can be nullSeries name
paymentobject · can be nullPayment
payment.methodstring · can be nullPayment method
payment.datestring · can be nullPayment date
customerobject · can be nullCustomer
customer.refstring · can be nullCustomer identifier
customer.dataobject · can be nullCustomer data
customer.data.taxpayerNumberstring · can be nullTax number (NIF)
customer.data.namestring · can be nullCustomer name
customer.data.emailstring · can be nullCustomer email
customer.data.countrystring · can be nullCustomer country
customer.data.phonestring · can be nullCustomer phone
dueDatestring · can be nullInvoice due date
datestring · can be nullInvoice issue date
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
itemsobject[] · can be nullInvoice items
items[].idstringIdentifier of the item on the invoice
items[].refstring · can be nullItem reference
items[].metaobject · can be nullItem metadata
items[].meta.quantitynumber · can be nullItem quantity
items[].meta.amountWithoutTaxnumber · can be nullAmount without tax
items[].meta.amountWithTaxnumber · can be nullAmount with tax
items[].meta.taxAmountnumber · can be nullTax amount
items[].meta.discountAmountnumber · can be nullDiscount amount applied to the item
items[].meta.unitAmountWithoutTaxnumber · can be nullUnit amount without tax
items[].meta.unitAmountWithTaxnumber · can be nullUnit amount with tax
items[].meta.withholdingTaxAmountnumber · can be nullWithholding tax amount
items[].meta.withholdingTaxEnabledboolean · can be nullWithholding tax enabled
items[].dataobject · can be nullItem data
items[].data.namestring · can be nullItem name
items[].data.descriptionstring · can be nullItem description
items[].data.typestringItem type
items[].data.unitPricenumber · can be nullUnit price
items[].data.taxRatenumber · can be nullTax rate
items[].data.vatRatestring · can be nullVAT rate
items[].data.vatTerritorystring · can be nullVAT territory
items[].data.vatExemptionReasonstring · can be nullVAT exemption reason
items[].data.isAutoVATEnabledboolean · can be nullAutomatic VAT enabled
items[].noteChangeKindstring · can be nullOnly on the lines of partial credit/debit notes: what the line changes on the corrected invoice line — the quantity (QUANTITY) or the unit price (PRICE). Absent on other lines and on older notes.
One of: QUANTITY, PRICE
items[].noteChangeFromnumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line before this note.
items[].noteChangeTonumber · can be nullWith noteChangeKind: the quantity or unit price of the invoice line after this note.
syncWithAtobject · can be nullAT synchronization status
syncWithAt.statusstring · can be nullAT synchronization status
syncWithAt.atCodestring · can be nullAT code
syncWithAt.atMessagestring · can be nullAT message
syncWithAt.systemErrorstring · can be nullSystem error
syncWithAt.isRetriableboolean · can be nullCan be retried
syncWithAt.updatedAtstring · can be nullLast update date

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Register invoice payment

POST /invoices/{id}/pay

Registers a payment against an already issued invoice, settling the outstanding balance. When the amount is omitted, the full outstanding balance is settled. Unlike updating an invoice, this operation is allowed on already issued documents. Only for INVOICE or DEBIT_NOTE documents in the ISSUED state.

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Parameters

NameInTypeDescription
id requiredpathstringUnique invoice identifier

Request body

FieldTypeDescription
method requiredstringPayment method
One of: cash, card, bankTransfer, mbWay, multibanco, spin, other
date requiredstringPayment date
amountnumberAmount paid (optional). When omitted, the full outstanding balance is settled. Minimum 0.01, at most two decimal places.
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request POST 'https://api.fiz.co/invoices/ID/pay' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "method": "mbWay",
  "date": "2025-11-04T07:00:00.000Z"
}'
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.invoices.pay('ID', {
  method: 'mbWay',
  date: '2025-11-04T07:00:00.000Z',
}, { idempotencyKey });
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.invoices.pay("ID", {
    "method": "mbWay",
    "date": "2025-11-04T07:00:00.000Z",
}, idempotency_key=idempotency_key)
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->invoices->pay('ID', [
    'method' => 'mbWay',
    'date' => '2025-11-04T07:00:00.000Z',
], ['idempotencyKey' => $idempotencyKey]);

Response 200

Payment registered successfully

FieldTypeDescription
idstringUnique invoice identifier
numberstring · can be nullInvoice number
documentTypestring · can be nullDocument type
statusstringInvoice status
notesstring · can be nullInvoice notes
seriesobject · can be nullInvoice series
series.refstring · can be nullSeries identifier
series.namestring · can be nullSeries name
paymentobject · can be nullLegacy field, populated only once the invoice is fully paid. On a partial payment it is null — use payments.
payment.methodstring · can be nullPayment method
payment.datestring · can be nullPayment date
paymentsobject[] · can be nullEvery payment registered against the invoice, including each amount.
payments[].methodstring · can be nullPayment method
payments[].datestring · can be nullPayment date
payments[].amountnumber · can be nullAmount paid
receiptobject · can be nullReceipt (RG) issued by this payment, carrying the id needed to download its PDF from GET /invoices/{id}/pdf. On a partial payment this is the receipt for this payment, not an earlier one. Null for AT-imported invoices, for which no receipt is issued.
receipt.idstringUnique receipt identifier — use it in GET /invoices/{id}/pdf
receipt.numberstring · can be nullReceipt number
receipt.atcudstring · can be nullUnique document code (ATCUD)
receipt.documentTypestring · can be nullDocument type
receipt.statusstringReceipt status
receipt.datestring · can be nullReceipt issue date
receipt.seriesobject · can be nullReceipt series
receipt.series.refstring · can be nullSeries identifier
receipt.series.namestring · can be nullSeries name
customerobject · can be nullCustomer
customer.refstring · can be nullCustomer identifier
customer.dataobject · can be nullCustomer data
customer.data.taxpayerNumberstring · can be nullTax number (NIF)
customer.data.namestring · can be nullCustomer name
customer.data.emailstring · can be nullCustomer email
customer.data.countrystring · can be nullCustomer country
customer.data.phonestring · can be nullCustomer phone
dueDatestring · can be nullInvoice due date
datestring · can be nullInvoice issue date
taxPointDatestring (date-time) · can be nullDate of supply, when recorded (art. 36.º n.º 5 al. f) CIVA). Comes back null when it was not recorded — the issue date applies in that case.
itemsobject[] · can be nullInvoice items
items[].idstringIdentifier of the item on the invoice
items[].refstring · can be nullItem reference
items[].metaobject · can be nullItem metadata
items[].meta.quantitynumber · can be nullQuantity
items[].meta.taxAmountnumber · can be nullTax amount
items[].dataobject · can be nullItem data
items[].data.namestring · can be nullItem name
items[].data.descriptionstring · can be nullItem description
items[].data.typestringItem type
items[].data.unitPricenumber · can be nullUnit price
items[].data.taxRatenumber · can be nullTax rate
items[].data.vatRatestring · can be nullVAT rate
items[].data.vatTerritorystring · can be nullVAT territory
items[].data.vatExemptionReasonstring · can be nullVAT exemption reason
items[].data.isAutoVATEnabledboolean · can be nullAutomatic VAT enabled
syncWithAtobject · can be nullAT synchronization status
syncWithAt.statusstring · can be nullAT synchronization status
syncWithAt.atCodestring · can be nullAT code
syncWithAt.atMessagestring · can be nullAT message
syncWithAt.systemErrorstring · can be nullSystem error
syncWithAt.isRetriableboolean · can be nullCan be retried
syncWithAt.updatedAtstring · can be nullLast update date

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice not found
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Cancel issued invoice

POST /invoices/{id}/cancel

Cancels an already issued invoice (and, when applicable, with the AT — the Portuguese Tax Authority). An invoice that already has issued credit/debit notes cannot be cancelled. Annulment is the instrument for formal errors that change neither the taxable amount nor the VAT (NIF, name, address, description) — followed by a corrected invoice dated with the original operation date — and for invoices of operations that never took place. Real changes to the operation (return, discount, wrong amount or VAT rate) are regularised with a credit note (Ofício Circulado 25120/2026).

Authentication: an API key (x-api-key) or an OAuth access token. Send an Idempotency-Key to retry this call safely.

Parameters

NameInTypeDescription
id requiredpathstring

Request body

FieldTypeDescription
reasonstringReason for the annulment, reported to the AT in the SAF-T. Recommended; optional for backward compatibility.
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
curl --request POST 'https://api.fiz.co/invoices/ID/cancel' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: ${IDEMPOTENCY_KEY:?set the operation key first, in the step above}" \
  --data '{
  "reason": "NIF do cliente incorreto — substituída por nova fatura"
}'
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const idempotencyKey = process.env.IDEMPOTENCY_KEY; // from the step above, the same on every retry
if (!idempotencyKey) throw new Error('Set IDEMPOTENCY_KEY first, in the step above');
const result = await fiz.invoices.cancel('ID', {
  reason: 'NIF do cliente incorreto — substituída por nova fatura',
}, { idempotencyKey });
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
import os

from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
idempotency_key = os.environ["IDEMPOTENCY_KEY"]  # from the step above, the same on every retry
result = fiz.invoices.cancel("ID", {
    "reason": "NIF do cliente incorreto — substituída por nova fatura",
}, idempotency_key=idempotency_key)
# Once per fiscal operation, before the call. Store it with the document:
# a retry after a lost response reuses it and gets the recorded result, or a 409
# without Retry-After when the outcome is unknown: then check the document first.
export IDEMPOTENCY_KEY=$(uuidgen)
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
// from the step above, the same on every retry
$idempotencyKey = getenv('IDEMPOTENCY_KEY') ?: throw new RuntimeException('Set IDEMPOTENCY_KEY first, in the step above');
$result = $fiz->invoices->cancel('ID', [
    'reason' => 'NIF do cliente incorreto — substituída por nova fatura',
], ['idempotencyKey' => $idempotencyKey]);

Response 200

Invoice cancelled successfully

FieldTypeDescription
idstringUnique invoice identifier
numberstring · can be nullDocument number
documentTypestring · can be nullDocument type
statusstringInvoice status
canceledAtstring · can be nullCancellation date
syncWithAtobject · can be nullAT synchronization status
syncWithAt.statusstring · can be nullAT synchronization status
syncWithAt.atCodestring · can be nullAT code
syncWithAt.atMessagestring · can be nullAT message
syncWithAt.systemErrorstring · can be nullSystem error
syncWithAt.isRetriableboolean · can be nullCan be retried
syncWithAt.updatedAtstring · can be nullLast update date

Errors

  • 400 Cannot cancel (already cancelled or has issued credit/debit notes)
  • 401 Unauthorized - API key missing or invalid
  • 409 A request with this idempotency key is still being processed, or the outcome of the first attempt is unknown
  • 422 The idempotency key was already used with a different request body
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Download invoice PDF

GET /invoices/{id}/pdf

Generates and returns the download link for an invoice PDF

Authentication: an API key (x-api-key) or an OAuth access token.

Parameters

NameInTypeDescription
id requiredpathstring
isDuplicatequerybooleanMark PDF as duplicate
formatquerystringPDF format
One of: A4, RECEIPT, RECEIPT_58
templateIdquerystringID of the template to use
curl 'https://api.fiz.co/invoices/ID/pdf' \
  --header "x-api-key: $FIZ_API_KEY"
import { Fiz } from '@fiz-co/sdk';

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.invoices.pdf('ID');
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.pdf("ID")
<?php
require 'vendor/autoload.php';

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->invoices->pdf('ID');

Response 200

PDF generated successfully

FieldTypeDescription
idstringPDF file ID
namestring · can be nullPDF file name
urlstring · can be nullPDF download URL

Errors

  • 400 Invalid data
  • 401 Unauthorized - API key missing or invalid
  • 404 Invoice not found
  • 429 The OAuth connection’s request limit is reached. Nothing was executed: repeat the same request after Retry-After seconds.

Errors

Errors share one shape: statusCode, message, code and error, with the request id in the X-Request-Id header.

All resources