TicketBAI and Verifactu REST API documentation
With the Ticketbai WS REST API you connect your application, online store, POS or ERP to the Basque provincial tax authorities (TicketBAI in Araba, Bizkaia/Batuz and Gipuzkoa) and to the AEAT (Spanish Tax Agency) for Verifactu, and you generate FacturaE electronic invoices for public administrations.
Just getting started?
- Quick start guide: from zero to your first invoice in production.
- Examples: 22 ready-to-copy cases (simplified, intra-EU, corrective invoices…).
- Test console: try the API without creating an account.
- Service status: response times of the API and of each tax authority.
Environments and base URL
All methods follow this pattern:
https://{entorno}.ticketbaiws.eus/{recurso}/
- POST Create (e.g. a new invoice)
- GET Retrieve
- PUT Update
- DEL Cancel
The environment is api-test for testing (submissions go to the tax authority's test environment and have no tax validity) and api for production. Some management methods (companies, licenses and NIF validation) only exist in production. Webhooks work in both environments and are configured separately in each one.
Authentication
Every request carries two headers: Token, the company's token for that environment (you'll find it in the private area; there is one for test and another for production), and Nif, the issuer's NIF (Spanish tax ID). Parameters are sent in a JSON object with Content-Type: application/json. For GET methods you can also send them in the query string.
Exception: the companies and licenses methods manage your account and authenticate with the developer token of your customer account and the account's NIF, not with those of a company.
Results and responses
The API responds with HTTP 200 and an object with three variables: result, return and msg.
- result:
OK,PENDING(accepted and pending submission to the tax authority) orERROR. - return: the resulting data (fingerprint, verification URL, QR code…).
- msg: status or error messages.
Always check result, not just the HTTP status code.
Submission to the tax authority
The API responds immediately and the submission to the tax authority is done in the background. To find out how it ended, retrieve the invoice with GET /tbai/ or set up a webhook. If you need the tax authority's response in the same request, send "sincrono": true in POST /tbai/. Line amounts are excluding VAT.
Rate limits
If the request limit is exceeded, the API responds with HTTP 429. Retry with increasing backoff and don't poll the status in a loop: that's what webhooks are for.
For AI agents and code generators
- OpenAPI 3.1 specification for all methods.
- llms.txt and llms-full.txt (the whole documentation in one file).
- Every page of this documentation has a Markdown version: add
.mdto the URL, e.g. en/ticketbai-post.md.



![]()
$ curl --request GET \
--url https://api-test.ticketbaiws.eus/status/ \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Token: xxx' \
--header 'Nif: 00000014Z'
$ composer require ticketbaiws/ticketbaiws-php
<?php
// Installation: composer require ticketbaiws/ticketbaiws-php
require 'vendor/autoload.php';
$tbai = new \TicketbaiWS\Client('xxx', '00000014Z', ['entorno' => 'test']);
$r = $tbai->estado();
if ($r->isError()) {
echo $r->getMessageText();
} else {
echo $r->getResult() . ' ' . $r->getMessageText();
}
$ python -m pip install requests
import requests
url = "https://api-test.ticketbaiws.eus/status/"
headers = {"Accept": "application/json", "Token" : "xxx", "Nif" : "00000014Z"}
response = requests.request("GET", url, headers=headers)
print(response.text)
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api-test.ticketbaiws.eus/status/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api-test.ticketbaiws.eus/status/")
.get()
.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": null,
"msg": "Ready"
}
HTTP/1.1 200 OK
{
"result": "ERROR",
"return": null,
"msg": "License expired"
}
API methods
TicketBAI / Verifactu methods
- POST New invoice / resubmission (zuzendu) TicketBAI / Verifactu
- POST Complete a simplified invoice
- GET Get a TicketBAI / Verifactu invoice
- GET List TicketBAI / Verifactu invoices
- GET Download TicketBAI / Verifactu XML
- GET Download invoice in FacturaE format
- GET Download invoice as PDF
- GET System status
- DEL Cancel a TicketBAI / Verifactu invoice
- PUT Force TicketBAI / Verifactu resend
- POST Validate a NIF with the AEAT
- POST Validate a VAT number in VIES
Representation document
- GET Representation document - Download template
- POST Representation document - Upload document
- GET Representation document - Download uploaded document
- DELETE Representation document - Revoke uploaded document
BATUZ BIZKAIA specific methods
- GET List IAE activity codes
- POST LROE - Received invoices - Submit (BATUZ)
- PUT LROE - Received invoices - Update (BATUZ)
- GET LROE - Received invoices - Query (BATUZ)
- DEL LROE - Received invoices - Cancel (BATUZ)
- POST LROE - Expenses without invoice - Submit (BATUZ, form 140)
- PUT LROE - Expenses without invoice - Update (BATUZ, form 140)
- GET LROE - Expenses without invoice - Query (BATUZ, form 140)
- DEL LROE - Expenses without invoice - Cancel (BATUZ, form 140)
- POST LROE - Cash accounting COLLECTIONS - Submit (BATUZ)
- PUT LROE - Cash accounting COLLECTIONS - Update (BATUZ)
- GET LROE - Cash accounting COLLECTIONS - Query (BATUZ)
- DEL LROE - Cash accounting COLLECTIONS - Cancel (BATUZ)
- POST LROE - Cash accounting PAYMENTS - Submit (BATUZ)
- PUT LROE - Cash accounting PAYMENTS - Update (BATUZ)
- GET LROE - Cash accounting PAYMENTS - Query (BATUZ)
- DEL LROE - Cash accounting PAYMENTS - Cancel (BATUZ)
SII (AEAT)
Customers and products (invoicing tool)
- GET Customers - Search / get customers
- POST Customers - New customer
- PUT Customers - Update customer
- GET Products - Search / get products
