Skip to content
Back to News
Changelog

SDK 6.4.0: answer a received invoice with receivedDocuments.respond

sdkreceiving

@getpeppr/sdk 6.4.0 brings Invoice Responses to the SDK. It is a minor release: nothing you already call changes.

import { Peppol } from "@getpeppr/sdk";

const peppol = new Peppol({ apiKey: "sk_live_..." });

// The id from the inbound.invoice.received webhook (data.receivedDocumentId)
const receivedDocumentId = "3f7c1a52-9d4e-4c1b-8a2f-6b5e0d1c7a93";

const response = await peppol.receivedDocuments.respond(
  receivedDocumentId,
  {
    responseCode: "RE",
    reasons: [{ code: "REF", text: "Purchase order number missing" }],
    actions: [{ code: "NIN" }],
  },
  // Same key on a retry: the response is never sent twice
  { idempotencyKey: `reject-${receivedDocumentId}` },
);

console.log(response.delivery); // "submitted"

What 6.4.0 adds

A supplier that does not accept Invoice Responses on the Peppol network is refused at once, and nothing is sent: PeppolApiError 422, result code received_documents.response_not_accepted_by_sender.

The Invoice Responses guide covers the codes, the delivery states and the refusals.

Install with npm install @getpeppr/sdk@6.4.0.