# vat.verify

Verify an EU or UK VAT number and return audit evidence. Upstream failures are unbilled.

- REST: `POST https://api.kanagu.dev/v1/vat/verify`
- MCP tool: `vat.verify` at https://api.kanagu.dev/mcp
- Price: $0.03 USD per successful call. Trial: 10 calls per IP per UTC day without a key, shared by REST and MCP.
- Auth: `Authorization: Bearer <key>` for billed calls. Retries: reuse `Idempotency-Key`.

## Request body

- `vatNumber` (string (max 40 chars), required): VAT number with country prefix, e.g. DE143454214.
- `requesterVat` (string (max 40 chars)): Your VAT number, to request a consultation ID.

## Response

- `verificationId` (string (uuid)): Audit ID for an authenticated verification.
- `vatNumber` (string, required)
- `country` ("AT" | "BE" | "BG" | "CY" | "CZ" | "DE" | … (29 values), required)
- `valid` (boolean, required)
- `source` ("checksum" | "vies" | "hmrc", required)
- `checkedAt` (string (date-time), required)
- `upstreamDate` (string)
- `name` (string)
- `address` (string)
- `consultationId` (string)
- `rawStatus` (string, required)

## Example

```sh
curl https://api.kanagu.dev/v1/vat/verify \
  -H "Authorization: Bearer $KANAGU_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vatNumber":"DE143454214"}'
```

```ts
const res = await fetch("https://api.kanagu.dev/v1/vat/verify", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KANAGU_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "vatNumber": "DE143454214"
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const result = await res.json();
```

## Errors

JSON `{"error":{"code","message"}}`.

- 400 `invalid_input`: The body does not match the request schema. The message names each field.
- 400 `invalid_json`: The body is missing or is not valid JSON.
- 400 `invalid_idempotency_key`: Idempotency-Key must be 1–128 visible ASCII characters.
- 401 `invalid_api_key`: The Bearer key is missing, malformed, invalid or inactive.
- 402 `free_allowance_exhausted`: This month's free usage is used up and the account has no subscription. Subscribe from the dashboard, or wait for the next UTC month; Retry-After gives the seconds left.
- 404 `not_found`: No operation at this path.
- 409 `idempotency_conflict`: The Idempotency-Key was already used with a different body.
- 413 `payload_too_large`: JSON bodies may be at most 64 KiB.
- 429 `trial_limit`: The anonymous trial allows 10 calls per IP per UTC day, shared by REST and MCP. Retry-After gives the seconds left.
- 500 `internal_error`: The call failed on our side. It is not billed; retry with the same Idempotency-Key.

## JSON Schema

Request:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "vatNumber": {
      "type": "string",
      "minLength": 3,
      "maxLength": 40,
      "description": "VAT number with country prefix, e.g. DE143454214."
    },
    "requesterVat": {
      "description": "Your VAT number, to request a consultation ID.",
      "type": "string",
      "minLength": 3,
      "maxLength": 40
    }
  },
  "required": [
    "vatNumber"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "vatNumber": "DE143454214"
    }
  ]
}
```

Response:
```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "verificationId": {
      "description": "Audit ID for an authenticated verification.",
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "vatNumber": {
      "type": "string"
    },
    "country": {
      "type": "string",
      "enum": [
        "AT",
        "BE",
        "BG",
        "CY",
        "CZ",
        "DE",
        "DK",
        "EE",
        "EL",
        "ES",
        "FI",
        "FR",
        "GB",
        "HR",
        "HU",
        "IE",
        "IT",
        "LT",
        "LU",
        "LV",
        "MT",
        "NL",
        "PL",
        "PT",
        "RO",
        "SE",
        "SI",
        "SK",
        "XI"
      ]
    },
    "valid": {
      "type": "boolean"
    },
    "source": {
      "type": "string",
      "enum": [
        "checksum",
        "vies",
        "hmrc"
      ]
    },
    "checkedAt": {
      "type": "string",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
    },
    "upstreamDate": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "address": {
      "type": "string"
    },
    "consultationId": {
      "type": "string"
    },
    "rawStatus": {
      "type": "string"
    }
  },
  "required": [
    "vatNumber",
    "country",
    "valid",
    "source",
    "checkedAt",
    "rawStatus"
  ],
  "additionalProperties": false
}
```
