# VAT

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

VAT helpers: the rate for a sale, and whether a customer’s VAT number is valid. 2 operations.

## Calculate VAT

POST `/vat/calculate`

Calculates the correct VAT rate for a sale based on the customer's country and type (B2C individual / B2B company), including OSS, reverse charge, intra-community exemption and the Portuguese territories. Does not create any invoice. Always returns the standard rate of the applicable regime (or 0% with the corresponding exemption reason); choosing reduced/intermediate rates per item category is the integrator's responsibility. Requires a plan with the Auto VAT feature.

Authentication: an API key (`x-api-key`).

### Request body

Customer and item data for the VAT calculation

| Field | Type | Description |
| --- | --- | --- |
| `clientHasVat` **required** | boolean | Whether the customer has a VAT number (B2B). Use false for final consumers (B2C) |
| `clientCountry` | string | Customer country code (ISO 3166-1 alpha-2) |
| `clientTerritory` | string | Customer territory, Portugal only — One of: `continental`, `azores`, `madeira` |
| `clientVatNumber` | string | Customer VAT number. For PT customers use the national NIF, without the country prefix (a "PT" prefix is removed automatically); for other EU countries it is validated via VIES |
| `clientPostalCode` | string | Customer postal code |
| `clientIsTIENI` | boolean | Whether the individual customer is a sole trader (TI/ENI — Trabalhador Independente or Empresário em Nome Individual). Used to resolve the territory of Portuguese B2B customers with an individual's NIF |
| `itemType` **required** | string | Item type — One of: `PRODUCT`, `SERVICE` |
| `itemText` | string | Item description |
| `invoiceCae` | string | Invoice CAE (economic activity code) |

**curl**

```shell
curl --request POST 'https://api.fiz.co/vat/calculate' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "clientHasVat": false,
  "itemType": "SERVICE"
}'
```

**TypeScript**

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

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.vat.calculate({
  clientHasVat: false,
  itemType: 'SERVICE',
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.vat.calculate({
    "clientHasVat": False,
    "itemType": "SERVICE",
})
```

**PHP**

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

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->vat->calculate([
    'clientHasVat' => false,
    'itemType' => 'SERVICE',
]);
```

### Response `200`

VAT calculation performed successfully

| Field | Type | Description |
| --- | --- | --- |
| `vat` | object | VAT calculation result |
| `vat.rate` | number | Applicable VAT rate (percentage). It is always the standard rate of the determined regime/territory (e.g. 23% mainland PT, 16% Azores, the customer country's standard rate under OSS) or 0 in case of exemption. Reduced and intermediate rates are not determined — if the item qualifies for a reduced rate, it is up to the integrator to select it when creating the invoice |
| `vat.reason` | number · can be null | Exemption reason code (e.g. 40 = reverse charge, 16 = Art. 16), null when VAT applies |
| `vat.text` | string | Explanatory text for the applied rate/exemption |
| `client` | object | Customer data used in the calculation |
| `client.country` | string | Customer country used in the calculation (normalized) |
| `client.territory` | string · can be null | Customer territory used in the calculation. For Portuguese B2B customers it can be resolved automatically from the postal code |
| `client.vies` | number · can be null | Validated-VAT-number indicator used in the calculation (0 or 1). Explains why an EU B2B sale did (or did not) get reverse charge / intra-community exemption. Mind the semantics: for EU countries (except PT) it reflects VIES validation; for PT and non-EU customers only the presence of a number; if the VIES service is unavailable, the clientHasVat value provided in the request is used |
| `warning` | string · can be null | Warning about the calculation (if applicable) |
| `warningCode` | string · can be null | Warning code (if applicable) |

### Errors

-   `400` Invalid data
-   `401` Unauthorized - API key missing or invalid
-   `402` Auto VAT feature not available on the current plan - upgrade required

## Verify customer VAT number

POST `/vat/validate-client`

Verifies a customer's VAT number. For EU countries (except PT) validation is done via VIES (with a 24-hour cache); for PT and non-EU customers only the presence of a number is checked — the returned value does not guarantee the number exists. If VIES is unavailable, the provided clientHasVat value is returned. Does not create any record.

Authentication: an API key (`x-api-key`).

### Request body

Customer data for VAT number verification

| Field | Type | Description |
| --- | --- | --- |
| `clientHasVat` **required** | boolean | Whether the customer has a VAT number (B2B). Use false for final consumers (B2C) |
| `clientCountry` | string | Customer country code (ISO 3166-1 alpha-2) |
| `clientVatNumber` | string | Customer VAT number to validate. For PT customers use the national NIF, without the country prefix (a "PT" prefix is removed automatically) |

**curl**

```shell
curl --request POST 'https://api.fiz.co/vat/validate-client' \
  --header "x-api-key: $FIZ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "clientHasVat": true
}'
```

**TypeScript**

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

const fiz = new Fiz(); // reads FIZ_API_KEY
const result = await fiz.vat.validateClient({
  clientHasVat: true,
});
```

**Python**

```python
from fiz_sdk import Fiz

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.vat.validate_client({
    "clientHasVat": True,
})
```

**PHP**

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

$fiz = new Fiz\Fiz(); // reads FIZ_API_KEY
$result = $fiz->vat->validateClient([
    'clientHasVat' => true,
]);
```

### Response `200`

Verification performed successfully

| Field | Type | Description |
| --- | --- | --- |
| `valid` | boolean | Verification result. Mind the semantics: for EU countries (except PT) the number is validated via VIES; for PT and non-EU customers only the presence of a number is checked (any non-empty value returns true). If the VIES service is unavailable, the clientHasVat value provided in the request is returned |

### Errors

-   `400` Invalid data
-   `401` Unauthorized - API key missing or invalid

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