POST https://{entorno}.ticketbaiws.eus/ticketbai/
Este método permite enviar una factura a la hacienda foral correspondiente y devolverá la huella TBAI, la imagen código QR en base64 y la URL de validación de la factura de la hacienda foral que contiene el QR. El entorno de test permite generar TBAIs en el entorno de pruebas de la hacienda correspondiente.
PARÁMETROS
| fecha string obligatorio Fecha de la factura en formato dd/mm/yyyy | 13/11/2021 | ||||||||||
| hora string obligatorio Hora de emisión de la factura en formato HH:MM:SS | 12:14:00 | ||||||||||
| nif string obligatorio NIF del cliente al que se le emite la factura | B01000012 | ||||||||||
| nombre string obligatorio Nombre social del cliente al que se le emite la factura | Empresa de ejemplo S.L. | ||||||||||
| direccion string obligatorio Dirección de facturación del cliente al que se le emite la factura | Calle de ejemplo 123 | ||||||||||
| cp string obligatorio Código postal del cliente al que se le emite la factura | 12:14:00 | ||||||||||
| serie string obligatorio Serie de la factura | A | ||||||||||
| numero string obligatorio Número de factura | 2021000123 | ||||||||||
| simplificada boolean obligatorio Es factura simplificada | true | ||||||||||
| rectificativa boolean obligatorio Es factura rectificativa | false | ||||||||||
| importacion boolean obligatorio Es factura de importación | false | ||||||||||
| intracomunitaria boolean obligatorio Es factura intracomunitaria | false | ||||||||||
| retencion float obligatorio Porcentaje de retención aplicado | 0.00 | ||||||||||
lineas object obligatorio
| |||||||||||
| total_factura float obligatorio Importe total de la factura | 132.00 | ||||||||||
$ curl --request POST \
--url https://api-test.ticketbaiws.eus/tbai/ \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Token: xxx' \
--header 'Nif: 00000014Z'
--data '
{
"fecha": "13\/11\/2021",
"hora": "12:14:00",
"fecha_operacion": "12\/11\/2021",
"pais_cliente": "ES",
"nif": "B00000011",
"nombre": "Empresa de ejemplo S.L.",
"direccion": "Calle Falsa 123",
"cp": "28080",
"serie": "A",
"numero": "2021000123",
"simplificada": false,
"rectificativa": false,
"clave_rectificativa": "R1",
"tipo_rectificativa": "I",
"rectificadas" : [
{
"serie": "A"
"numero": "20210000075",
"fecha": "10\/11\/2021"
}
],
"tipo_operacion": "servicios",
"intracomunitaria": false,
"exportacion": false,
"retencion": 0,
"lineas": [
{
"descripcion": "Producto normal",
"cantidad": 1,
"importe_unitario": 100.00,
"tipo_iva": 21.00,
"tipo_req": 0
},
{
"descripcion": "Producto alimentario",
"cantidad": 1,
"importe_unitario": 10,
"tipo_iva": 10.00,
"tipo_req": 0
}
],
"total_factura": 132.00,
"zuzendu" : false
}'
$ composer require guzzlehttp/guzzle
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api-test.ticketbaiws.eus/tbai/', [
'body' => '{"fecha":"13\/11\/2021","hora":"12:14:00","fecha_operacion":"12\/11\/2021","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","simplificada":false,"rectificativa":false,"tipo_operacion":"servicios","intracomunitaria":false,"retencion":0,"lineas":[{"descripcion":"Producto normal","cantidad":1,"importe_unitario":100.00,"tipo_iva":"21.00","tipo_req":0},{"descripcion":"Producto alimentario","cantidad":1,"importe_unitario":10,"tipo_iva":10.00,"tipo_req":0}],"total_factura":132.00,"zuzendu":false}',
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Token' => 'xxx',
'Nif' => '00000014Z'
],
]);
echo $response->getBody();
$ python -m pip install requests
import requests
url = "https://api-test.ticketbaiws.eus/tbai/"
payload = {
"fecha": "13\/11\/2021",
"hora": "12:14:00",
"fecha_operacion":"12\/11\/2021",
"nif": "B00000011",
"nombre": "Empresa de ejemplo S.L.",
"direccion": "Calle Falsa 123",
"cp": "28080",
"serie": "A-",
"numero": "2021000123",
"simplificada": false,
"rectificativa": false,
"tipo_operacion":"servicios",
"intracomunitaria": false,
"retencion": 0,
"lineas": [
{
"descripcion": "Producto normal",
"cantidad": 1,
"importe_unitario": 100.00,
"tipo_iva": 21.00,
"tipo_req": 0
},
{
"descripcion": "Producto alimentario",
"cantidad": 1,
"importe_unitario": 10,
"tipo_iva": 10.00,
"tipo_req": 0
}
],
"total_factura": 132.00,
"zuzendu":false
}
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-test.ticketbaiws.eus/tbai/");
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, '{"fecha":"13\/11\/2021","hora":"12:14:00","fecha_operacion":"12\/11\/2021","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","simplificada":false,"rectificativa":false,"tipo_operacion":"servicios","intracomunitaria":false,"retencion":0,"lineas":[{"descripcion":"Producto normal","cantidad":1,"importe_unitario":100.00,"tipo_iva":"21.00","tipo_req":0},{"descripcion":"Producto alimentario","cantidad":1,"importe_unitario":10,"tipo_iva":10.00,"tipo_req":0}],"total_factura":132.00,"zuzendu":false}');
CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, '{"fecha":"13\/11\/2021","hora":"12:14:00","fecha_operacion":"12\/11\/2021","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","simplificada":false,"rectificativa":false,"tipo_operacion":"servicios","intracomunitaria":false,"retencion":0,"lineas":[{"descripcion":"Producto normal","cantidad":1,"importe_unitario":100.00,"tipo_iva":"21.00","tipo_req":0},{"descripcion":"Producto alimentario","cantidad":1,"importe_unitario":10,"tipo_iva":10.00,"tipo_req":0}],"total_factura":132.00,"zuzendu":false}');
Request request = new Request.Builder()
.url("https://api-test.ticketbaiws.eus/tbai/")
.post(body)
.addHeader("Accept", "application/json")
.addHeader("Token", "xxx")
.addHeader("Nif", "00000014Z")
.build();
Response response = client.newCall(request).execute();
HTTP/1.1 200 OK
{
"result": "OK",
"return": {
"huella_tbai" : "TBAI-B01000012-131121-zG3wtCW3WlOSN-108",
"qr" : "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAIAAABEtEjdAAAABmJ...",
"url" : "https://batuz.eus/QRTBAI/?id=TBAI-..."
},
"msg": null
}
HTTP/1.1 200 OK
{
"result": "OK",
"return": {
"huella" : "8FA696A615A750A9EC04A273013F05EB1B092076FFD9A66EF6",
"qr" : "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAIAAABEtEjdAAAABmJ...",
"url" : "https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?..."
},
"msg": null
}