Guides

Notifications

SDI notification management

Notifications

Retrieve SDI notifications for sent and received invoices.

Setup

import { NotificationsClient } from '@fatturazione-elettronica-aruba/notifications';

const notifications = new NotificationsClient(client.http);

Sent Invoice Notifications

const result = await notifications.getSentNotifications({
  invoiceFilename: 'IT01234567890_00001.xml',
});

for (const n of result.notifications) {
  console.log(`${n.docType}: ${n.filename}`);
}

Notification Types

CodeNameDescription
RCDelivery ReceiptInvoice delivered to recipient
NSRejection NoticeInvoice rejected for errors
MCFailed DeliveryUnable to deliver
NEOutcome NoticeRecipient outcome (EC01/EC02)
DTTerm ExpiryNo outcome within 15 days
ATTransmission CertificatePA transmission confirmation

Polling Notifications

async function waitForDelivery(filename: string): Promise<boolean> {
  for (let i = 0; i < 10; i++) {
    const result = await notifications.getSentNotifications({
      invoiceFilename: filename,
    });

    if (result.notifications.some(n => n.docType === 'RC')) {
      return true;
    }

    if (result.notifications.some(n => n.docType === 'NS')) {
      return false;
    }

    await new Promise(r => setTimeout(r, 60000));
  }
  return false;
}