TicketBAI in the Basque Country: Bizkaia, Gipuzkoa and Álava/Araba
TicketBAI is the mandatory e-invoicing system for all three Basque foral territories. Each Diputación Foral (Provincial Council) runs its own receiving platform, its own endpoints, and has its own enforcement dates. Frihet supports all three territories with automatic ZIP code detection.
Why three separate systems
The Basque foral territories have full fiscal autonomy. Bizkaia, Gipuzkoa and Álava/Araba designed technically compatible systems — same XAdES signature standard, same SHA-256 chaining, same QR — but with separate receiving infrastructure. Whether your company is in Bilbao or Vitoria-Gasteiz determines which Hacienda Foral you report to and which endpoint Frihet uses for submission.
Automatic detection by ZIP code
Frihet identifies the foral territory from the ZIP code in your fiscal profile:
| Prefix | Territory | System | Hacienda Foral |
|---|---|---|---|
48xxx | Bizkaia | BATUZ | Hacienda Foral de Bizkaia |
20xxx | Gipuzkoa | TicketBAI Gipuzkoa | Hacienda Foral de Gipuzkoa |
01xxx | Álava/Araba | TicketBAI Álava | Hacienda Foral de Álava |
If your ZIP code does not start with any of these prefixes, the TicketBAI section does not appear in Settings. Navarra (31xxx) has its own system under the Hacienda Foral de Navarra and is not included in this version.
Mandatory elements in every TicketBAI invoice
Regardless of territory, each TicketBAI invoice must contain:
- XML signed with XAdES-BES using the taxpayer's digital certificate
- SHA-256 chained hash with the immediately preceding invoice (
issuer|series|number|date|amount|previousHash) - TBAI identifier assigned by the Hacienda Foral after validating the submission
- QR code generated from the actual TBAI identifier returned by the authority (never generated internally)
The chain is inviolable: altering one record invalidates the entire subsequent chain.
Bizkaia — BATUZ
BATUZ is the Hacienda Foral de Bizkaia system. Unlike Gipuzkoa and Álava, it uses SOAP with custom HTTP headers instead of REST.
Endpoints
| Environment | URL |
|---|---|
| Sandbox | https://pruebasarqueo.bizkaia.eus/N3B4000M/aurkezpena |
| Production | https://sarrerak.bizkaia.eus/N3B4000M/aurkezpena |
BATUZ-specific headers
The Bizkaia SOAP service requires custom HTTP headers not used by other systems:
eus-bizkaia-n3-version: 1.0
eus-bizkaia-n3-idoperacion: {unique UUID per submission}
eus-bizkaia-n3-nif: {issuer NIF}
eus-bizkaia-n3-tipoComunicacion: A00
Content-Type: application/octet-stream; charset=UTF-8
Frihet manages these headers automatically in its BATUZ submission Cloud Function. No additional configuration is required.
Expected response
BATUZ returns a SOAP result with:
CSV— Secure Verification Code for the taxpayerIdentificadorTBAI— unique identifier for the invoice in BizkaiaEstado—Correcto,AceptadoConErroresorIncorrecto
Frihet stores the CSV and IdentificadorTBAI in Firestore under invoices/{id}/tbai/submission and generates the QR from the real IdentificadorTBAI. If BATUZ returns an error status, the invoice is marked as pending correction.
Mandatory dates in Bizkaia
| Taxpayer group | From |
|---|---|
| Large taxpayers (turnover > €6M) | 1 January 2022 |
| All other businesses and self-employed | 1 January 2023 |
| Invoicing software (technical compliance) | 1 January 2022 |
Gipuzkoa — TicketBAI REST
The Hacienda Foral de Gipuzkoa uses a REST API instead of SOAP, which simplifies technical integration.
Endpoints
| Environment | URL |
|---|---|
| Sandbox | https://tbai-z.prep.gipuzkoa.eus/sarrerak/alta |
| Production | https://tbai-z.egoitza.gipuzkoa.eus/sarrerak/alta |
Submission method
POST /sarrerak/alta
Content-Type: application/xml; charset=UTF-8
Authorization: {client certificate in mTLS}
The request body is the TicketBAI XML signed with XAdES-BES. The response returns the IdentificadorTBAI and validation status in JSON.
Mandatory dates in Gipuzkoa
| Taxpayer group | From |
|---|---|
| Taxpayers in module estimation | 1 January 2022 |
| Self-employed in simplified direct estimation | 1 October 2022 |
| Remaining companies and self-employed | 1 July 2023 |
Álava/Araba — TicketBAI REST
The Hacienda Foral de Álava also uses REST, with a similar structure to Gipuzkoa but its own domain.
Endpoints
| Environment | URL |
|---|---|
| Sandbox | https://pruebas-ticketbai.araba.eus/TicketBAI/v1/facturas/ |
| Production | https://ticketbai.araba.eus/TicketBAI/v1/facturas/ |
Submission method
POST /TicketBAI/v1/facturas/
Content-Type: application/xml; charset=UTF-8
The response includes the validation status and the IdentificadorTBAI for accepted invoices.
Mandatory dates in Álava
| Taxpayer group | From |
|---|---|
| Large companies (> €6M) | 1 January 2022 |
| All other taxpayers with economic activity | 1 January 2023 |
BYOC digital certificate
TicketBAI requires signing with the taxpayer's own certificate, not a service certificate. Frihet implements a Bring Your Own Certificate (BYOC) model:
- Go to Settings → TicketBAI → Digital certificate.
- Upload the
.p12or.pfxfile with the certificate password. - Frihet encrypts the certificate with AES-256-GCM and stores it in Firestore. The encryption key does not leave the Cloud Functions environment.
- On each submission, Frihet decrypts the certificate in memory, signs the XML, and discards it without persisting the decrypted form.
Valid certificates for TicketBAI:
- FNMT — Fábrica Nacional de Moneda y Timbre (individuals and legal entities)
- Izenpe — Basque certification authority (recommended for foral taxpayers)
- Other certificates recognized by the Haciendas Forales (ACCV, ANF, Camerfirma)
Certificates for legal entities expire. Frihet shows a warning 30 days before expiry. A signature with an expired certificate is rejected by the Hacienda Foral with an unrecoverable error. Renew the certificate before expiry and update it in Settings.
Testing in sandbox
The sandbox allows integration verification without fiscal effects:
- Go to Settings → TicketBAI.
- The section only appears if your ZIP code is from a foral territory (48xxx, 20xxx, 01xxx).
- Click Test sandbox to send a test invoice to your Hacienda Foral's test environment.
- The result shows the verification CSV and IdentificadorTBAI if the test succeeds.
In sandbox you can submit without a real certificate to verify XML format and connectivity. For production, a certificate is mandatory.
Technical pipeline in Frihet
Frihet runs the TicketBAI pipeline in Cloud Functions (europe-west1):
- XML construction — TicketBAI v1.2 conforming to the XSD schema of the relevant Hacienda Foral
- XAdES-BES signing — using the BYOC certificate decrypted in memory
- SHA-256 chaining — calculates
previousHashfrom the last record in the same series - Territory detection — routes to the correct endpoint (BATUZ SOAP, Gipuzkoa REST, Álava REST)
- Submission and validation — receives CSV + IdentificadorTBAI
- QR generation — from the real IdentificadorTBAI returned by the authority
- Persistence — CSV, QR, hash and status stored in Firestore
If submission fails, the invoice stays in pending_tbai status and Frihet retries automatically with exponential backoff.
Status check via MCP
If you use the Frihet MCP server, the ticketbai_status tool returns the current status of any invoice:
ticketbai_status(invoiceId: string)
→ { invoiceId, status, csv, qrUrl, province, tbaiIdentifier, submittedAt }
status values: submitted, accepted, rejected, pending, no_submission_yet.
Frequently asked questions
Is TicketBAI the same as VeriFactu? No. VeriFactu is the AEAT system for the rest of Spain. TicketBAI is the system of the Basque Haciendas Forales. If your company is in the Basque Country, you use TicketBAI. Both systems coexist but are independent and do not share data.
What if my company has offices in Bizkaia and Madrid? Invoices issued from the permanent establishment in Bizkaia go to BATUZ. Invoices issued from Madrid go to VeriFactu (AEAT). Frihet manages both systems based on the active fiscal profile on each invoice.
Does TicketBAI apply to self-employed? Yes. The system is mandatory for any taxpayer with economic activity in foral territory, whether an individual (self-employed) or a legal entity (company). Applicable document types and numbering series are the same.
Does the sandbox use real data? No. Each Hacienda Foral's sandbox is an isolated test environment. TBAI identifiers generated in sandbox have no fiscal validity and do not appear in the Hacienda's records.
Official references
- BATUZ (Bizkaia): https://www.batuz.eus
- Hacienda Foral de Gipuzkoa: https://www.gipuzkoa.eus/es/hacienda/ticketbai
- Hacienda Foral de Álava: https://www.araba.eus/es/hacienda/ticketbai
- TicketBAI specification: https://www.ticketbai.eus
- Izenpe (Basque certification): https://www.izenpe.eus