E-Factura UBL 2.1 SPV ANAF

E-Factura integration

Everything you need to submit invoices to ANAF SPV via the Billyou API. UBL 2.1 is handled automatically: you provide structured data, we generate the XML.

UBL 2.1 XML format

ANAF requires invoices in the UBL 2.1 XML format, validated against the Romanian national XSD profile (CIUS-RO). Billyou automatically generates and validates the UBL XML from the structured data you provide through the API. You never need to construct or parse XML directly.

Billyou validates the generated XML against the ANAF XSD schema before submission. If validation fails, the API returns an error immediately rather than letting ANAF reject it.

Required fields

issuer.cui required Tax ID of the issuing company. Format: RO + numeric digits, or just numeric digits.
issuer.name required Legal name of the issuing company, as registered at ONRC.
issuer.address required Full address of the issuing company including city and county.
recipient.cui required Tax ID of the recipient company. Required for B2B E-Factura.
recipient.name required Legal name of the recipient.
items[].name required Name or description of the product or service.
items[].quantity required Numeric quantity. Must be positive.
items[].pricePerUnit required Unit price excluding VAT, in the invoice currency.
items[].vatRate required VAT rate as a number: 0, 5, 9, or 19.
currency optional ISO 4217 currency code. Defaults to RON. Foreign currency invoices use the BNR rate from the invoice date.
spv optional Boolean. Set to true to automatically submit to ANAF SPV after creation.

Complete example

create-efactura.ts
const invoice = await billyou.invoices.create({
  issuer: {
    cui: 'RO12345678',
    name: 'My Company SRL',
    address: 'Strada Victoriei 12, Bucuresti',
  },
  recipient: {
    cui: 'RO87654321',
    name: 'Client SRL',
    address: 'Calea Floreasca 5, Bucuresti',
  },
  items: [{
    name: 'Servicii consultanta',
    unit: 'ora',
    quantity: 10,
    pricePerUnit: 125.00,
    vatRate: 19,
  }],
  currency: 'RON',
  spv: true,
});

SPV submission flow

1
Create invoice
POST to /v1/invoices with spv: true. Billyou validates the data and generates UBL XML.
2
XML validation
The generated XML is validated against the ANAF CIUS-RO XSD schema. Errors are returned immediately.
3
Digital signature
Billyou signs the XML with your company's qualified certificate.
4
SPV submission
The signed XML is submitted to ANAF SPV. You receive an upload_id immediately.
5
ANAF processing
ANAF processes the invoice, typically within 2-30 seconds. Billyou polls for the result.
6
Status update
When ANAF responds, Billyou fires invoice.confirmed or invoice.rejected webhook events.

Error codes

E001
Invalid CUI
The CUI (tax ID) format is invalid. Must be ROxxxxxxxx or just the numeric part.
E002
Missing required field
A required field is absent. Check the error.field property for the field name.
E003
Duplicate invoice number
An invoice with this number already exists for your account. Use a unique series/number.
E100
ANAF SPV unavailable
ANAF infrastructure is temporarily unavailable. Billyou retries automatically.
E101
Invalid UBL format
The generated XML failed ANAF's XSD schema validation. Contact support with the invoice ID.
E200
VAT rate not applicable
The specified VAT rate is not applicable for this type of transaction.

Next steps