API reference

VAT

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

FieldTypeDescription
clientHasVat requiredbooleanWhether the customer has a VAT number (B2B). Use false for final consumers (B2C)
clientCountrystringCustomer country code (ISO 3166-1 alpha-2)
clientTerritorystringCustomer territory, Portugal only
One of: continental, azores, madeira
clientVatNumberstringCustomer 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
clientPostalCodestringCustomer postal code
clientIsTIENIbooleanWhether 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 requiredstringItem type
One of: PRODUCT, SERVICE
itemTextstringItem description
invoiceCaestringInvoice CAE (economic activity code)
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"
}'
import { Fiz } from '@fiz-co/sdk';

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

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.vat.calculate({
    "clientHasVat": False,
    "itemType": "SERVICE",
})
<?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

FieldTypeDescription
vatobjectVAT calculation result
vat.ratenumberApplicable 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.reasonnumber · can be nullExemption reason code (e.g. 40 = reverse charge, 16 = Art. 16), null when VAT applies
vat.textstringExplanatory text for the applied rate/exemption
clientobjectCustomer data used in the calculation
client.countrystringCustomer country used in the calculation (normalized)
client.territorystring · can be nullCustomer territory used in the calculation. For Portuguese B2B customers it can be resolved automatically from the postal code
client.viesnumber · can be nullValidated-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
warningstring · can be nullWarning about the calculation (if applicable)
warningCodestring · can be nullWarning 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

FieldTypeDescription
clientHasVat requiredbooleanWhether the customer has a VAT number (B2B). Use false for final consumers (B2C)
clientCountrystringCustomer country code (ISO 3166-1 alpha-2)
clientVatNumberstringCustomer VAT number to validate. For PT customers use the national NIF, without the country prefix (a "PT" prefix is removed automatically)
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
}'
import { Fiz } from '@fiz-co/sdk';

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

fiz = Fiz()  # reads FIZ_API_KEY
result = fiz.vat.validate_client({
    "clientHasVat": True,
})
<?php
require 'vendor/autoload.php';

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

Response 200

Verification performed successfully

FieldTypeDescription
validbooleanVerification 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