# EU VAT validation

> POST /vat checks an EU VAT number: national format rules, then a live VIES check, with the registered name and address when the member state shares them.

`POST https://api.qelka.com/v1/vat`

Check an EU VAT number before you invoice a business in another member state: the API checks the national format, then asks VIES, the VAT Information Exchange System of the European Commission, whether the number is active for intra-EU trade, with the registered name and address when the member state shares them. Each check costs 1 credit; answers VIES could not give, errors and test keys are never billed.

## Request

Send the number with its country prefix, or without it and with `country`. Numbers of the 27 EU member states and of Northern Ireland (`XI`) can be checked.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `vat` | string | Yes | none | The VAT number, 2 to 40 characters, with its country prefix (`IE6388047V`, `FR 40 303 265 045`) or without it when you send `country`. Spaces, dots, hyphens and slashes are ignored, and lower case is accepted. |
| `country` | string | No | none | The member state of a number sent without its prefix: an ISO 3166-1 alpha-2 code, or `EL` for Greece and `XI` for Northern Ireland. `GR` is read as `EL`. |
| `requester` | string | No | none | Your own EU VAT number with its prefix, 4 to 40 characters. VIES then returns a consultation number for the check. |
| `fresh` | boolean | No | `false` | `true` skips the 24-hour result cache and asks VIES again. |

VIES can take several seconds to answer, so every snippet sets a 30-second client timeout.

```bash title="cURL"
curl https://api.qelka.com/v1/vat \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vat": "IE6388047V"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/vat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ vat: 'IE6388047V' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/vat",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"vat": "IE6388047V"},
    timeout=30,
)
result = response.json()
print(result)
```
```php title="PHP"
<?php
$ch = curl_init('https://api.qelka.com/v1/vat');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('QELKA_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode(['vat' => 'IE6388047V']),
    CURLOPT_TIMEOUT => 30,
]);
$result = json_decode(curl_exec($ch), true);
print_r($result);
```
```go title="Go"
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	payload, _ := json.Marshal(map[string]any{"vat": "IE6388047V"})
	request, _ := http.NewRequest(http.MethodPost, "https://api.qelka.com/v1/vat", bytes.NewReader(payload))
	request.Header.Set("Authorization", "Bearer "+os.Getenv("QELKA_API_KEY"))
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(response.Body).Decode(&result); err != nil {
		panic(err)
	}
	fmt.Println(result)
}
```
```ruby title="Ruby"
require 'json'
require 'net/http'

uri = URI('https://api.qelka.com/v1/vat')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV.fetch('QELKA_API_KEY')}"
request['Content-Type'] = 'application/json'
request.body = JSON.generate({ vat: 'IE6388047V' })

response = Net::HTTP.start(uri.host, uri.port, use_ssl: true, read_timeout: 30) do |http|
  http.request(request)
end
result = JSON.parse(response.body)
puts result
```

## Response

Every number that can be read gets a `200`. Read `status`: `valid`, `invalid` or `unavailable`.

| Field | Type | Description |
|---|---|---|
| `id` | string | Identifier of this lookup: `lkp_` followed by 26 characters. |
| `object` | string | Always `vat`. |
| `input` | string | The `vat` you sent, without surrounding spaces. |
| `country` | object | The member state of the number. Northern Ireland numbers report the United Kingdom. |
| `country.code` | string | ISO 3166-1 alpha-2 code, such as `IE`. |
| `country.name` | string | English short name, such as `Ireland`. |
| `prefix` | string | The VAT prefix: the ISO code, except `EL` for Greece and `XI` for Northern Ireland. |
| `vat_number` | string | The number without its prefix, upper case, without separators. |
| `formatted` | string | Prefix and number together, as written on invoices. |
| `format_valid` | boolean | `true` when the number follows the national format of its member state. |
| `valid` | boolean or null | `true` when VIES confirms the number, `false` when the format or VIES says no, `null` when VIES could not answer. |
| `status` | string | `valid`, `invalid` or `unavailable`. |
| `reason` | string or null | Why the number is invalid or could not be checked. `null` when it is valid. Every value is in the status table that follows. |
| `name` | string or null | The registered name, when the member state shares it through VIES. Only returned for valid numbers. |
| `address` | string or null | The registered address on one line, when the member state shares it. Only returned for valid numbers. |
| `vies` | object | What VIES answered. |
| `vies.checked` | boolean | `true` when VIES answered for this number. |
| `vies.request_date` | string or null | Date and time of the VIES check, as VIES reports it, in ISO 8601. |
| `vies.consultation_number` | string or null | The VIES consultation number, when you sent `requester` and VIES issued one. |
| `credits_used` | integer | 1 with a live key, `0` when `status` is `unavailable` or with a test key. |
| `cached` | boolean | `true` when the answer came from the 24-hour cache. |

```json title="Response"
{
  "id": "lkp_01M85R2A3R34P0X54YZRHHCNPV",
  "object": "vat",
  "input": "IE6388047V",
  "country": { "code": "IE", "name": "Ireland" },
  "prefix": "IE",
  "vat_number": "6388047V",
  "formatted": "IE6388047V",
  "format_valid": true,
  "valid": true,
  "status": "valid",
  "reason": null,
  "name": "GOOGLE IRELAND LIMITED",
  "address": "3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4",
  "vies": {
    "checked": true,
    "request_date": "2026-11-24T03:02:23.528Z",
    "consultation_number": null
  },
  "credits_used": 1,
  "cached": false
}
```

## Act on the status

| `status` | `reason` | What it means | What to do | Billed |
|---|---|---|---|---|
| `valid` | `null` | VIES confirms the number is active for intra-EU trade. | Accept it. Keep `formatted` and `vies.request_date` with the invoice as a record of the check. | Yes |
| `invalid` | `invalid_format` | The number does not follow the national format, or VIES rejected it as malformed. When the format check fails, VIES is not called. | Ask the customer to check the number. | Yes |
| `invalid` | `not_registered` | VIES answers that the number is not valid for intra-EU transactions: unknown, or not activated for cross-border trade. | Do not treat it as a valid EU VAT number until the customer gives one VIES confirms. | Yes |
| `unavailable` | `ms_unavailable` | The national service of the member state is not available to VIES. | Check again a few minutes later. | No |
| `unavailable` | `timeout` | VIES or the national service did not answer in time. | Check again a few minutes later. | No |
| `unavailable` | `service_unavailable` | VIES itself did not answer, or answered with an error the API does not know. | Check again a few minutes later. | No |
| `unavailable` | `ms_max_concurrent_req`, `global_max_concurrent_req` | Too many checks were running at once at the member state or at VIES. | Check again shortly, and spread your checks out. | No |
| `unavailable` | `vat_blocked`, `ip_blocked` | VIES refused to check this number or this request. | Check again later. If it persists, write to support@qelka.com. | No |

An `unavailable` answer is never cached and never billed, and it says nothing about the number: do not treat it as invalid. The European Commission publishes the availability of each member state's service on the VIES site.

## Plan for slow answers

VIES forwards each check to the national service of the member state, which can take several seconds. The API waits up to 12 seconds for an answer and, when VIES reports too many concurrent requests and time allows, tries once more. When there is still no answer, you get a `200` with `status: "unavailable"`, not an error.

Set your client timeout to 30 seconds, or check numbers in a background job. In a [batch](https://qelka.com/docs/api-reference/batch), at most 2 VAT checks run at the same time, so a batch of many VAT numbers takes longer than other batches.

## Keep proof of the check

Send your own EU VAT number in `requester`, and VIES returns a consultation number in `vies.consultation_number`. VIES issues it so that you can show a tax administration that you checked a given number at a given time.

Cached answers keep the consultation number and request date of the original check, and answers with and without `requester` are cached separately. Send `"fresh": true` when you need a new consultation number.

## Read the name and address

Each member state decides whether VIES returns the registered name and address. Ireland shares them, as the response example shows. Germany does not: its answers carry dashes, which the API turns into `null`. Name and address are only returned when the number is valid.

## Which formats are checked

Before calling VIES, the API checks the structure each member state uses, as the VIES FAQ describes it. Some of them:

| Prefix | Member state | Format | Example |
|---|---|---|---|
| `AT` | Austria | `U` and 8 digits | `ATU13585627` |
| `DE` | Germany | 9 digits | `DE811569869` |
| `EL` | Greece | 9 digits | `EL094014201` |
| `ES` | Spain | 9 characters, the first or the last a letter | `ESA28015865` |
| `FR` | France | 2 letters or digits (not `I` or `O`), then 9 digits | `FR40303265045` |
| `IE` | Ireland | 7 digits and 1 or 2 letters, or the older 8-character form | `IE6388047V` |
| `NL` | Netherlands | 9 digits, `B`, 2 digits | `NL004495445B01` |
| `SE` | Sweden | 10 digits and `01` | `SE556188840401` |
| `XI` | Northern Ireland | 9 or 12 digits, or `GD` or `HA` and 3 digits | `XI925901618` |

## Examples

### Send a number without its prefix

Send the number and its member state in `country`. Germany confirms the number but shares neither name nor address.

```bash title="cURL"
curl https://api.qelka.com/v1/vat \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vat": "811569869", "country": "DE"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/vat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ vat: '811569869', country: 'DE' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/vat",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"vat": "811569869", "country": "DE"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714B6J6B7HC5JX69P5TAK3",
  "object": "vat",
  "input": "811569869",
  "country": { "code": "DE", "name": "Germany" },
  "prefix": "DE",
  "vat_number": "811569869",
  "formatted": "DE811569869",
  "format_valid": true,
  "valid": true,
  "status": "valid",
  "reason": null,
  "name": null,
  "address": null,
  "vies": {
    "checked": true,
    "request_date": "2026-11-24T20:27:24.465Z",
    "consultation_number": null
  },
  "credits_used": 1,
  "cached": false
}
```

### Catch a malformed number before VIES

A German number has 9 digits. This one has 5, so the API answers at once without calling VIES. The answer is billed, because the check ran.

```bash title="cURL"
curl https://api.qelka.com/v1/vat \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vat": "DE12345"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/vat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ vat: 'DE12345' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/vat",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"vat": "DE12345"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714C3VPPF3J7M0ZEJCHYVR",
  "object": "vat",
  "input": "DE12345",
  "country": { "code": "DE", "name": "Germany" },
  "prefix": "DE",
  "vat_number": "12345",
  "formatted": "DE12345",
  "format_valid": false,
  "valid": false,
  "status": "invalid",
  "reason": "invalid_format",
  "name": null,
  "address": null,
  "vies": {
    "checked": false,
    "request_date": null,
    "consultation_number": null
  },
  "credits_used": 1,
  "cached": false
}
```

### Test the unavailable path

Test keys never call VIES. After the format check, a number ending in `0000` is not registered, one ending in `9999` is unavailable, and any other well-formed number is valid, with the sample name `EXAMPLE TRADING LTD`. With a test key in `QELKA_API_KEY`, this request returns:

```bash title="cURL"
curl https://api.qelka.com/v1/vat \
  --max-time 30 \
  -H "Authorization: Bearer $QELKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vat": "DE123459999"}'
```
```javascript title="Node.js"
const response = await fetch('https://api.qelka.com/v1/vat', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.QELKA_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ vat: 'DE123459999' }),
  signal: AbortSignal.timeout(30_000),
})
const result = await response.json()
console.log(result)
```
```python title="Python"
import os

import requests

api_key = os.environ["QELKA_API_KEY"]
response = requests.post(
    "https://api.qelka.com/v1/vat",
    headers={"Authorization": f"Bearer {api_key}"},
    json={"vat": "DE123459999"},
    timeout=30,
)
result = response.json()
print(result)
```

```json title="Response"
{
  "id": "lkp_01M8714D14327P36AVE03AS002",
  "object": "vat",
  "input": "DE123459999",
  "country": { "code": "DE", "name": "Germany" },
  "prefix": "DE",
  "vat_number": "123459999",
  "formatted": "DE123459999",
  "format_valid": true,
  "valid": null,
  "status": "unavailable",
  "reason": "ms_unavailable",
  "name": null,
  "address": null,
  "vies": {
    "checked": false,
    "request_date": null,
    "consultation_number": null
  },
  "credits_used": 0,
  "cached": false
}
```

## Errors

| Status | Type | When |
|---|---|---|
| 400 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | `vat` is missing, shorter than 2 or longer than 40 characters, `country` is not two letters, `requester` is shorter than 4 or longer than 40 characters, the body is not a JSON object, or it has a field the request table does not list |
| 401 | [invalid_api_key](https://qelka.com/docs/errors#invalid_api_key) | The key is missing, unknown or revoked |
| 402 | [insufficient_credits](https://qelka.com/docs/errors#insufficient_credits) | Your balance is less than 1 credit (live keys only) |
| 403 | [forbidden](https://qelka.com/docs/errors#forbidden) | The key is restricted to other endpoints |
| 405 | [invalid_request](https://qelka.com/docs/errors#invalid_request) | The method is not `POST` |
| 422 | [unprocessable_input](https://qelka.com/docs/errors#unprocessable_input) | The number has characters a VAT number cannot have, has no prefix and no `country`, has a prefix or a `country` outside VIES (such as `GB`), has a prefix that contradicts `country` or nothing after its prefix, or `requester` is malformed or rejected by VIES |
| 429 | [rate_limited](https://qelka.com/docs/errors#rate_limited) | Too many requests: wait `Retry-After` seconds |
| 500 | [internal_error](https://qelka.com/docs/errors#internal_error) | Unexpected error on our side: retry with backoff |

No error is billed. When VIES or a member state fails, the API does not return an error: it answers `200` with `status: "unavailable"` and `credits_used: 0`.

## Related

- [EU VAT validation API](https://qelka.com/products/vat-validation)
- Free tool: [EU VAT number checker](https://qelka.com/tools/vat-checker)
- [Batch](https://qelka.com/docs/api-reference/batch): up to 100 VAT numbers in one call, each item with `type: "vat"`
- [Bulk](https://qelka.com/docs/api-reference/bulk): a whole file of VAT numbers with `type=vat`
- [Caching](https://qelka.com/docs/caching), [Errors](https://qelka.com/docs/errors), [Test mode](https://qelka.com/docs/test-mode)
