API Reference

Notifications

API reference for the Notifications package - SDI notification management.

Notifications Package

The @fatturazione-elettronica-aruba/notifications package provides methods to retrieve and manage SDI (Sistema di Interscambio) notifications for both sent and received invoices.

Installation

pnpm add @fatturazione-elettronica-aruba/notifications

NotificationsClient

Constructor

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

const notifications = new NotificationsClient({
  httpClient: client.http,
});

Options:

NameTypeRequiredDescription
httpClientHttpClientYesHTTP client instance from ArubaClient

Methods

getSentNotifications

Retrieves notifications for sent invoices.

async getSentNotifications(params: GetNotificationsParams): Promise<NotificationsResponse>

Parameters:

NameTypeRequiredDescription
idstringNoSDI identifier of the invoice
filenamestringNoInvoice filename
At least one of id or filename must be provided.

Example:

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

console.log(`Found ${response.count} notifications`);
for (const notification of response.notifications) {
  console.log(`${notification.docType}: ${notification.notificationDate}`);
}

getSentNotificationDetail

Retrieves the full content of a specific notification for a sent invoice.

async getSentNotificationDetail(params: GetNotificationDetailParams): Promise<Notification>

Parameters:

NameTypeRequiredDescription
filenamestringYesNotification filename

Example:

const notification = await notifications.getSentNotificationDetail({
  filename: 'IT01234567890_00001_RC_001.xml',
});

console.log('Notification file content:', notification.file);

getReceivedNotifications

Retrieves notifications for received invoices.

async getReceivedNotifications(params: GetNotificationsParams): Promise<NotificationsResponse>

Parameters: Same as getSentNotifications

getReceivedNotificationDetail

Retrieves the full content of a specific notification for a received invoice.

async getReceivedNotificationDetail(params: GetNotificationDetailParams): Promise<Notification>

Parameters: Same as getSentNotificationDetail


Types

NotificationType

SDI notification types:

CodeNameDescription
RCRicevuta di ConsegnaInvoice was successfully delivered to the recipient
NSNotifica di ScartoInvoice was rejected due to validation errors
MCMancata ConsegnaInvoice could not be delivered (recipient unreachable)
NENotifica EsitoBuyer's acceptance/rejection outcome (EC01/EC02)
DTDecorrenza Termini15-day deadline expired without buyer response
ATAttestazione di TrasmissioneTransmission certificate (for PA invoices)
type NotificationType = 'RC' | 'NS' | 'MC' | 'NE' | 'DT' | 'AT';

EsitoResult

Buyer outcome codes (used in NE notifications):

CodeDescription
EC01Invoice accepted
EC02Invoice rejected
type EsitoResult = 'EC01' | 'EC02';

Notification

interface Notification {
  date: string;              // Invoice date
  docType: NotificationType; // Notification type (RC, NS, MC, etc.)
  file: string;              // Base64-encoded notification XML
  filename: string;          // Notification filename
  invoiceId: string;         // SDI identifier
  notificationDate: string;  // When notification was received
  number: string | null;     // Invoice number
  result: EsitoResult | null; // EC01/EC02 (only for NE notifications)
}

NotificationsResponse

interface NotificationsResponse {
  count: number;                 // Total number of notifications
  notifications: Notification[]; // Array of notifications
}

GetNotificationsParams

interface GetNotificationsParams {
  id?: string;       // SDI identifier
  filename?: string; // Invoice filename
}

GetNotificationDetailParams

interface GetNotificationDetailParams {
  filename: string; // Notification filename
}

Notification Flow

Invoice Sent
     │
     ▼
┌─────────┐
│   NS    │──── Rejected (validation errors)
└────┬────┘
     │ Valid
     ▼
┌─────────┐
│ RC / MC │──── Delivered (RC) or Failed delivery (MC)
└────┬────┘
     │ Delivered (RC)
     ▼
┌─────────┐
│   NE    │──── Buyer outcome (EC01: accept, EC02: reject)
└────┬────┘
     │ No response within 15 days
     ▼
┌─────────┐
│   DT    │──── Deadline expired (tacit acceptance)
└─────────┘

Polling Example

async function waitForDelivery(
  notifications: NotificationsClient,
  filename: string,
  maxAttempts = 10,
  intervalMs = 30000
): Promise<Notification | null> {
  for (let i = 0; i < maxAttempts; i++) {
    const response = await notifications.getSentNotifications({ filename });

    const delivery = response.notifications.find(
      (n) => n.docType === 'RC' || n.docType === 'NS' || n.docType === 'MC'
    );

    if (delivery) {
      return delivery;
    }

    await new Promise((resolve) => setTimeout(resolve, intervalMs));
  }

  return null;
}