---
title: "Sending & Receiving"
space: "eInvoicing"
url: "https://www.prilk.com/docs/edocument/integration/send-receive"
updated: "2026-05-14"
---

## Sending & Receiving

The day-to-day flow once credentials and webhook/polling are configured.

### Sending — outbound

1. Create / submit a Sales Invoice with a PEPPOL Customer (Customer has Electronic Address)
2. EDocument is auto-created (or click **Generate XML** on a manually-created EDocument)
3. XML is auto-validated; status becomes "Validation Successful"
4. Click **Transmit via API**

What the app does:
- Looks up the matching **EDocument Integration Settings** for the source invoice's Company
- Routes to the configured integrator (B2B Router or Recommand)
- Extracts the recipient's EndpointID from the XML
- Calls the provider's send endpoint with the XML
- Updates EDocument status to "Transmission Successful"
- Stores the provider's document ID in `EDocument.reference` for tracking
- Adds a comment with the tracking ID

If transmission fails, the status changes to "Transmission Failed" and the error is recorded on the EDocument.

### Receiving — inbound

Two delivery channels depending on what your provider supports:

**Webhook (real-time):**
```
Provider receives doc → POSTs to /api/method/edocument_integration.api.webhook
  → EDocument created, XML attached
  → Detector auto-fills profile + company
  → Validator runs against XSD + Schematron
```
You'll see new EDocument records in the inbox seconds after receipt. Open one to review and continue with the matching/import flow.

**Polling (scheduled or manual):**
```
Hourly scheduler (or manual click) → poll provider inbox
  → For each unread doc:
    → Duplicate check (skip if reference exists)
    → Create EDocument (no profile yet — skips premature validation)
    → Attach XML → set profile → save (triggers validation)
```

Both paths converge on the same review-and-create flow.

### Creating Purchase Invoices from inbound documents

After the EDocument has been received and validated:

1. Open the EDocument record
2. (Optional) Click **Match Document** if matching wasn't automatic
3. **Create Document** — parses the XML and creates a Purchase Invoice in one step
4. Or **Create & Review Document** — opens an editable Purchase Invoice form with parsed data, save manually

See [Receiving Invoices](/docs/edocument/receiving-invoices) for the full matching and parsing flow.

### API endpoints

For external automation or testing:

| Endpoint | Method | Purpose |
|---|---|---|
| `/api/method/edocument_integration.api.webhook` | POST | Public — receives XML from service providers |
| `/api/method/edocument_integration.api.transmit_edocument` | POST | Transmit an EDocument; arg: `edocument_name` |
| `/api/method/edocument_integration.api.poll_incoming_invoices` | POST | Manual poll; args: `profile`, optional `company` |
| `/api/method/edocument_integration.api.get_edocument_integration_settings` | POST | Read decrypted credentials (System Manager only) |

### Tracking and audit

| What you want | Where |
|---|---|
| Per-EDocument transmission status | EDocument record — Status field |
| Provider's document ID | `EDocument.reference` field |
| Failed transmissions | EDocument status "Transmission Failed" + Error field |
| Skipped duplicates | Error Log with `reference` ID |
| Webhook payloads | Frappe Request Log (if enabled) |

### Troubleshooting

- **Transmission fails** — open EDocument, check the Error field; verify the recipient's EndpointID is correct and that Integration Settings credentials are valid
- **No incoming documents** — confirm webhook URL or polling is enabled; check provider dashboard for documents stuck in their queue
- **Wrong company auto-assigned** — verify the buyer's EndpointID in the XML matches exactly one Company's Electronic Address; if not, the detector falls back to the customer name

For low-level architecture details, see the [edocument_integration source on GitHub](https://github.com/prilk-consulting/edocument_integration).
