VAT Validation API

Validate European VAT numbers with format verification and database lookups. For Latvian VAT numbers, optionally retrieve complete company information from our comprehensive business registry.

28 EU Countries Supported

Format validation for all EU member states with comprehensive pattern matching and country-specific rules.

Latvian Database Integration

Real-time database validation for Latvian VAT numbers with optional company data retrieval.

Base URL

https://api.clients.lv/api/vat

Authentication & Permissions

All API endpoints require authentication using Bearer tokens with the following permission:

Required Permission

vat:read - Required for all VAT Validation API access

Provides access to VAT number validation and Latvian company data retrieval.

Authentication Example

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Accept: application/json" \
     -H "Content-Type: application/json" \
     -X POST https://api.clients.lv/api/vat/validate \
     -d '{"vat_number": "LV40203029397"}'

API Endpoints

POST /api/vat/validate

Validate VAT number format and optionally retrieve company data for Latvian VAT numbers.

Request Body

Parameter Type Required Description
vat_number string Yes VAT number to validate (with or without country prefix)
include_company boolean No Include company data for valid Latvian VAT numbers (default: false)

Example Requests

Basic VAT validation:

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Content-Type: application/json" \
     -X POST "https://api.clients.lv/api/vat/validate" \
     -d '{"vat_number": "LV40203029397"}'

VAT validation with company data:

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Content-Type: application/json" \
     -X POST "https://api.clients.lv/api/vat/validate" \
     -d '{"vat_number": "LV40203029397", "include_company": true}'

Validate German VAT number:

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Content-Type: application/json" \
     -X POST "https://api.clients.lv/api/vat/validate" \
     -d '{"vat_number": "DE123456789"}'

Response Examples

Valid Latvian VAT (format only):

{
  "valid": true,
  "vat_number": "LV40203029397",
  "country": "LV",
  "format_valid": true,
  "database_check": true,
  "exists_in_database": true,
  "vat_status": {
    "is_active": true,
    "registered_date": "2018-02-01",
    "excluded_date": null,
    "construction_industry": false,
    "company_name": "SIA \"Example Company\""
  }
}

Valid Latvian VAT with company data:

{
  "valid": true,
  "vat_number": "LV40203029397",
  "country": "LV",
  "format_valid": true,
  "database_check": true,
  "exists_in_database": true,
  "vat_status": {
    "is_active": true,
    "registered_date": "2018-02-01",
    "excluded_date": null,
    "construction_industry": false,
    "company_name": "SIA \"Example Company\""
  },
  "company_data": {
    "regcode": "40203029397",
    "name": "SIA \"Example Company\"",
    "type": "SIA",
    "type_text": "Sabiedrība ar ierobežotu atbildību",
    "address": "Rīga, Brīvības iela 1-1",
    "registered": "2018-01-15",
    "is_active": true,
    "is_liquidated": false
  }
}

Valid non-Latvian VAT (format validation only):

{
  "valid": true,
  "vat_number": "DE123456789",
  "country": "DE",
  "format_valid": true,
  "database_check": false,
  "exists_in_database": false,
  "vat_status": null
}

Invalid VAT number:

{
  "valid": false,
  "vat_number": "XX123",
  "error": "Unknown or unsupported country code: XX",
  "country": "XX",
  "format_valid": false
}
GET /api/vat/stats

Get VAT validation system statistics including database coverage and supported countries.

Example Request

curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     "https://api.clients.lv/api/vat/stats"

Response Example

{
  "total_vat_numbers": 15234,
  "active_vat_numbers": 14567,
  "excluded_vat_numbers": 667,
  "construction_companies": 1234,
  "supported_countries": {
    "total": 28,
    "with_database_support": ["LV"],
    "format_validation_only": [
      "LT", "EE", "DE", "FR", "GB", "IE", "IT", "ES", "PT", "NL", "BE",
      "AT", "DK", "FI", "SE", "PL", "CZ", "SK", "HU", "SI", "HR", "RO",
      "BG", "MT", "LU", "CY"
    ]
  },
  "last_updated": "2025-09-27T14:53:35.000000Z"
}

Supported Countries & Formats

The VAT Validation API supports format validation for all 28 EU member states. Database validation is currently available for Latvian VAT numbers only.

Database Validation

Latvia (LV) ✓ Full Support
  • Format validation
  • Database existence check
  • VAT status verification
  • Company data retrieval
  • Registration/exclusion dates
  • Construction industry indicator

Format Validation Only

All other EU countries support format validation with country-specific patterns:

🇱🇹 Lithuania (LT) 🇪🇪 Estonia (EE) 🇩🇪 Germany (DE) 🇫🇷 France (FR) 🇬🇧 United Kingdom (GB) 🇮🇪 Ireland (IE) 🇮🇹 Italy (IT) 🇪🇸 Spain (ES) 🇵🇹 Portugal (PT) 🇳🇱 Netherlands (NL) 🇧🇪 Belgium (BE) 🇦🇹 Austria (AT) 🇩🇰 Denmark (DK) 🇫🇮 Finland (FI) 🇸🇪 Sweden (SE) 🇵🇱 Poland (PL) 🇨🇿 Czech Republic (CZ) 🇸🇰 Slovakia (SK) 🇭🇺 Hungary (HU) 🇸🇮 Slovenia (SI) 🇭🇷 Croatia (HR) 🇷🇴 Romania (RO) 🇧🇬 Bulgaria (BG) 🇲🇹 Malta (MT) 🇱🇺 Luxembourg (LU) 🇨🇾 Cyprus (CY)

Error Responses

The API returns standard HTTP status codes and JSON error responses:

Authentication Errors

401 Unauthorized - Missing or invalid token

{
  "error": "Missing API token"
}

403 Forbidden - Insufficient permissions

{
  "error": "Insufficient permissions. Required: vat:read"
}

Validation Errors

422 Validation Error - Invalid request parameters

{
  "message": "The vat number field is required.",
  "errors": {
    "vat_number": ["The vat number field is required."]
  }
}

Common Status Codes

Code Status Description
200 OK VAT validation successful
401 Unauthorized Missing/invalid token
403 Forbidden Insufficient permissions
422 Validation Error Invalid request parameters
500 Server Error Internal server error

Code Examples

PHP Example

<?php

$apiToken = 'YOUR_API_TOKEN';
$baseUrl = 'https://api.clients.lv/api/vat';

// Validate VAT number with company data
$data = [
    'vat_number' => 'LV40203029397',
    'include_company' => true
];

$response = file_get_contents($baseUrl . '/validate', false, stream_context_create([
    'http' => [
        'method' => 'POST',
        'header' => [
            'Authorization: Bearer ' . $apiToken,
            'Content-Type: application/json',
            'Accept: application/json'
        ],
        'content' => json_encode($data)
    ]
]));

$result = json_decode($response, true);

if ($result['valid']) {
    echo "VAT Number: " . $result['vat_number'] . "\n";
    echo "Country: " . $result['country'] . "\n";

    if (isset($result['vat_status'])) {
        echo "VAT Status: " . ($result['vat_status']['is_active'] ? 'Active' : 'Inactive') . "\n";
        echo "Company: " . $result['vat_status']['company_name'] . "\n";
    }

    if (isset($result['company_data'])) {
        echo "Company Type: " . $result['company_data']['type_text'] . "\n";
        echo "Address: " . $result['company_data']['address'] . "\n";
    }
} else {
    echo "Invalid VAT number: " . $result['error'] . "\n";
}

JavaScript Example

const apiToken = 'YOUR_API_TOKEN';
const baseUrl = 'https://api.clients.lv/api/vat';

// Validate VAT number with company data
async function validateVAT(vatNumber, includeCompany = false) {
    try {
        const response = await fetch(`${baseUrl}/validate`, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiToken}`,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
            },
            body: JSON.stringify({
                vat_number: vatNumber,
                include_company: includeCompany
            })
        });

        const result = await response.json();

        if (result.valid) {
            console.log('VAT Number:', result.vat_number);
            console.log('Country:', result.country);

            if (result.vat_status) {
                console.log('VAT Status:', result.vat_status.is_active ? 'Active' : 'Inactive');
                console.log('Company:', result.vat_status.company_name);
            }

            if (result.company_data) {
                console.log('Company Type:', result.company_data.type_text);
                console.log('Address:', result.company_data.address);
            }
        } else {
            console.log('Invalid VAT number:', result.error);
        }

        return result;

    } catch (error) {
        console.error('Error:', error);
    }
}

// Usage examples
validateVAT('LV40203029397', true);  // Latvian VAT with company data
validateVAT('DE123456789');          // German VAT (format only)

Integration Notes

Format Validation: All EU VAT numbers are validated against country-specific patterns and rules.
Database Integration: Latvian VAT numbers are checked against our real-time government data.
Daily Updates: Latvian VAT data is updated daily from official government sources.
Rate Limiting: Standard API rate limits apply. Consider caching results for frequently validated VAT numbers.