API > Nueva factura FacturaE

Nueva factura FacturaE

POST  https://{entorno}.ticketbaiws.eus/facturae/

Método disponible únicamente bajo petición. Se requiere de un certificado digital del cliente para poder firmar las facturas.

Este método permite generar una factura electrónica firmada digitalmente con el estandar FacturaE 3.2.
La factura en formato XML se devuelve encapsulada mediante base64.

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
lineas object obligatorio
descripcion string
Descripción de la línea de la factura (opcional)
Producto normal
cantidad float obligatorio
Número de unidades de la línea
1
importe_unitario float obligatorio
Importe SIN IVA de la línea
100.00
tipo_iva float obligatorio
Porcentaje de IVA aplicado para la línea
21.00

total_factura float obligatorio
Importe total de la factura
132.00

POST https://{entorno}.ticketbaiws.eus/facturae/
$ curl --request POST \
     --url https://api-test.ticketbaiws.eus/facturae/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'Token: xxx' \
     --header 'Nif: 00000014Z'
	 --data '
{
    "fecha": "13\/11\/2021",
    "hora": "12:14:00",
    "nif": "B00000011",
    "nombre": "Empresa de ejemplo S.L.",
    "direccion": "Calle Falsa 123",
    "cp": "28080",
    "serie": "A-",
    "numero": "2021000123",
    "lineas": [
        {
            "descripcion": "Producto normal",
            "cantidad": 1,
            "importe_unitario": 100.00,
            "tipo_iva": 21.00
        },
        {
            "descripcion": "Producto alimentario",
            "cantidad": 1,
            "importe_unitario": 10,
            "tipo_iva": 10.00
        }
    ],
    "total_factura": 132.00
}'
$ composer require guzzlehttp/guzzle
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-test.ticketbaiws.eus/facturae/', [
  'body' => '{"fecha":"13\/11\/2021","hora":"12:14:00","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","simplificada":false,"rectificativa":false,"importacion":false,"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}',
  '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/facturae/"
payload = {
    "fecha": "13\/11\/2021",
    "hora": "12:14:00",
    "nif": "B00000011",
    "nombre": "Empresa de ejemplo S.L.",
    "direccion": "Calle Falsa 123",
    "cp": "28080",
    "serie": "A-",
    "numero": "2021000123",
    "lineas": [
        {
            "descripcion": "Producto normal",
            "cantidad": 1,
            "importe_unitario": 100.00,
            "tipo_iva": 21.00
        },
        {
            "descripcion": "Producto alimentario",
            "cantidad": 1,
            "importe_unitario": 10,
            "tipo_iva": 10.00
        }
    ],
    "total_factura": 132.00
}

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/facturae/");

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","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","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}');

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","nif":"B00000011","nombre":"Empresa de ejemplo S.L.","direccion":"Calle Falsa 123","cp":"28080","serie":"A-","numero":"2021000123","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}');

Request request = new Request.Builder()
  .url("https://api-test.ticketbaiws.eus/facturae/")
  .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": {
		"facturae" : "iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAIAAABEtEjdAAAABmJ..."
	}, 
	"msg": null 
}

Métodos TicketBAI / Verifactu

Métodos específicos para Verifactu

Métodos específicos para BATUZ BIZKAIA

Otros métodos