Skip to content

VeriFactu

The VeriFactu object

object

Attributes


Upload AEAT certificate

POST/fiscalization/verifactu/certificate

Store an encrypted client private key and certificate for AEAT mutual TLS. Representative certificates are allowed; AEAT verifies representation authority. Maximum file size: 1 MiB.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Body parameters

filestring<binary>required

P12/PFX client certificate file.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';
import fs from 'fs';

const sdk = new SpaceInvoices('YOUR_API_KEY');

// Read file as Buffer
const fileBuffer = fs.readFileSync('/path/to/certificate.p12');
const file = new File([fileBuffer], 'certificate.p12', { type: 'application/x-pkcs12' });

const response = await sdk.veriFactu.uploadCertificate({
  file,
  passphrase: "cert-password"
}, { entity_id: 'YOUR_ENTITY_ID' });

console.log(response);

Returns

siibooleannullable
json
{
  "enabled": true,
  "territory": "ordinary",
  "sii": true,
  "eligibility": "not_configured",
  "has_certificate": true,
  "certificate_expiry": "certificate-expiry",
  "environment": "test",
  "software_version": "software-version",
  "production_ready": true,
  "pending_records": 0
}

Get VeriFactu settings

GET/fiscalization/verifactu/settings

Retrieve eligibility, configuration and certificate status for the selected entity.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.getSettings({
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

siibooleannullable
json
{
  "enabled": true,
  "territory": "ordinary",
  "sii": true,
  "eligibility": "not_configured",
  "has_certificate": true,
  "certificate_expiry": "certificate-expiry",
  "environment": "test",
  "software_version": "software-version",
  "production_ready": true,
  "pending_records": 0
}

Get fiscal submission evidence

GET/fiscalization/verifactu/records/{id}

Retrieve the immutable record and its latest 100 submission or consultation attempts. Evidence contains invoice personal data and requires entity settings administration permission.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstringrequired

Fiscal record identifier from document.verifactu.record_id.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.getEvidence('VERIFACTU_ID', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

json
{
  "record_id": "record-id",
  "status": "pending",
  "hash": "hash",
  "generated_at": "generated-at",
  "qr_url": "https://example.com",
  "software_version": "software-version",
  "csv": "csv",
  "error_code": "error-code",
  "error_message": "error-message",
  "document_id": "document-id",
  "kind": "alta",
  "sequence": 0,
  "previous_record_id": "previous-record-id",
  "reason": "reason",
  "request_xml": "request-xml",
  "total_attempts": 0,
  "attempts": [
    {
      "id": "id",
      "request_xml": "request-xml",
      "response_xml": "response-xml",
      "http_status": 0,
      "started_at": "started-at",
      "finished_at": "finished-at",
      "error_code": "error-code"
    }
  ]
}

Update VeriFactu settings

PUT/fiscalization/verifactu/settings

Confirm fiscal territory and SII status. Enabling requires ordinary territory, non-SII status, and a valid client certificate. Production also requires an approved software release. Once records exist, ordinary updates cannot disable or reclassify the installation.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Body parameters

territorystringrequired

The issuer's fiscal territory, confirmed during onboarding.

Possible values: "ordinary", "basque_country", "navarra"

siibooleanrequired

Whether the issuer uses Spain's SII VAT reporting system.

enabledbooleanrequired

Enable VeriFactu issuance after eligibility and credentials have been checked.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.updateSettings({
  territory: "ordinary",
  sii: true,
  enabled: true
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

siibooleannullable
json
{
  "enabled": true,
  "territory": "ordinary",
  "sii": true,
  "eligibility": "not_configured",
  "has_certificate": true,
  "certificate_expiry": "certificate-expiry",
  "environment": "test",
  "software_version": "software-version",
  "production_ready": true,
  "pending_records": 0
}

Retry an unconfirmed fiscal submission

POST/fiscalization/verifactu/records/{id}/retry

Retry retained pending XML without generating another record. Respects AEAT flow control, installation order and leases. Confirmed rejection needs a correction instead.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstringrequired

Fiscal record identifier from document.verifactu.record_id.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.retryRecord('VERIFACTU_ID', {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

json
{
  "record_id": "record-id",
  "status": "pending",
  "hash": "hash",
  "generated_at": "generated-at",
  "qr_url": "https://example.com",
  "software_version": "software-version",
  "csv": "csv",
  "error_code": "error-code",
  "error_message": "error-message"
}

Correct fiscal record data

POST/fiscalization/verifactu/records/{id}/correct

Append a full Subsanacion record for incorrect fiscal metadata, preserving the issued invoice and old evidence. Invoice amounts, identity and recipient changes require a rectifying invoice. Only the latest confirmed alta may be corrected. Repeating an identical correction is idempotent.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstringrequired

Fiscal record identifier from document.verifactu.record_id.

Body parameters

reasonstringrequired

Operator explanation retained with this fiscal operation.

correctionobjectrequired

Fiscal classifications supplied before issue, or as an append-only fiscal metadata correction.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.correctRecord('VERIFACTU_ID', {
  reason: "reason",
  correction: {
    invoice_type: "F1",
    description: "description",
    customer_id_type: "02",
    tax_treatments: [
      {
        tax_index: 0,
        tax: "01",
        regime: "regime",
        qualification: "S1"
      }
    ]
  }
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

json
{
  "record_id": "record-id",
  "status": "pending",
  "hash": "hash",
  "generated_at": "generated-at",
  "qr_url": "https://example.com",
  "software_version": "software-version",
  "csv": "csv",
  "error_code": "error-code",
  "error_message": "error-message"
}

Cancel an invoice issued in error

POST/fiscalization/verifactu/records/{id}/cancel

Append a chained cancellation and mark the invoice void without deleting it. Restricted to confirmed records without payments or applied advances; economic refunds require a rectifying invoice. A rejected cancellation can itself be cancelled again to generate a new RechazoPrevio record. Repeating the same reason for the same record is idempotent.

Header parameters

entity_idstringoptional

Entity ID on which the request is made. Auto-selected when only one entity exists, required when multiple entities exist.

Path parameters

idstringrequired

Fiscal record identifier from document.verifactu.record_id.

Body parameters

reasonstringrequired

Operator explanation retained with this fiscal operation.

import SpaceInvoices from '@spaceinvoices/js-sdk/sdk';

const sdk = new SpaceInvoices('YOUR_API_KEY');

const response = await sdk.veriFactu.cancelRecord('VERIFACTU_ID', {
  reason: "reason"
}, {
  entity_id: "YOUR_ENTITY_ID"
});

console.log(response);

Returns

json
{
  "record_id": "record-id",
  "status": "pending",
  "hash": "hash",
  "generated_at": "generated-at",
  "qr_url": "https://example.com",
  "software_version": "software-version",
  "csv": "csv",
  "error_code": "error-code",
  "error_message": "error-message"
}