Xero.EInvoicing (Xero v1.0.0)

Copy Markdown View Source

Xero eInvoicing API – PEPPOL BIS 3.0 / UBL 2.1 electronic invoicing. Base URL: https://api.xero.com/einvoicing Scope: einvoicing.documents

Available primarily for AU and NZ organisations on the PEPPOL network. UK support is in progress — check Xero documentation for current availability.

What is eInvoicing?

eInvoicing is the automated digital exchange of structured invoices between accounting systems via the PEPPOL network. No email, no PDFs, no manual data entry. The format is PEPPOL BIS 3.0 (UBL 2.1 XML).

PEPPOL Participant IDs

Format: scheme:value

  • AU ABN: "0151:12345678901" (11 digits)
  • AU ARBN: "0151:12345678" (9 digits)
  • NZ IRD: "0088:1234567890" (NZBN)
  • GLN: "0088:1234567890123"

Workflow

  1. lookup_participant/3 — verify recipient is on PEPPOL
  2. Ensure your invoice is AUTHORISED in Xero
  3. send_document/3 — send the invoice
  4. get_document_status/3 — poll until "DELIVERED" or "FAILED"
  5. For inbound: list_documents/3 with direction: "RECEIVED", then acknowledge_document/3

Document Statuses

StatusDescription
"SENT"Document transmitted to PEPPOL network
"DELIVERED"Recipient's access point confirmed delivery
"FAILED"Delivery failed — see error details
"REJECTED"Recipient rejected the document

Summary

Functions

Acknowledges receipt of an inbound e-invoice.

Downloads the raw UBL 2.1 XML for an e-invoicing document.

Retrieves a single e-invoicing document by ID.

Gets the delivery status of a sent e-invoice.

Returns the PEPPOL registration details for the connected organisation itself. Use this to check if your organisation is properly registered on the PEPPOL network.

Lists sent and/or received e-invoicing documents.

Checks if a business is registered as a PEPPOL participant.

Rejects an inbound e-invoice.

Sends an AUTHORISED Xero invoice as a PEPPOL e-invoice to the recipient.

Functions

acknowledge_document(t, tid, id)

@spec acknowledge_document(Xero.Auth.Token.t(), String.t(), String.t()) ::
  :ok | {:error, Xero.Error.t()}

Acknowledges receipt of an inbound e-invoice.

Acknowledge inbound documents once processed to prevent re-delivery. Should be called after successfully importing the invoice into your system.

download_document(t, tid, id)

@spec download_document(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, binary()} | {:error, Xero.Error.t()}

Downloads the raw UBL 2.1 XML for an e-invoicing document.

Returns binary XML suitable for archiving, forwarding, or compliance storage.

get_document(t, tid, id)

@spec get_document(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Retrieves a single e-invoicing document by ID.

get_document_status(t, tid, id)

@spec get_document_status(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Gets the delivery status of a sent e-invoice.

Poll this after send_document/3 until status is "DELIVERED" or "FAILED". Recommended polling interval: 30 seconds for first 5 minutes, then 5 minutes.

get_organisation_participant(t, tid)

@spec get_organisation_participant(Xero.Auth.Token.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Returns the PEPPOL registration details for the connected organisation itself. Use this to check if your organisation is properly registered on the PEPPOL network.

list_documents(t, tid, opts \\ [])

@spec list_documents(Xero.Auth.Token.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Lists sent and/or received e-invoicing documents.

Options

  • :direction"SENT" | "RECEIVED" (omit for both)

  • :status"SENT" | "DELIVERED" | "FAILED" | "REJECTED"

  • :date_from / :date_to — Date range (YYYY-MM-DD)
  • :page — Page number
  • :page_size — Items per page (max 100)

lookup_participant(t, tid, participant_id)

@spec lookup_participant(Xero.Auth.Token.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Checks if a business is registered as a PEPPOL participant.

Parameters

  • participant_id — PEPPOL participant ID in scheme:value format e.g. "0151:12345678901" (AU ABN) or "0088:1234567890123" (GLN)

Returns participant details if registered, or :not_found error if not.

reject_document(t, tid, id, attrs)

@spec reject_document(Xero.Auth.Token.t(), String.t(), String.t(), map()) ::
  :ok | {:error, Xero.Error.t()}

Rejects an inbound e-invoice.

Use this when you receive an invoice that you cannot process (e.g. wrong recipient, duplicate, incorrect details).

Required fields

  • "rejectReason" — Reason code for rejection
  • "rejectDescription" — Human-readable rejection description

send_document(t, tid, attrs)

@spec send_document(Xero.Auth.Token.t(), String.t(), map()) ::
  {:ok, map()} | {:error, Xero.Error.t()}

Sends an AUTHORISED Xero invoice as a PEPPOL e-invoice to the recipient.

The invoice must already exist in Xero with status AUTHORISED. The contact must have a valid PEPPOL participant ID configured.

Required fields

  • "invoiceId" — UUID of the AUTHORISED Xero invoice to send

Optional fields

  • "documentType" — PEPPOL document type code (default: standard invoice)