Home / VAT API / Integrations / Laravel
Laravel EU VAT Validation API
Add EU VAT validation to your Laravel application with the TaxID API. Wire it into a Form Request validation rule, a dedicated service class, or a queued job so a business customer's VAT number is checked against VIES before you apply reverse-charge treatment or persist it to your database.
Quick start
CURL
curl -H "Authorization: Bearer YOUR_API_KEY" \ https://www.taxid.dev/api/v1/validate/DE/DE123456789
Code example
Full integration example including error handling for service_unavailable responses from VIES.
PHP (Laravel service)
<?php
// app/Services/VatValidator.php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class VatValidator
{
public static function check(string $country, string $vat): array
{
return Http::withToken(config('services.taxid.key'))
->timeout(10)
->get("https://www.taxid.dev/api/v1/validate/{$country}/{$vat}")
->json();
}
}
// Usage in a controller or action
$result = VatValidator::check('DE', 'DE123456789');
if ($result['status'] === 'active') {
// Valid EU business — apply reverse charge
$customer->update([
'vat_number' => $result['vat_number'],
'vat_company' => $result['company_name'],
'vat_validated_at' => now(),
]);
} elseif ($result['status'] === 'service_unavailable') {
// VIES down — allow through and re-check later
ReValidateVat::dispatch($customer)->delay(now()->addMinutes(5));
}PHP (Form Request rule)
<?php
// app/Rules/ValidVatNumber.php — php artisan make:rule ValidVatNumber
namespace App\Rules;
use App\Services\VatValidator;
use Illuminate\Contracts\Validation\Rule;
class ValidVatNumber implements Rule
{
public function passes($attribute, $value): bool
{
$country = strtoupper(substr($value, 0, 2));
$result = VatValidator::check($country, $value);
// Treat a VIES outage as a soft pass, not a failure
return $result['status'] !== 'invalid';
}
public function message(): string
{
return 'The :attribute is not a valid, registered EU VAT number.';
}
}
// In your Form Request rules():
// 'vat_number' => ['required', 'string', new ValidVatNumber],API response
The TaxID API returns a consistent JSON response for every validation:
{
"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..."
}activeVAT number is valid and the business is registered
invalidVAT number format is wrong or not registered in VIES
service_unavailableVIES or the national authority is temporarily down — retry later, do not silently zero-rate
Implementation steps
- 1
Get a free TaxID API key
Sign up at taxid.dev/signup — no credit card required, 100 validations/month on the free plan. Add the key to your .env file as TAXID_API_KEY and reference it through config/services.php rather than reading env() directly, so it works under config:cache in production.
- 2
Create a VatNumber service
Add an App\Services\VatValidator class that wraps Laravel's Http client (Illuminate\Support\Facades\Http). Call Http::withToken(config('services.taxid.key'))->get("https://www.taxid.dev/api/v1/validate/{$country}/{$vat}") and return the decoded JSON. Set a timeout of 10 seconds so a slow VIES lookup never hangs a request.
- 3
Enforce it with a Form Request rule
Generate a custom rule with php artisan make:rule ValidVatNumber and call the service inside passes(). Attach the rule to your checkout or onboarding Form Request so an invalid number is rejected with a validation error before it ever reaches your controller. Treat a status of 'service_unavailable' as a soft-pass, not a failure.
- 4
Store the validated result
When status === 'active', persist the returned company_name, company_address, and a validated_at timestamp alongside the VAT number on your Customer model. This gives you the audit trail a tax authority will ask for, and lets you skip re-validation for numbers checked within the cache window.
- 5
Re-validate subscriptions with a scheduled command
For recurring billing, add an Artisan command to app/Console/Kernel.php scheduled monthly that re-checks every customer flagged for reverse-charge. VAT registrations can be cancelled between billing cycles, and you need proof the number was valid at the time of each invoice — dispatch the checks onto a queue to avoid rate limits.
Frequently asked questions
How do I validate a VAT number inside a Laravel Form Request?
Create a custom rule class with php artisan make:rule ValidVatNumber, inject your VatValidator service, and call the TaxID API inside the passes() method. Return true only when the response status is 'active'. Reference the rule in the rules() array of your Form Request so Laravel rejects invalid numbers automatically and returns a 422 with your message.
Should I call the TaxID API from a Livewire or Blade component directly?
No — always validate from server-side code (a service class, Form Request, or job), never from Alpine/JavaScript in the browser, because that would expose your API key. In Livewire, call the service from an action method on the server and bind only the boolean result back to the view.
How should I handle a VIES timeout in a Laravel queue job?
The TaxID API returns status 'service_unavailable' when VIES is temporarily down. In a queued job, do not mark the number invalid — instead release the job back onto the queue with a delay ($this->release(300)) so it retries after five minutes. Configure tries and backoff on the job class to cap the retries.
Which EU countries can I validate from Laravel?
All 27 EU member states via VIES, plus the UK (HMRC), Norway (Brønnøysund), Switzerland, and Australia (ABN). The endpoint and your Laravel service code are identical for every country — you pass the two-letter country code and the number, and the API routes to the correct authority.
Country-specific API docs:
In-depth integration guide:
EU VAT validation in PHP / Laravel
Validate EU VAT numbers in PHP applications with Laravel, Symfony, or plain PHP. Includes service class, validation rule, and database storage pattern.
Start validating EU VAT numbers in Laravel
Free plan — 100 validations/month. No credit card required.