Skip to content

Type Definitions

Complete TypeScript type reference for the @getpeppr/sdk. All types are exported from the package.

InvoiceInput

The main payload for sending invoices. Required fields: number, to, lines. The seller is determined by the API key; from is accepted only as deprecated local metadata.

InvoiceInput
interface InvoiceInput {
  number: string;
  to: BuyerParty;
  lines: InvoiceLine[];

  // Optional
  date?: string;                // ISO 8601 (default: today)
  dueDate?: string;             // ISO 8601
  currency?: string;            // ISO 4217 (default: "EUR")
  taxCurrency?: string;         // BT-6
  taxCurrencyRate?: number;
  note?: string;
  from?: Party;                 // deprecated: seller comes from API key
  payeeParty?: Party;           // BG-10
  buyerReference?: string;      // BT-10
  orderReference?: string;      // PO number
  salesOrderReference?: string; // BT-14
  contractReference?: string;   // BT-12
  projectReference?: string;    // BT-11
  invoiceReference?: string;    // required for credit notes
  isCreditNote?: boolean;

  // Payment
  paymentTerms?: string;
  paymentReference?: string;
  paymentMeans?: number;        // 30=credit transfer, 58=SEPA
  paymentIban?: string;
  paymentBic?: string;

  // Extended
  delivery?: Delivery;
  invoicePeriod?: InvoicePeriod;
  attachments?: Attachment[];
  allowances?: AllowanceCharge[];
  charges?: AllowanceCharge[];
}

Party

Represents a seller (from) or buyer (to) in an invoice. The peppolId format is scheme:identifier (e.g. 0208:0685660237).

Party
interface Party {
  name: string;
  peppolId: string;          // e.g. "0208:0685660237"
  country: string;           // ISO 3166-1 alpha-2

  // Optional
  vatNumber?: string;
  street?: string;
  city?: string;
  postalCode?: string;
  companyId?: string;        // BT-30 / BT-47
  companyIdScheme?: string;  // e.g. "0208"
  contactName?: string;
  phone?: string;
  email?: string;
}

type BuyerParty = Party & {
  street: string;
  city: string;
  postalCode: string;
}

InvoiceLine

A single line item. Totals are calculated automatically from quantity × unitPrice. Line-level allowances and charges can be added.

InvoiceLine
interface InvoiceLine {
  description: string;
  quantity: number;
  unitPrice: number;
  vatRate: number;            // percentage (e.g. 21)

  // Optional
  unit?: string;              // UN/ECE code or "hour", "day", "kg"...
  vatCategory?: string;       // "S" | "Z" | "E" | "AE" | ...
  itemId?: string;            // seller's item ID
  standardItemId?: string;    // GTIN/EAN
  standardItemScheme?: string;
  baseQuantity?: number;
  accountingCost?: string;    // BT-133
  allowances?: LineAllowanceCharge[];
  charges?: LineAllowanceCharge[];
}

SendResult

Returned by invoices.send(), including credit notes sent with isCreditNote: true. Check Document Status for the full status lifecycle.

SendResult
interface SendResult {
  id: string;
  status: DocumentStatus;
  peppolMessageId?: string;   // Peppol AS4 message ID
  ublXml?: string;            // generated UBL (debug)
  warnings?: ValidationWarning[];
  createdAt: string;          // ISO 8601
}

type DocumentStatus =
  | "submitted" | "delivered" | "accepted"
  | "rejected" | "paid" | "failed"
  | "cleared" | "acknowledged" | "in_process"
  | "under_query" | "conditionally_accepted"
  | "partially_paid" | "no_action" | "unknown";

ServerValidationResult

Returned by invoices.validateServer(). The gateway validates the same payload server-side, verifies UBL XML generation under ubl, and keeps xsd as deprecated compatibility metadata.

ServerValidationResult
interface ServerValidationResult {
  valid: boolean;
  errors: ValidationError[];
  warnings: ValidationWarning[];
  ubl: {
    valid: boolean;
    errors: ServerValidationMessage[];
  };
  /** @deprecated Mirrors ubl.valid; no standalone XSD validator runs. */
  xsd: {
    valid: boolean;
    errors: ServerValidationMessage[];
    note?: string;
  };
  schematron: {
    valid: boolean;
    errors: ServerValidationMessage[];
    warnings: ServerValidationMessage[];
  };
}

interface ServerValidationMessage {
  severity: "error" | "warning";
  message: string;
  location?: string;
  ruleId?: string;
}

PeppolConfig

Configuration options for the SDK client. See Authentication for details.

PeppolConfig
interface PeppolConfig {
  apiKey: string;
  environment?: "sandbox" | "production";
  baseUrl?: string;           // custom endpoint
  timeout?: number;           // ms (default: 30000)
}

Attachment

File attachment for invoices. Supports embedded base64 content or external URL references. See Attachments guide.

Attachment
interface Attachment {
  id: string;                 // document reference
  description?: string;
  filename?: string;          // e.g. "invoice.pdf"
  mimeType?: string;          // e.g. "application/pdf"
  content?: string;           // raw base64, no data URI prefix; 2 MB decoded cap on server validation
  url?: string;               // external URL alternative
}

AllowanceCharge

Discounts and surcharges at document and line level. See Allowances & Charges guide.

AllowanceCharge
// Document-level (BG-20 / BG-21)
interface AllowanceCharge {
  reason: string;
  amount: number;
  vatRate: number;
  vatCategory?: string;
}

// Line-level (BG-27 / BG-28)
interface LineAllowanceCharge {
  reason: string;
  amount: number;
}

WebhookEvent

Webhook event payload. See Webhooks for event types and handler examples.

WebhookEvent
interface WebhookEvent<T = unknown> {
  id: string;
  type: WebhookEventType;
  data: T;
  createdAt: string;
}

type WebhookEventType =
  | "invoice.sent"
  | "invoice.accepted"
  | "invoice.refused"
  | "invoice.error"
  | "invoice.registered"
  | "invoice.paid"
  | "invoice.closed"
  | "invoice.received"
  | "legal_entity.registered"
  | "legal_entity.verification_failed"
  | "legal_entity.awaiting_authz"
  | "creditnote.sent"
  | "creditnote.received"
  | "inbound.invoice.received"
  | "inbound.creditnote.received"
  | "test.ping";