Accounts Receivable

Issuing e-invoices through Staple

View as Markdown

Business flow

Accounts Receivable (AR) covers the flow of issuing e-invoices from your business to your customers. With Staple, your accounting or ERP system does not need to integrate directly with each country’s tax authority or with the Peppol network — Staple handles all the country-specific format conversion, validation, and transport on your behalf.

One format, every country: STAR

Every country defines its own e-invoice format. Singapore uses Peppol UBL. Malaysia uses MyInvois UBL 2.1. India uses IRP JSON. Poland uses KSeF XML. Mexico uses CFDI XML. Each format has its own field names, structure, and validation rules. If your business operates in more than one country, integrating directly with each format multiplies the engineering work with every country added.

To remove this burden, Staple defines a single unified schema called STARStaple Transactional API Records. STAR is a country-agnostic representation of an invoice. You map your ERP data to STAR once, and Staple takes responsibility for converting STAR into the format each tax authority expects.

The full STAR schema reference is documented in Schema Objects.

One STAR format, every country

How the AR flow works

The flow works as follows:

  1. Your system produces a STAR invoice. Your accounting or ERP system constructs an invoice in STAR format using the data fields documented in the Schema Objects reference.
  2. Submit the invoice to Staple. Your system calls the Submit endpoint with the STAR payload. Staple acknowledges receipt and queues the invoice for processing. The acknowledgement returns a docId you will use in subsequent steps.
  3. Staple validates and clears the invoice. Behind the scenes, Staple performs two distinct steps:
    • Validation — Staple converts the STAR payload into the destination country’s e-invoice format and validates it against the schema and the relevant tax authority’s rules.
    • Clearance — Once validation passes, Staple submits the converted invoice to the tax authority portal or the Peppol network. The tax authority returns a clearance reference (such as a MyInvois UUID, SDI IdentificativoSdI, KSeF number, or IRN) that legally identifies the issued invoice.
  4. Your system learns the outcome. You can learn the outcome in two ways:
    • Push — subscribe to webhook events and Staple notifies your server when each step completes.
    • Pull — call the Get invoice status endpoint at any time with the docId to retrieve the current validation status and clearance evidence.
  5. Your buyer may accept, reject, or pay the invoice. Days or weeks later, the buyer at the receiving end may take action on the invoice you issued. If you want to be notified of buyer actions — particularly rejections — you can subscribe to the relevant webhook event.

Country support

Staple’s AR flow supports all 12 countries: 🇸🇬 Singapore · 🇨🇳 China · 🇲🇾 Malaysia · 🇵🇱 Poland · 🇫🇷 France · 🇧🇪 Belgium · 🇮🇹 Italy · 🇩🇪 Germany · 🇪🇸 Spain · 🇧🇷 Brazil · 🇲🇽 Mexico · 🇮🇳 India. Country-specific behaviour, required fields, and validation rules are documented inside each schema object and on the per-country payload pages.

Submit API

POST https://api.staple.io/v2/einvoice/submit/queue/:queueId

Submit a STAR e-invoice to Staple for conversion, validation, and submission to the destination country’s tax authority or the Peppol network. Compliance processing runs asynchronously — this endpoint acknowledges receipt of the payload and returns identifiers you can use to track the outcome.

queueId
integerRequired

The queue ID the document should land in.

Authorization
stringRequired

Bearer token, e.g. Authorization: Bearer <token>.

*
JSONRequired

The full STAR invoice payload. See Schema Objects for the complete schema reference.

1POST https://api.staple.io/v2/einvoice/submit/queue/4173
2Authorization: Bearer <token>
3Content-Type: application/json
4
5{
6 "Country": "DE",
7 "ComplianceStandards": ["eu-en16931-v2017", "de-xrechnung-v3"],
8 "DocNumber": "INV-0001",
9 "IssueDate": "2026-05-09",
10 "Currency": "EUR",
11 "Supplier": {
12 "Name": "Mustermann GmbH",
13 "TaxID": { "Country": "DE", "Code": "111111125" }
14 },
15 "Customer": {
16 "Name": "Buyer GmbH",
17 "TaxID": { "Country": "DE", "Code": "222222229" }
18 },
19 "Lines": [
20 {
21 "Quantity": "1.00",
22 "Item": { "Name": "Consulting service", "Price": "1000.00" },
23 "Taxes": [{ "Cat": "VAT", "Rate": "standard" }]
24 }
25 ]
26}

The example above shows a minimum payload for Germany. The required fields and country-specific extensions differ for each supported country. See the Request Payloads section for the minimum payload example per country.

Response fields

FieldDescription
statusThe acknowledgement status from Staple. ACCEPTED indicates the payload was received and queued for processing. Validation and clearance run asynchronously.
messageHuman-readable confirmation message.
docIdThe Staple-assigned identifier for the document. Use this with the Get invoice status endpoint and the Search documents endpoint.
docNumberThe invoice number provided in the submitted payload.
queueIdThe queue the document was placed into.

After submission, validation and clearance run asynchronously. To learn the outcome, either subscribe to the webhook events described in Webhook notifications below, or pull the current status using the Get invoice status endpoint.

Get invoice status

GET https://api.staple.io/v1/documents/{identifier}

Retrieve the current validation and clearance status of an e-invoice you previously submitted. Use this endpoint when you need to check the outcome on demand — for example, when reconciling with your accounting system or troubleshooting a specific invoice.

The response is country-agnostic. Country-specific clearance evidence (such as MyInvois UUID, SDI IdentificativoSdI, or KSeF number) is returned inside the clearance block.

identifier
integer or stringRequired

Either the Staple docId (integer) returned by the Submit endpoint, or the taxAuthorityReference (string) such as a MyInvois UUID or KSeF number. The endpoint detects the type automatically.

Authorization
stringRequired

Bearer token, e.g. Authorization: Bearer <token>.

1GET https://api.staple.io/v1/documents/9021
2Authorization: Bearer <token>

validation block

The validation block describes whether the submitted invoice passed Staple’s internal validation and the tax authority’s schema-level rules.

FieldTypeDescription
statusstringValidation outcome. One of pending, passed, or failed.
completedAtstring (datetime)ISO 8601 timestamp of when validation completed. null if still pending.
faultsstring[]List of validation faults when status is failed. Empty array when validation passed.

clearance block

The clearance block describes whether the tax authority or the Peppol network has accepted the invoice and what evidence has been issued.

FieldTypeDescription
statusstringClearance outcome. One of pending, cleared, or failed. pending means validation passed and Staple is currently submitting to the tax authority.
completedAtstring (datetime)ISO 8601 timestamp of when clearance completed. null if still pending.
sourcestringThe system that performed the clearance. One of tax_authority or peppol.
referencestringThe clearance reference issued by the source system — for example, the MyInvois UUID, SDI IdentificativoSdI, KSeF number, IRN, or Peppol Message ID.
validationLinkstringA URL to a tax authority page that displays the cleared invoice, where applicable. null if the source system does not provide a public link.

Search documents

POST https://api.staple.io/v2/search/documents

Search for e-invoices you have issued. Filter by Staple document ID, your own invoice number, tax authority reference, status, or date range. This endpoint returns a paginated list of summary results — for full validation and clearance details on a specific invoice, use the Get invoice status endpoint.

Authorization
stringRequired

Bearer token, e.g. Authorization: Bearer <token>.

filter
objectRequired

Filter criteria. See the fields below.

pagination
objectRequired

Pagination control. See the fields below.

filter object fields

FieldTypeRequiredDescription
documentIdsinteger[]OptionalArray of Staple document IDs to look up directly.
docNumbersstring[]OptionalArray of seller invoice numbers (the DocNumber field from the submitted STAR payload).
taxAuthorityReferencesstring[]OptionalArray of tax authority references to look up directly (MyInvois UUID, SDI IdentificativoSdI, KSeF number, IRN, or Peppol Message ID).
queueinteger[]OptionalArray of queue IDs to search within.
tabstring[]OptionalDocument state(s) to include. Allowed values: RECEIVED, COMPLETED, REJECTED, EXPORTED, EXPORT_FAILED.
uploadedAtobjectOptionalFilter by upload date. Object with from and to fields, each formatted as dd/mm/yyyy.
completedAtobjectOptionalFilter by completion date. Object with from and to fields, each formatted as dd/mm/yyyy.
rejectedAtobjectOptionalFilter by rejection date. Object with from and to fields, each formatted as dd/mm/yyyy.
exportedAtobjectOptionalFilter by export date. Object with from and to fields, each formatted as dd/mm/yyyy.

pagination object fields

FieldTypeRequiredDescription
skipintegerRequiredCurrent page number (zero-indexed).
takeintegerRequiredNumber of documents to return per page.
1POST https://api.staple.io/v2/search/documents
2Authorization: Bearer <token>
3Content-Type: application/json
4
5{
6 "filter": {
7 "queue": [4173],
8 "tab": ["COMPLETED"],
9 "uploadedAt": {
10 "from": "01/05/2026",
11 "to": "31/05/2026"
12 }
13 },
14 "pagination": {
15 "skip": 0,
16 "take": 50
17 }
18}

The underlying endpoint supports additional filters used elsewhere in the Staple platform (such as filename and content search) — those filters are omitted here as they are not commonly used in e-invoice workflows.

Webhook notifications

Subscribe to webhook events so your system is notified when Staple completes asynchronous processing of an e-invoice you submitted — without polling. Configure your webhook URL in User Profile → Webhooks. You will need the Manage webhooks permission to do this.

Three e-invoice events are available:

EventFired when
document.validation_completedStaple’s internal validation step completes. The payload indicates whether validation passed or failed.
document.clearedThe tax authority or Peppol network confirms acceptance of the invoice and issues a clearance reference.
document.rejected_by_buyerThe buyer has rejected an invoice you previously issued. Useful for AR teams to react to disputes or duplicate-invoice issues raised by buyers.

Webhook payload — document.validation_completed

1{
2 "event": "document.validation_completed",
3 "payload": {
4 "docId": 9021,
5 "docNumber": "INV-0001",
6 "country": "DE",
7 "validation": {
8 "status": "passed",
9 "completedAt": "2026-05-09T09:18:42Z",
10 "faults": []
11 }
12 }
13}

When validation fails, the faults array contains the validation errors:

1{
2 "event": "document.validation_completed",
3 "payload": {
4 "docId": 9021,
5 "docNumber": "INV-0001",
6 "country": "DE",
7 "validation": {
8 "status": "failed",
9 "completedAt": "2026-05-09T09:18:42Z",
10 "faults": [
11 "Tax code mismatch for line 1",
12 "Missing buyer reference for DE XRechnung"
13 ]
14 }
15 }
16}

Webhook payload — document.cleared

1{
2 "event": "document.cleared",
3 "payload": {
4 "docId": 9021,
5 "docNumber": "INV-0001",
6 "country": "DE",
7 "clearance": {
8 "status": "cleared",
9 "completedAt": "2026-05-09T09:21:00Z",
10 "source": "tax_authority",
11 "reference": "DE-XR-2026-AB12C345",
12 "validationLink": "https://example-tax-authority/invoices/DE-XR-2026-AB12C345"
13 }
14 }
15}

Webhook payload — document.rejected_by_buyer

1{
2 "event": "document.rejected_by_buyer",
3 "payload": {
4 "docId": 9021,
5 "docNumber": "INV-0001",
6 "country": "DE",
7 "rejection": {
8 "rejectedAt": "2026-05-12T14:05:00Z",
9 "reasons": ["duplicate", "incorrect_amount"]
10 }
11 }
12}