EU VAT validation in Deno
Validate EU VAT numbers in Deno using the built-in fetch API and TypeScript. Deployable to Deno Deploy with zero configuration — no npm install, no package.json needed.
Implementation steps
- 1
Use Deno's built-in fetch — no imports needed for HTTP
- 2
Load the API key from Deno.env or a .env file
- 3
Define a TypeScript interface for the VATResult response
- 4
Run with --allow-net --allow-env or deploy to Deno Deploy
Code example
Deno (TS)
// deno run --allow-net --allow-env validate_vat.ts
// Deploy to Deno Deploy — no npm install, no config
interface VATResult {
valid: boolean;
status: string;
company_name?: string;
company_address?: string;
}
async function validateVAT(
country: string,
vatNumber: string
): Promise<VATResult> {
const res = await fetch(
`http://localhost:3000/api/v1/validate/${country}/${vatNumber}`,
{ headers: { Authorization: `Bearer ${Deno.env.get("TAXID_API_KEY")}` } }
);
return res.json() as Promise<VATResult>;
}
const result = await validateVAT("DE", "DE123456789");
if (result.valid) {
console.log(`Valid EU business: ${result.company_name}`);
} else if (result.status === "service_unavailable") {
console.warn("VIES temporarily unavailable — retry later");
} else {
console.log("Invalid VAT number");
}cURL
curl "http://localhost:3000/api/v1/validate/DE/DE123456789" \
-H "Authorization: Bearer $TAXID_API_KEY"
# {
# "valid": true,
# "status": "active",
# "company_name": "Example GmbH",
# "company_address": "Musterstraße 1, 10115 Berlin",
# "cached": false
# }API response
The TaxID API returns a consistent JSON response for every validation request:
{
"valid": true,
"status": "active",
"country_code": "DE",
"vat_number": "123456789",
"company_name": "Example GmbH",
"company_address": "Musterstraße 1, 10115 Berlin",
"request_date": "2026-05-10T00:00:00.000Z",
"cached": false,
"request_id": "req_01j..."
}Error handling
The API uses a consistent Stripe-style error format. Always handle service_unavailable separately — VIES has occasional downtime and you should not reject valid customers during outages.
activeVAT number is valid and the business is registered
invalidVAT number format is wrong or not registered in VIES
service_unavailableVIES or the national system is temporarily down — retry later
Evaluating EU VAT APIs? Compare TaxID vs Vatstack, Vatlayer, Avalara →
Related use cases
Validate EU VAT numbers in Stripe Checkout
Add EU VAT validation to your Stripe checkout flow. Verify customer VAT numbers server-side before a...
UK VAT validation in Shopify B2B
Validate UK VAT numbers for B2B customers in Shopify. Required under UK Making Tax Digital rules for...
WooCommerce Spain NIF/CIF validation
Validate Spanish NIF and CIF numbers in WooCommerce checkout. Automatically apply B2B tax exemptions...