Home / Validate VAT / Spain

Validate Spanish VAT Numbers via API

Spain uses the NIF (Número de Identificación Fiscal) as its unified tax identifier. Companies formerly issued a CIF (Código de Identificación Fiscal); since 2008 all entities — including S.A. and S.L. companies — use the NIF format. Foreign nationals residing in Spain are issued a NIE (Número de Identidad de Extranjero). All three can appear as Spanish VAT numbers registered in the EU VIES system.

The TaxID API validates any Spanish VAT number against the AEAT (Agencia Estatal de Administración Tributaria) via VIES in real time, returning registration status, company name, and registered address. Standard IVA rate in Spain is 21%, with reduced rates of 10% and 4%.

QUICK START

curl -H "Authorization: Bearer YOUR_API_KEY" \
  http://localhost:3000/api/v1/validate/ES/ESA12345678

Code examples

Each example validates a Spanish company NIF (ESA12345678) and returns the VIES registration status with company details. Swap in any NIF, CIF, or NIE prefixed with ES.

const res = await fetch('http://localhost:3000/api/v1/validate/ES/ESA12345678', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const data = await res.json();
// {
//   valid: true,
//   status: "active",
//   company_name: "EXAMPLE EMPRESA S.L.",
//   country_code: "ES",
//   vat_number: "ESA12345678",
//   cached: false
// }
console.log(data.valid, data.company_name);

Spanish VAT identifier types

Spain has three distinct VAT number formats depending on the entity type. The TaxID API handles all three — you only need to prefix the identifier with ES as required by VIES.

TypeWhoFormatExample
NIF (empresa)Companies (S.A., S.L., etc.)ES + letter + 7 digits + letterESA12345678
NIF (persona física)Spanish individuals / autónomosES + 8 digits + letterES12345678Z
NIEForeign nationals in SpainES + X/Y/Z + 7 digits + letterESX1234567Z

Note: Not all Spanish individuals or autónomos are registered for IVA. The API returns valid: false for a correctly formatted NIF that is not enrolled in the VIES registry — which is expected for anyone exempt from IVA.

When to validate Spanish VAT numbers

B2B cross-border sales (intracomunitario)

EU VAT law (Directive 2006/112/EC) requires suppliers to verify a Spanish customer's NIF before zero-rating an intra-community supply under the reverse charge mechanism. If validation is skipped and the registration is inactive, your company is liable for the full 21% IVA plus interest.

E-commerce and SaaS checkout

Validating the NIF at checkout determines whether to charge 21% IVA (B2C) or zero-rate the invoice (B2B reverse charge). This affects invoicing, Modelo 303 quarterly returns, and Modelo 349 EC sales list reporting.

Supplier and marketplace onboarding

For ERP systems and DAC7-regulated marketplaces operating in Spain, validating a supplier's NIF during onboarding prevents rejected invoices and hacienda audit failures. Validate at onboarding and re-validate periodically to catch deregistrations.

Spanish entity verification (due diligence)

For KYB (Know Your Business) workflows, a VIES-confirmed NIF provides a first-layer check that the entity is legitimately registered with the AEAT. The API returns the registered company name and address, allowing you to cross-reference against other Spanish commercial registry data.

API response format

Every validation response includes the registration status, company name, registered address, and whether the result was served from cache.

{
  "valid": true,
  "status": "active",
  "vat_number": "ESA12345678",
  "country_code": "ES",
  "company_name": "EXAMPLE EMPRESA S.L.",
  "address": "CALLE MAYOR 1, 28001 MADRID",
  "cached": false,
  "validated_at": "2026-05-16T10:00:00Z"
}

Spain IVA rates

Spain applies the Impuesto sobre el Valor Añadido (IVA) across three tiers. The TaxID /rates endpoint returns these values programmatically.

Rate typeRateApplies to
Tipo general21%Most goods and services
Tipo reducido10%Food, water, hotel accommodation, passenger transport, cultural events
Tipo superreducido4%Basic foodstuffs (bread, cereals, milk), books & newspapers, medicines, prosthetics
B2B intra-community supply0%Reverse charge — customer accounts for IVA

Frequently asked questions

What is the difference between NIF, CIF, and NIE in Spain?

NIF (Número de Identificación Fiscal) is Spain's general tax identifier. CIF (Código de Identificación Fiscal) was the old name for the company identifier — since 2008, companies use NIF too, but the format differs: a letter prefix + 7 digits + a check digit letter (e.g. A12345678). Individuals use 8 digits + a letter (e.g. 12345678Z). NIE (Número de Identidad de Extranjero) is for foreign nationals residing in Spain, formatted as X/Y/Z + 7 digits + letter (e.g. X1234567Z). All three formats can be registered as Spanish VAT numbers in VIES.

How do I validate a Spanish company VAT number (CIF) via the API?

Send a GET request to http://localhost:3000/api/v1/validate/ES/{vat_number} with your API key. For a company (CIF format), the number follows ES + letter + 7 digits + letter, for example ESA12345678. The API checks the format locally then queries VIES against the Spanish AEAT (Agencia Estatal de Administración Tributaria) database and returns the registration status, company name, and registered address in real time.

Is Spanish VAT validation supported through VIES?

Yes. Spain is a full EU member state and the AEAT exposes Spanish VAT registrations through the EU VIES system. The TaxID API connects to VIES over the official SOAP endpoint, so validation reflects the live registration status in the Spanish tax authority's database — not a static list.

What is the Spanish IVA (VAT) rate?

Spain applies three IVA (Impuesto sobre el Valor Añadido) rates: the standard rate (tipo general) of 21%, a reduced rate (tipo reducido) of 10% for food, water, hotel accommodation, passenger transport, and cultural events, and a super-reduced rate (tipo superreducido) of 4% for basic foodstuffs (bread, cereals, milk), books, newspapers, medicines, and prosthetics. For B2B cross-border sales within the EU, the reverse charge mechanism applies and no IVA is charged.

Is VAT validation mandatory when selling to Spanish businesses?

Under EU VAT Directive 2006/112/EC, you must verify that your customer holds a valid VAT registration before zero-rating an intra-community B2B sale. If you sell without IVA to a Spanish customer whose registration is invalid or inactive, your company becomes liable for the full 21% IVA plus potential penalties. The TaxID API call takes under 400ms and provides the audit trail you need.

How do I handle Spain's three VAT identifier types in my code?

The TaxID API accepts any valid Spanish VAT identifier — CIF (company), NIF (individual), or NIE (foreign national) — as long as you prefix it with 'ES' as required by the VIES standard. The API validates the format regex, performs the VIES lookup, and returns the result. You don't need to pre-classify the identifier type before calling the endpoint.

How fast is Spanish VAT validation?

Cached results (previously validated in the last 24 hours) return in under 10ms. For uncached requests, the VIES SOAP call to the AEAT typically completes in 100–400ms depending on the AEAT server load. Active (valid) numbers are cached for 24 hours; invalid numbers are cached for 1 hour.

Can the API validate VAT numbers for Spanish freelancers (autónomos)?

Yes. Autónomos registered for VAT use their personal NIF as their VAT number — 8 digits followed by a letter (e.g. ES12345678Z). As long as they have registered with the AEAT for IVA purposes and appear in the VIES registry, the API will return a valid result. Note that not all autónomos are registered for IVA; the API will return invalid for those who are not.

Start validating Spanish VAT numbers

Free plan includes 100 validations/month. No credit card required.

Related guides

Also validate VAT in:

Concepts explained: