# Invoices

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

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

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `offset` | query | number | Number of records to skip (offset) |
| `limit` | query | number | Maximum number of records to return |
| `sort` | query | string | Sort field and order (e.g. date:desc, number:asc) |
| `search` | query | string | Global search term (number, customer, etc.) |
| `documentType` | query | string | Filter by document type — One of: `CREDIT_NOTE`, `DEBIT_NOTE`, `INVOICE`, `INVOICE_RECEIPT`, `RECEIPT`, `SIMPLIFIED_INVOICE` |
| `status` | query | string | Filter by status — One of: `CANCELED`, `CREATED`, `DRAFT`, `ISSUED`, `PAID`, `PROCESSING`, `SCHEDULED` |
| `aggregatedStatus` | query | string | Filter by aggregated status — One of: `DRAFT`, `OVERDUE`, `PAID`, `PENDING`, `SCHEDULED`, `UNPAID` |
| `date` | query | string | Filter by a specific date (ISO 8601 with timezone) |
| `dueDate` | query | string | Filter by a specific due date (ISO 8601 with timezone) |
| `fromDate` | query | string | Filter from this date (ISO 8601 with timezone) |
| `toDate` | query | string | Filter up to this date (ISO 8601 with timezone) |
| `currency` | query | string | Filter by currency |
| `description` | query | string | Filter by description |
| `notes` | query | string | Filter by notes |
| `parentInvoiceId` | query | string | Filter 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. |
| `scheduleTemplateId` | query | string | Filter 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. |
| `filterAllStatusesByDate` | query | boolean | Apply the date filter to all statuses |
| `includeATInvoices` | query | boolean | Include invoices imported from the AT |

**curl**

```shell
curl 'https://api.fiz.co/invoices' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

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

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.list()
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

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

### Response `200`

List of invoices returned successfully

| Field | Type | Description |
| --- | --- | --- |
| `[].id` | string |  |
| `[].number` | string · can be null |  |
| `[].documentType` | string · can be null |  |
| `[].status` | string |  |
| `[].date` | string (date-time) · can be null |  |
| `[].taxPointDate` | string (date-time) · can be null | Date 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. |
| `[].dueDate` | string (date-time) · can be null |  |
| `[].currency` | string · can be null |  |
| `[].parentInvoiceId` | string · can be null | The invoice that spawned this document. Populated on receipts, credit notes and debit notes; null on an invoice. |
| `[].parentInvoiceNumber` | string · can be null | Number of the originating invoice |
| `[].parentInvoiceDate` | string (date-time) · can be null | Date of the originating invoice |
| `[].parentInvoiceType` | string · can be null | Document type of the originating invoice |
| `[].scheduleTemplateId` | string · can be null | Recurring invoice that issued this document. Null on a manually created document. |
| `[].summary` | object · can be null |  |
| `[].summary.amountWithoutTax` | number · can be null |  |
| `[].summary.amountWithTax` | number · can be null |  |
| `[].summary.taxAmount` | number · can be null |  |
| `[].summary.total` | number · can be null |  |
| `[].customer` | object · can be null |  |
| `[].customer.ref` | string · can be null |  |
| `[].customer.data` | object · can be null |  |
| `[].customer.data.name` | string · can be null |  |
| `[].customer.data.taxpayerNumber` | string · can be null |  |
| `[].customer.data.email` | string · 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

| Field | Type | Description |
| --- | --- | --- |
| `date` | string | Invoice issue date (optional). Defaults to the current date and time when omitted. Determines the tax period the document falls in. |
| `dueDate` | string | Invoice 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. |
| `taxPointDate` | string | Date 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` **required** | string | CAE code (Portuguese classification of economic activities) |
| `type` **required** | string | Document type — One of: `CREDIT_NOTE`, `DEBIT_NOTE`, `INVOICE`, `INVOICE_RECEIPT`, `RECEIPT`, `SIMPLIFIED_INVOICE` |
| `customerId` **required** | string | Customer identifier |
| `seriesId` | string | Series identifier (optional). Use the "id" returned by GET /series. If omitted, the account's default series is used. |
| `notes` | string | Invoice notes (optional) |
| `items` **required** | object\[\] | List of invoice items |
| `items[].id` **required** | string | Item identifier |
| `items[].quantity` **required** | number | Item quantity |
| `items[].unitPrice` | number | Unit 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[].unitPriceWithVat` | number | Unit 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[].discountType` | string | Discount 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[].discountPercent` | number | Discount percentage for this line (e.g. 10 for 10%). Requires discountType=PERCENT. |
| `items[].discountAmount` | number | Absolute per-unit discount amount for this line, before VAT. Requires discountType=AMOUNT. |
| `items[].withholdingTaxEnabled` | boolean | Apply 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[].withholdingTaxPercent` | number | Withholding 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. |
| `summary` | object | Invoice summary with global discount (optional) |
| `summary.globalDiscountType` | string | Global discount type — One of: `AMOUNT`, `PERCENT` |
| `summary.globalDiscountPercent` | number | Global discount percentage (e.g. 10 for 10%) |
| `summary.globalDiscountAmount` | number | Absolute global discount amount |
| `payment` | object | Payment (optional). Only allowed for the INVOICE\_RECEIPT and SIMPLIFIED\_INVOICE types. |
| `payment.method` **required** | string | Payment method — One of: `cash`, `card`, `bankTransfer`, `mbWay`, `multibanco`, `spin`, `other` |
| `payment.date` **required** | string | Payment date |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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
    }
  ]
}'
```

**TypeScript**

```ts
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,
    },
  ],
});
```

**Python**

```python
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**

```php
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `number` | string · can be null | Document number. Null on a draft — it is assigned on issue. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null on a draft — it is assigned on issue. |
| `shortHash` | string · can be null | Document hash summary (4 characters). Null on a draft — it is assigned on issue. |
| `documentType` | string · can be null | Document type |
| `status` | string | Invoice status |
| `updatedAt` | string (date-time) · can be null | Draft revision (updatedAt). Send it as expectedUpdatedAt when issuing: a draft changed in the meantime is refused. |
| `notes` | string · can be null | Invoice notes |
| `series` | object · can be null | Invoice series |
| `series.ref` | string · can be null | Series identifier |
| `series.name` | string · can be null | Series name |
| `payment` | object · can be null | Payment |
| `payment.method` | string · can be null | Payment method |
| `payment.date` | string · can be null | Payment date |
| `customer` | object · can be null | Customer |
| `customer.ref` | string · can be null | Customer identifier |
| `customer.data` | object · can be null | Customer data |
| `customer.data.taxpayerNumber` | string · can be null | Tax number (NIF) |
| `customer.data.name` | string · can be null | Customer name |
| `customer.data.email` | string · can be null | Customer email |
| `customer.data.country` | string · can be null | Customer country |
| `customer.data.phone` | string · can be null | Customer phone |
| `dueDate` | string · can be null | Invoice due date |
| `date` | string · can be null | Invoice issue date |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `items` | object\[\] · can be null | Invoice items |
| `items[].id` | string | Identifier of the item on the invoice |
| `items[].ref` | string · can be null | Item reference |
| `items[].meta` | object · can be null | Item metadata |
| `items[].meta.quantity` | number · can be null | Item quantity |
| `items[].meta.amountWithoutTax` | number · can be null | Amount without tax |
| `items[].meta.amountWithTax` | number · can be null | Amount with tax |
| `items[].meta.taxAmount` | number · can be null | Tax amount |
| `items[].meta.discountAmount` | number · can be null | Discount amount applied to the item |
| `items[].meta.unitAmountWithoutTax` | number · can be null | Unit amount without tax |
| `items[].meta.unitAmountWithTax` | number · can be null | Unit amount with tax |
| `items[].meta.withholdingTaxAmount` | number · can be null | Withholding tax amount |
| `items[].meta.withholdingTaxEnabled` | boolean · can be null | Withholding tax enabled |
| `items[].data` | object · can be null | Item data |
| `items[].data.name` | string · can be null | Item name |
| `items[].data.description` | string · can be null | Item description |
| `items[].data.type` | string | Item type |
| `items[].data.unitPrice` | number · can be null | Unit price |
| `items[].data.taxRate` | number · can be null | Tax rate |
| `items[].data.vatRate` | string · can be null | VAT rate |
| `items[].data.vatTerritory` | string · can be null | VAT territory |
| `items[].data.vatExemptionReason` | string · can be null | VAT exemption reason |
| `items[].data.isAutoVATEnabled` | boolean · can be null | Automatic VAT enabled |
| `items[].noteChangeKind` | string · can be null | Only 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[].noteChangeFrom` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line before this note. |
| `items[].noteChangeTo` | number · can be null | With 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).

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

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

| Field | Type | Description |
| --- | --- | --- |
| `parentInvoiceId` **required** | string | Identifier 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` **required** | string | Credit 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` |
| `reason` | string | Text description of the reason (required). If omitted, the reasonCode's default description is used. |
| `issue` | boolean | Issue the credit note immediately (true) or leave it as a draft (false). Issued by default. |
| `items` | object\[\] | 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` **required** | string | Identifier 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[].taxRate` | number | VAT 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[].quantity` | number | Returned 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[].unitPrice` | number | New 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. |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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"
}'
```

**TypeScript**

```shell
# 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)
```

```ts
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 });
```

**Python**

```shell
# 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)
```

```python
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)
```

**PHP**

```shell
# 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
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique credit note identifier |
| `number` | string · can be null | Credit note number. Null when created as a draft (issue: false); assigned on issue. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null when created as a draft (issue: false); assigned on issue. |
| `documentType` | string · can be null | Document type |
| `status` | string | Document status |
| `creditNoteReasonCode` | string · can be null | Credit 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` |
| `parentInvoiceId` | string · can be null | Identifier of the reversed invoice |
| `parentInvoiceNumber` | string · can be null | Number of the reversed invoice |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `customer` | object · can be null | Customer |
| `customer.ref` | string · can be null | Customer identifier |
| `customer.data` | object · can be null | Customer data |
| `customer.data.taxpayerNumber` | string · can be null | Tax number (NIF) |
| `customer.data.name` | string · can be null | Customer name |
| `customer.data.email` | string · can be null | Customer email |
| `customer.data.country` | string · can be null | Customer country |
| `customer.data.phone` | string · can be null | Customer phone |
| `items` | object\[\] · can be null | Credit note items |
| `items[].id` | string | Identifier of the item on the invoice |
| `items[].ref` | string · can be null | Item reference |
| `items[].meta` | object · can be null | Item metadata |
| `items[].meta.quantity` | number · can be null | Item quantity |
| `items[].meta.amountWithoutTax` | number · can be null | Amount without tax |
| `items[].meta.amountWithTax` | number · can be null | Amount with tax |
| `items[].meta.taxAmount` | number · can be null | Tax amount |
| `items[].meta.discountAmount` | number · can be null | Discount amount applied to the item |
| `items[].meta.unitAmountWithoutTax` | number · can be null | Unit amount without tax |
| `items[].meta.unitAmountWithTax` | number · can be null | Unit amount with tax |
| `items[].meta.withholdingTaxAmount` | number · can be null | Withholding tax amount |
| `items[].meta.withholdingTaxEnabled` | boolean · can be null | Withholding tax enabled |
| `items[].data` | object · can be null | Item data |
| `items[].data.name` | string · can be null | Item name |
| `items[].data.description` | string · can be null | Item description |
| `items[].data.type` | string | Item type |
| `items[].data.unitPrice` | number · can be null | Unit price |
| `items[].data.taxRate` | number · can be null | Tax rate |
| `items[].data.vatRate` | string · can be null | VAT rate |
| `items[].data.vatTerritory` | string · can be null | VAT territory |
| `items[].data.vatExemptionReason` | string · can be null | VAT exemption reason |
| `items[].data.isAutoVATEnabled` | boolean · can be null | Automatic VAT enabled |
| `items[].noteChangeKind` | string · can be null | Only 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[].noteChangeFrom` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line before this note. |
| `items[].noteChangeTo` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line after this note. |
| `summary` | object · can be null | Document summary |
| `summary.amountWithoutTax` | number · can be null | Amount without tax |
| `summary.amountWithTax` | number · can be null | Amount with tax |
| `summary.amountWithoutTaxWithoutDiscount` | number · can be null | Amount without tax and discount |
| `summary.taxAmount` | number · can be null | Tax amount |
| `summary.globalDiscountType` | string · can be null | Global discount type — One of: `AMOUNT`, `PERCENT` |
| `summary.globalDiscountPercent` | number · can be null | Global discount percentage |
| `summary.globalDiscountAmount` | number · can be null | Global discount amount |
| `summary.total` | number · can be null | Total |
| `summary.totalToPay` | number · can be null | Total payable |
| `summary.withholdingTaxAmount` | number · can be null | Withholding tax amount |
| `summary.creditNotesTotal` | number · can be null | Total 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

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique invoice identifier |

**curl**

```shell
curl 'https://api.fiz.co/invoices/ID' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

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

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.retrieve("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

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

### Response `200`

Invoice found

| Field | Type | Description |
| --- | --- | --- |
| `id` | string |  |
| `number` | string · can be null |  |
| `atcud` | string · can be null |  |
| `shortHash` | string · can be null |  |
| `documentType` | string · can be null |  |
| `status` | string |  |
| `updatedAt` | string (date-time) · can be null | Draft revision to pass as expectedUpdatedAt when issuing. |
| `date` | string (date-time) · can be null |  |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `dueDate` | string (date-time) · can be null |  |
| `currency` | string · can be null |  |
| `description` | string · can be null |  |
| `notes` | string · can be null |  |
| `cae` | string · can be null |  |
| `createdAt` | string (date-time) · can be null |  |
| `issuedAt` | string (date-time) · can be null |  |
| `parentInvoiceId` | string · can be null | The invoice that spawned this document. Populated on receipts, credit notes and debit notes; null on an invoice. |
| `parentInvoiceNumber` | string · can be null | Number of the originating invoice |
| `parentInvoiceDate` | string (date-time) · can be null | Date of the originating invoice |
| `parentInvoiceType` | string · can be null | Document type of the originating invoice |
| `isAdvance` | boolean · can be null | Advance invoice (an FT or FR recording a payment received in advance), to be deducted later in a final invoice. |
| `advanceBalance` | object · can be null | Advance invoices only: computed balance (not stored). remaining = total − deducted in live final invoices − refunded by ADVANCE\_REFUND credit notes. |
| `advanceBalance.total` | number | Taxable base of the advance |
| `advanceBalance.deducted` | number |  |
| `advanceBalance.refunded` | number |  |
| `advanceBalance.remaining` | number |  |
| `advanceBalance.byRate` | object\[\] |  |
| `advanceBalance.byRate[].vatRate` | string · can be null |  |
| `advanceBalance.byRate[].taxRate` | number |  |
| `advanceBalance.byRate[].exemptionCode` | string · can be null |  |
| `advanceBalance.byRate[].base` | number |  |
| `advanceBalance.byRate[].remaining` | number |  |
| `syncWithAt` | object · can be null |  |
| `syncWithAt.status` | string · can be null |  |
| `syncWithAt.atCode` | string · can be null |  |
| `syncWithAt.atMessage` | string · can be null |  |
| `series` | object · can be null |  |
| `series.ref` | string · can be null |  |
| `series.name` | string · can be null |  |
| `customer` | object · can be null |  |
| `customer.ref` | string · can be null |  |
| `customer.data` | object · can be null |  |
| `customer.data.name` | string · can be null |  |
| `customer.data.taxpayerNumber` | string · can be null |  |
| `customer.data.email` | string · can be null |  |
| `customer.data.address` | string · can be null |  |
| `customer.data.postalCode` | string · can be null |  |
| `customer.data.city` | string · can be null |  |
| `customer.data.country` | string · can be null |  |
| `customer.data.phone` | string · can be null |  |
| `customer.data.mobile` | string · can be null |  |
| `summary` | object · can be null |  |
| `summary.amountWithoutTax` | number · can be null |  |
| `summary.amountWithTax` | number · can be null |  |
| `summary.amountWithoutTaxWithoutDiscount` | number · can be null |  |
| `summary.taxAmount` | number · can be null |  |
| `summary.globalDiscountType` | string · can be null | One of: `PERCENT`, `AMOUNT` |
| `summary.globalDiscountPercent` | number · can be null |  |
| `summary.globalDiscountAmount` | number · can be null |  |
| `summary.total` | number · can be null |  |
| `summary.totalToPay` | number · can be null |  |
| `summary.withholdingTaxAmount` | number · can be null |  |
| `summary.creditNotesTotal` | number · can be null |  |
| `items` | object\[\] · can be null |  |
| `items[].id` | string |  |
| `items[].ref` | string · can be null |  |
| `items[].noteChangeKind` | string · can be null | Only 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[].noteChangeFrom` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line before this note. |
| `items[].noteChangeTo` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line after this note. |
| `items[].meta` | object · can be null |  |
| `items[].meta.quantity` | number · can be null |  |
| `items[].meta.amountWithoutTax` | number · can be null |  |
| `items[].meta.amountWithTax` | number · can be null |  |
| `items[].meta.taxAmount` | number · can be null |  |
| `items[].meta.discountAmount` | number · can be null |  |
| `items[].meta.unitItemDiscountPercent` | number · can be null |  |
| `items[].meta.unitItemDiscountAmount` | number · can be null |  |
| `items[].meta.unitDiscountPercent` | number · can be null |  |
| `items[].meta.unitDiscountAmount` | number · can be null |  |
| `items[].meta.unitAmountWithoutTax` | number · can be null |  |
| `items[].meta.unitAmountWithTax` | number · can be null |  |
| `items[].meta.withholdingTaxAmount` | number · can be null |  |
| `items[].meta.withholdingTaxEnabled` | boolean · can be null |  |
| `items[].data` | object · can be null |  |
| `items[].data.name` | string · can be null |  |
| `items[].data.description` | string · can be null |  |
| `items[].data.type` | string |  |
| `items[].data.unitPrice` | number · can be null |  |
| `items[].data.vatRate` | string · can be null |  |
| `items[].data.unitDiscountType` | string · can be null | One of: `PERCENT`, `AMOUNT` |
| `items[].data.unitDiscountPercent` | number · can be null |  |
| `items[].data.unitDiscountAmount` | number · can be null |  |
| `items[].kind` | string · can be null | ADVANCE\_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[].parentItemId` | string · can be null | With kind ADVANCE\_DEDUCTION: the `id` of the item line the deduction belongs to. |
| `items[].advanceRef` | object · can be null | With kind ADVANCE\_DEDUCTION: the advance invoice deducted. |
| `items[].advanceRef.invoiceId` | string |  |
| `items[].advanceRef.number` | string |  |
| `items[].advanceRef.date` | string (date-time) |  |
| `items[].advanceRef.paymentDate` | string (date-time) · can be null | Payment 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. |
| `payment` | object · can be null |  |
| `payment.method` | string · can be null |  |
| `payment.date` | string (date-time) · can be null |  |
| `qrCode` | object · can be null |  |
| `qrCode.url` | string · can be null |  |
| `qrCode.data` | string |  |
| `qrCode.imageData` | string |  |
| `issuer` | object · can be null |  |
| `issuer.ref` | string · can be null |  |
| `issuer.data` | object · can be null |  |
| `issuer.data.name` | string · can be null |  |
| `issuer.data.taxPayerNumber` | string · can be null |  |
| `issuer.data.address` | string · can be null |  |
| `issuer.data.city` | string · can be null |  |
| `issuer.data.postalCode` | string · can be null |  |
| `issuer.data.country` | string · 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

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique invoice identifier |

### Request body

Fields to update on the draft invoice

| Field | Type | Description |
| --- | --- | --- |
| `date` | string | Invoice issue date. When omitted, the date already stored on the invoice is kept. Determines the tax period the document falls in. |
| `dueDate` | string | Invoice 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. |
| `cae` | string | CAE code (Portuguese classification of economic activities) |
| `customerId` | string | Customer identifier |
| `seriesId` | string | Series identifier (optional). Use the "id" returned by GET /series. If omitted, the account's default series is used. |
| `notes` | string | Invoice notes (optional) |
| `items` | object\[\] | List of invoice items |
| `items[].id` **required** | string | Item identifier |
| `items[].quantity` **required** | number | Item quantity |
| `items[].unitPrice` | number | Unit 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[].unitPriceWithVat` | number | Unit 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[].discountType` | string | Discount 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[].discountPercent` | number | Discount percentage for this line (e.g. 10 for 10%). Requires discountType=PERCENT. |
| `items[].discountAmount` | number | Absolute per-unit discount amount for this line, before VAT. Requires discountType=AMOUNT. |
| `items[].withholdingTaxEnabled` | boolean | Apply 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[].withholdingTaxPercent` | number | Withholding 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. |
| `summary` | object | Invoice summary with global discount (optional) |
| `summary.globalDiscountType` | string | Global discount type — One of: `AMOUNT`, `PERCENT` |
| `summary.globalDiscountPercent` | number | Global discount percentage (e.g. 10 for 10%) |
| `summary.globalDiscountAmount` | number | Absolute global discount amount |
| `taxPointDate` | string · can be null | Date 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. |
| `payment` | object | Payment |
| `payment.method` **required** | string | Payment method — One of: `cash`, `card`, `bankTransfer`, `mbWay`, `multibanco`, `spin`, `other` |
| `payment.date` **required** | string | Payment date |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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"
}'
```

**TypeScript**

```ts
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',
});
```

**Python**

```python
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**

```php
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `number` | string · can be null | Document number. Null on a draft — it is assigned on issue. |
| `atcud` | string · can be null | Unique document code (ATCUD). Null on a draft — it is assigned on issue. |
| `shortHash` | string · can be null | Document hash summary (4 characters). Null on a draft — it is assigned on issue. |
| `documentType` | string · can be null | Document type |
| `status` | string | Invoice status |
| `updatedAt` | string (date-time) · can be null | Draft revision (updatedAt). Send it as expectedUpdatedAt when issuing: a draft changed in the meantime is refused. |
| `notes` | string · can be null | Invoice notes |
| `series` | object · can be null | Invoice series |
| `series.ref` | string · can be null | Series identifier |
| `series.name` | string · can be null | Series name |
| `payment` | object · can be null | Payment |
| `payment.method` | string · can be null | Payment method |
| `payment.date` | string · can be null | Payment date |
| `customer` | object · can be null | Customer |
| `customer.ref` | string · can be null | Customer identifier |
| `customer.data` | object · can be null | Customer data |
| `customer.data.taxpayerNumber` | string · can be null | Tax number (NIF) |
| `customer.data.name` | string · can be null | Customer name |
| `customer.data.email` | string · can be null | Customer email |
| `customer.data.country` | string · can be null | Customer country |
| `customer.data.phone` | string · can be null | Customer phone |
| `dueDate` | string · can be null | Invoice due date |
| `date` | string · can be null | Invoice issue date |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `items` | object\[\] · can be null | Invoice items |
| `items[].id` | string | Identifier of the item on the invoice |
| `items[].ref` | string · can be null | Item reference |
| `items[].meta` | object · can be null | Item metadata |
| `items[].meta.quantity` | number · can be null | Item quantity |
| `items[].meta.amountWithoutTax` | number · can be null | Amount without tax |
| `items[].meta.amountWithTax` | number · can be null | Amount with tax |
| `items[].meta.taxAmount` | number · can be null | Tax amount |
| `items[].meta.discountAmount` | number · can be null | Discount amount applied to the item |
| `items[].meta.unitAmountWithoutTax` | number · can be null | Unit amount without tax |
| `items[].meta.unitAmountWithTax` | number · can be null | Unit amount with tax |
| `items[].meta.withholdingTaxAmount` | number · can be null | Withholding tax amount |
| `items[].meta.withholdingTaxEnabled` | boolean · can be null | Withholding tax enabled |
| `items[].data` | object · can be null | Item data |
| `items[].data.name` | string · can be null | Item name |
| `items[].data.description` | string · can be null | Item description |
| `items[].data.type` | string | Item type |
| `items[].data.unitPrice` | number · can be null | Unit price |
| `items[].data.taxRate` | number · can be null | Tax rate |
| `items[].data.vatRate` | string · can be null | VAT rate |
| `items[].data.vatTerritory` | string · can be null | VAT territory |
| `items[].data.vatExemptionReason` | string · can be null | VAT exemption reason |
| `items[].data.isAutoVATEnabled` | boolean · can be null | Automatic VAT enabled |
| `items[].noteChangeKind` | string · can be null | Only 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[].noteChangeFrom` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line before this note. |
| `items[].noteChangeTo` | number · can be null | With 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

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique invoice identifier |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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}"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

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

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.delete("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

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

### Response `200`

Invoice deleted successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `createdAt` | string · can be null | Invoice 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.

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

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

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string |  |

### Request body

| Field | Type | Description |
| --- | --- | --- |
| `expectedUpdatedAt` | string (date-time) | Draft revision (updatedAt). Issuance is refused if the document has changed. |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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"
}'
```

**TypeScript**

```shell
# 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)
```

```ts
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 });
```

**Python**

```shell
# 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)
```

```python
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)
```

**PHP**

```shell
# 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
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `number` | string · can be null | Document number |
| `atcud` | string · can be null | Unique document code (ATCUD) |
| `shortHash` | string · can be null | Document hash summary (4 characters) printed on the PDF |
| `documentType` | string · can be null | Document type |
| `status` | string | Invoice status |
| `notes` | string · can be null | Invoice notes |
| `series` | object · can be null | Invoice series |
| `series.ref` | string · can be null | Series identifier |
| `series.name` | string · can be null | Series name |
| `payment` | object · can be null | Payment |
| `payment.method` | string · can be null | Payment method |
| `payment.date` | string · can be null | Payment date |
| `customer` | object · can be null | Customer |
| `customer.ref` | string · can be null | Customer identifier |
| `customer.data` | object · can be null | Customer data |
| `customer.data.taxpayerNumber` | string · can be null | Tax number (NIF) |
| `customer.data.name` | string · can be null | Customer name |
| `customer.data.email` | string · can be null | Customer email |
| `customer.data.country` | string · can be null | Customer country |
| `customer.data.phone` | string · can be null | Customer phone |
| `dueDate` | string · can be null | Invoice due date |
| `date` | string · can be null | Invoice issue date |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `items` | object\[\] · can be null | Invoice items |
| `items[].id` | string | Identifier of the item on the invoice |
| `items[].ref` | string · can be null | Item reference |
| `items[].meta` | object · can be null | Item metadata |
| `items[].meta.quantity` | number · can be null | Item quantity |
| `items[].meta.amountWithoutTax` | number · can be null | Amount without tax |
| `items[].meta.amountWithTax` | number · can be null | Amount with tax |
| `items[].meta.taxAmount` | number · can be null | Tax amount |
| `items[].meta.discountAmount` | number · can be null | Discount amount applied to the item |
| `items[].meta.unitAmountWithoutTax` | number · can be null | Unit amount without tax |
| `items[].meta.unitAmountWithTax` | number · can be null | Unit amount with tax |
| `items[].meta.withholdingTaxAmount` | number · can be null | Withholding tax amount |
| `items[].meta.withholdingTaxEnabled` | boolean · can be null | Withholding tax enabled |
| `items[].data` | object · can be null | Item data |
| `items[].data.name` | string · can be null | Item name |
| `items[].data.description` | string · can be null | Item description |
| `items[].data.type` | string | Item type |
| `items[].data.unitPrice` | number · can be null | Unit price |
| `items[].data.taxRate` | number · can be null | Tax rate |
| `items[].data.vatRate` | string · can be null | VAT rate |
| `items[].data.vatTerritory` | string · can be null | VAT territory |
| `items[].data.vatExemptionReason` | string · can be null | VAT exemption reason |
| `items[].data.isAutoVATEnabled` | boolean · can be null | Automatic VAT enabled |
| `items[].noteChangeKind` | string · can be null | Only 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[].noteChangeFrom` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line before this note. |
| `items[].noteChangeTo` | number · can be null | With noteChangeKind: the quantity or unit price of the invoice line after this note. |
| `syncWithAt` | object · can be null | AT synchronization status |
| `syncWithAt.status` | string · can be null | AT synchronization status |
| `syncWithAt.atCode` | string · can be null | AT code |
| `syncWithAt.atMessage` | string · can be null | AT message |
| `syncWithAt.systemError` | string · can be null | System error |
| `syncWithAt.isRetriable` | boolean · can be null | Can be retried |
| `syncWithAt.updatedAt` | string · can be null | Last 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.

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

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

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string | Unique invoice identifier |

### Request body

| Field | Type | Description |
| --- | --- | --- |
| `method` **required** | string | Payment method — One of: `cash`, `card`, `bankTransfer`, `mbWay`, `multibanco`, `spin`, `other` |
| `date` **required** | string | Payment date |
| `amount` | number | Amount paid (optional). When omitted, the full outstanding balance is settled. Minimum 0.01, at most two decimal places. |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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"
}'
```

**TypeScript**

```shell
# 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)
```

```ts
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 });
```

**Python**

```shell
# 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)
```

```python
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)
```

**PHP**

```shell
# 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
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `number` | string · can be null | Invoice number |
| `documentType` | string · can be null | Document type |
| `status` | string | Invoice status |
| `notes` | string · can be null | Invoice notes |
| `series` | object · can be null | Invoice series |
| `series.ref` | string · can be null | Series identifier |
| `series.name` | string · can be null | Series name |
| `payment` | object · can be null | Legacy field, populated only once the invoice is fully paid. On a partial payment it is null — use `payments`. |
| `payment.method` | string · can be null | Payment method |
| `payment.date` | string · can be null | Payment date |
| `payments` | object\[\] · can be null | Every payment registered against the invoice, including each amount. |
| `payments[].method` | string · can be null | Payment method |
| `payments[].date` | string · can be null | Payment date |
| `payments[].amount` | number · can be null | Amount paid |
| `receipt` | object · can be null | Receipt (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.id` | string | Unique receipt identifier — use it in GET /invoices/{id}/pdf |
| `receipt.number` | string · can be null | Receipt number |
| `receipt.atcud` | string · can be null | Unique document code (ATCUD) |
| `receipt.documentType` | string · can be null | Document type |
| `receipt.status` | string | Receipt status |
| `receipt.date` | string · can be null | Receipt issue date |
| `receipt.series` | object · can be null | Receipt series |
| `receipt.series.ref` | string · can be null | Series identifier |
| `receipt.series.name` | string · can be null | Series name |
| `customer` | object · can be null | Customer |
| `customer.ref` | string · can be null | Customer identifier |
| `customer.data` | object · can be null | Customer data |
| `customer.data.taxpayerNumber` | string · can be null | Tax number (NIF) |
| `customer.data.name` | string · can be null | Customer name |
| `customer.data.email` | string · can be null | Customer email |
| `customer.data.country` | string · can be null | Customer country |
| `customer.data.phone` | string · can be null | Customer phone |
| `dueDate` | string · can be null | Invoice due date |
| `date` | string · can be null | Invoice issue date |
| `taxPointDate` | string (date-time) · can be null | Date 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. |
| `items` | object\[\] · can be null | Invoice items |
| `items[].id` | string | Identifier of the item on the invoice |
| `items[].ref` | string · can be null | Item reference |
| `items[].meta` | object · can be null | Item metadata |
| `items[].meta.quantity` | number · can be null | Quantity |
| `items[].meta.taxAmount` | number · can be null | Tax amount |
| `items[].data` | object · can be null | Item data |
| `items[].data.name` | string · can be null | Item name |
| `items[].data.description` | string · can be null | Item description |
| `items[].data.type` | string | Item type |
| `items[].data.unitPrice` | number · can be null | Unit price |
| `items[].data.taxRate` | number · can be null | Tax rate |
| `items[].data.vatRate` | string · can be null | VAT rate |
| `items[].data.vatTerritory` | string · can be null | VAT territory |
| `items[].data.vatExemptionReason` | string · can be null | VAT exemption reason |
| `items[].data.isAutoVATEnabled` | boolean · can be null | Automatic VAT enabled |
| `syncWithAt` | object · can be null | AT synchronization status |
| `syncWithAt.status` | string · can be null | AT synchronization status |
| `syncWithAt.atCode` | string · can be null | AT code |
| `syncWithAt.atMessage` | string · can be null | AT message |
| `syncWithAt.systemError` | string · can be null | System error |
| `syncWithAt.isRetriable` | boolean · can be null | Can be retried |
| `syncWithAt.updatedAt` | string · can be null | Last 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).

> Fiscal act: this call creates, settles or cancels fiscal documents, and it cannot be undone. Rehearse it in the sandbox first (`fiz_test_` keys).

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

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string |  |

### Request body

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string | Reason for the annulment, reported to the AT in the SAF-T. Recommended; optional for backward compatibility. |

**curl**

```shell
# Once per operation. Keep it and reuse it on every retry.
IDEMPOTENCY_KEY=$(uuidgen)
```

```shell
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"
}'
```

**TypeScript**

```shell
# 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)
```

```ts
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 });
```

**Python**

```shell
# 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)
```

```python
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)
```

**PHP**

```shell
# 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
<?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

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Unique invoice identifier |
| `number` | string · can be null | Document number |
| `documentType` | string · can be null | Document type |
| `status` | string | Invoice status |
| `canceledAt` | string · can be null | Cancellation date |
| `syncWithAt` | object · can be null | AT synchronization status |
| `syncWithAt.status` | string · can be null | AT synchronization status |
| `syncWithAt.atCode` | string · can be null | AT code |
| `syncWithAt.atMessage` | string · can be null | AT message |
| `syncWithAt.systemError` | string · can be null | System error |
| `syncWithAt.isRetriable` | boolean · can be null | Can be retried |
| `syncWithAt.updatedAt` | string · can be null | Last 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

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `id` **required** | path | string |  |
| `isDuplicate` | query | boolean | Mark PDF as duplicate |
| `format` | query | string | PDF format — One of: `A4`, `RECEIPT`, `RECEIPT_58` |
| `templateId` | query | string | ID of the template to use |

**curl**

```shell
curl 'https://api.fiz.co/invoices/ID/pdf' \
  --header "x-api-key: $FIZ_API_KEY"
```

**TypeScript**

```ts
import { Fiz } from '@fiz-co/sdk';

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

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.invoices.pdf("ID")
```

**PHP**

```php
<?php
require 'vendor/autoload.php';

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

### Response `200`

PDF generated successfully

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | PDF file ID |
| `name` | string · can be null | PDF file name |
| `url` | string · can be null | PDF 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

-   [Company](https://api.fiz.co/docs/api/company) ([Markdown](https://api.fiz.co/docs/api/company.md))
-   [Customers](https://api.fiz.co/docs/api/customers) ([Markdown](https://api.fiz.co/docs/api/customers.md))
-   [Items](https://api.fiz.co/docs/api/items) ([Markdown](https://api.fiz.co/docs/api/items.md))
-   [Invoices](https://api.fiz.co/docs/api/invoices) ([Markdown](https://api.fiz.co/docs/api/invoices.md))
-   [Recurring invoices](https://api.fiz.co/docs/api/recurring-invoices) ([Markdown](https://api.fiz.co/docs/api/recurring-invoices.md))
-   [Pro formas](https://api.fiz.co/docs/api/pro-formas) ([Markdown](https://api.fiz.co/docs/api/pro-formas.md))
-   [Transport documents](https://api.fiz.co/docs/api/transport-documents) ([Markdown](https://api.fiz.co/docs/api/transport-documents.md))
-   [Series](https://api.fiz.co/docs/api/series) ([Markdown](https://api.fiz.co/docs/api/series.md))
-   [PDF templates](https://api.fiz.co/docs/api/pdf-templates) ([Markdown](https://api.fiz.co/docs/api/pdf-templates.md))
-   [Exports](https://api.fiz.co/docs/api/exports) ([Markdown](https://api.fiz.co/docs/api/exports.md))
-   [Expenses](https://api.fiz.co/docs/api/expenses) ([Markdown](https://api.fiz.co/docs/api/expenses.md))
-   [VAT](https://api.fiz.co/docs/api/vat) ([Markdown](https://api.fiz.co/docs/api/vat.md))
-   [Bank](https://api.fiz.co/docs/api/bank) ([Markdown](https://api.fiz.co/docs/api/bank.md))
