Home / VAT API / Integrations / PHP

PHP

PHP EU VAT Validation API

Validate EU VAT numbers from PHP backends using cURL or Guzzle. Works with Laravel, Symfony, WordPress, and plain PHP. Returns live company data from VIES in a single REST call — no SOAP or XML required.

VIES-backedSub-100ms cachedFree plan available27 EU countries

Quick start

CURL

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

Code example

Full integration example including error handling for service_unavailable responses from VIES.

PHP (cURL)

<?php
$country   = 'DE';
$vatNumber = 'DE123456789';
$apiKey    = getenv('TAXID_API_KEY');

$ch = curl_init("http://localhost:3000/api/v1/validate/{$country}/{$vatNumber}");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER     => ["Authorization: Bearer {$apiKey}"],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT        => 10,
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

if ($data['valid']) {
    echo "Active EU business: " . $data['company_name'];
} elseif ($data['status'] === 'service_unavailable') {
    // VIES is down — do not silently zero-rate
    throw new \RuntimeException('VIES unavailable — retry later');
} else {
    echo "Invalid VAT number";
}

PHP (Guzzle)

<?php
// Using Guzzle: composer require guzzlehttp/guzzle
use GuzzleHttp\Client;

$client = new Client([
    'base_uri' => 'http://localhost:3000',
    'timeout'  => 10,
]);

$response = $client->get('/api/v1/validate/DE/DE123456789', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('TAXID_API_KEY'),
    ],
]);

$data = json_decode($response->getBody(), true);

if ($data['valid']) {
    echo "Active EU business: " . $data['company_name'];
}

API response

The TaxID API returns a consistent JSON response for every validation:

200 OK — valid numbervalid
{
  "valid": true,
  "status": "active",
  "country_code": "DE",
  "vat_number": "DE123456789",
  "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..."
}
active

VAT number is valid and the business is registered

invalid

VAT number format is wrong or not registered in VIES

service_unavailable

VIES or the national authority is temporarily down — retry later, do not silently zero-rate

Implementation steps

  1. 1

    Get a free TaxID API key

    Sign up at taxid.dev/signup. Store your API key in your .env file as TAXID_API_KEY and load it with getenv() or your framework's config (config('services.taxid.key') in Laravel, $this->getParameter() in Symfony).

  2. 2

    Make a GET request with cURL or Guzzle

    Use curl_init() and curl_exec() for plain PHP or WordPress, or the GuzzleHttp\Client for Laravel and Symfony. Both approaches send the Authorization header with your API key and parse the JSON response.

  3. 3

    Parse the JSON response

    Call json_decode($body, true) to get an associative array. Check $data['valid'] === true for an active EU business. The $data['status'] field can be 'active', 'invalid', 'not_found', or 'service_unavailable'.

  4. 4

    Handle errors and service downtime

    Throw a distinct exception for status 'service_unavailable' so you can handle it separately from a genuinely invalid VAT number. A good fallback: charge standard VAT, log the event, and queue the customer for re-validation once VIES recovers.

Frequently asked questions

Do I need a SOAP library to validate EU VAT numbers from PHP?

No. TaxID exposes a simple REST/JSON API — no SOAP, no XML, no PHP SoapClient required. A single curl_exec() or Guzzle request is all you need. This avoids the complexity and maintenance burden of working with the raw VIES SOAP endpoint directly.

How do I call the TaxID API from Laravel?

Use Laravel's built-in Http facade: Http::withToken(config('services.taxid.key'))->get('/api/v1/validate/DE/DE123456789')->json(). This wraps Guzzle under the hood and handles JSON parsing, timeout configuration, and retry logic cleanly.

Can I use the TaxID API in WordPress via wp_remote_get?

Yes. WordPress's wp_remote_get() function handles cURL internally and works with any REST API. Pass the Authorization header in the 'headers' array option. Use is_wp_error() to handle network failures gracefully rather than crashing.

How do I validate EU VAT numbers in batch from PHP?

Use the batch endpoint: POST /api/v1/validate with Content-Type: application/json and a body containing a 'numbers' array of up to 25 objects, each with 'country' and 'vat'. Process the response array 1-to-1 with your input for bulk customer onboarding or reconciliation.

Country-specific API docs:

Start validating EU VAT numbers in PHP

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

Other integrations

Stripe

Validate EU VAT numbers before applying Stripe reverse-charge

Shopify

EU VAT validation for Shopify B2B storefronts

Node.js

EU VAT validation in Node.js with a single HTTP call

Python

Validate EU VAT numbers from Python with requests or httpx