API > Validate NIF with the AEAT

Validate NIF with the AEAT

POST  https://{entorno}.ticketbaiws.eus/validar-nif/

Validates a NIF (Spanish tax ID) against the taxpayer register of the AEAT (Spanish Tax Agency). Verifactu requires invoices to individuals to be issued with the correct details (first name + last name + NIF). For legal entities, the NIF alone is enough.

PARAMETERS

nif string required
NIF to validate
12345678Z
nombre string required only for individuals
First name + last name for individuals; optional for legal entities
Juan Martínez


For individuals, the possible results are:

IDENTIFICADO: The taxpayer matches the identification data provided. The last name(s) and first name linked to the NIF are returned.
NO IDENTIFICADO-SIMILAR: The taxpayer does not match the identification data provided due to minor differences in the last name(s) and first name. The last name(s) and first name linked to the NIF are returned.
NO IDENTIFICADO: The taxpayer does not match the identification data provided.

For legal entities, the “No Identificado-Similar” result does not exist, but these two results are added:

IDENTIFICADO-BAJA: The taxpayer matches the NIF provided and is deregistered. The current NIF and its registered name are returned.
IDENTIFICADO-REVOCADO: The taxpayer matches the NIF provided and is deregistered because the NIF was revoked. The current NIF and its registered name are returned.

POST https://api.ticketbaiws.eus/validar-nif/
$ curl --request POST \
     --url https://api.ticketbaiws.eus/validar-nif/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
	 --data '
{
    "nif": "12345678Z",
    "nombre": "Juan Martínez"
}'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';

$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'real']);

$r = $tbai->validarNif('12345678Z', 'Juan Martínez');

if ($r->isError()) {
    echo $r->getMessageText();
} else {
    print_r($r->getData());
}
$ python -m pip install requests
import requests

url = "https://api.ticketbaiws.eus/validar-nif/"
payload = {
    "nif": "12345678Z",
    "nombre": "Juan Martínez"
}

headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
CURL *hnd = curl_easy_init();

curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.ticketbaiws.eus/validar-nif/");

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, '{"nif": "12345678Z","nombre": "Juan Martínez"}');

CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{"nif": "12345678Z","nombre": "Juan Martínez"}');

Request request = new Request.Builder()
  .url("https://api.ticketbaiws.eus/validar-nif/")
  .post(body)
  .addHeader("Accept", "application/json")
  .addHeader("Token", "xxx")
  .addHeader("Nif", "00000014Z")
  .build();
  
Response response = client.newCall(request).execute();
{ } Response JSON
HTTP/1.1 200 OK
{
    "result": "OK",
    "return": {
        "nif": "12345678Z",
        "nombre": "MARTINEZ RODRIGUEZ JUAN",
        "resultado": "IDENTIFICADO"
    },
    "msg": ""
}

TicketBAI / Verifactu methods

Representation document

BATUZ BIZKAIA specific methods

SII (AEAT)

Customers and products (invoicing tool)

Other methods