Example: invoices
A complete example from start to finish: your webshop should create invoices in e-conomic, without ever holding an e-conomic key and without knowing how e-conomic wants its invoices.
1. Connect e-conomic
An admin opens Services → Add a service, picks e-conomic from the gallery and signs in to the company's e-conomic agreement. OneAPI makes one harmless call to check the sign-in before saving it, encrypted. Nobody sees it again, and the webshop never gets it.
2. Design the Invoice
Under Artifacts, create an Invoice with the fields your company needs. The lines are their own artifact, InvoiceLine, part of the invoice, so an invoice and its lines are written in one call. (Or import "Accounting basics for e-conomic" from the artifact library and get all of this ready-made.)
| Field | Kind | Note |
|---|---|---|
customer_name | text, required | Copied onto the invoice |
customer_address, customer_city, customer_zipcode, customer_country | text | The country decides the VAT zone |
invoice_date | date, required | |
invoice_currency | choice: DKK, EUR, SEK, NOK, USD | Applies to every line |
invoice_lines | parts: InvoiceLine | Description, price, count, discount %; total is read-only |
3. Describe what "create" does
e-conomic wants a customer number on every invoice, but the webshop only knows the customer's name. So the create flow first looks the customer up, creates them if they're new, and then creates the invoice:
Each call has a mapping table: what to send, and where it comes from. Most rows point at an Invoice field; others come from an earlier step, a setting of the service, a fixed value or a formula.
| e-conomic's draft invoice | comes from | |
|---|---|---|
date | ← | Invoice field invoice_date |
currency | ← | Invoice field invoice_currency |
customer.customerNumber | ← | the customer found or created in an earlier step |
recipient.name | ← | Invoice field customer_name |
lines[].unitNetPrice | ← | for each line: invoiceline_price |
paymentTerms.paymentTermsNumber | ← | the e-conomic service's setting (set once by an admin) |
Before publishing, Test this flow runs the whole flow for real and shows every step on the flowchart: what was sent, what came back, which way each decision went. A good run can be saved as a test case, and OneAPI replays it whenever the flow changes.
4. Give the webshop a key
Under People & API keys, create an API key called "Webshop" and give it W WRITE on Invoice (which includes R READ). The key is shown once. The webshop can now create and read invoices, and nothing else: to the webshop, Customer and every other artifact don't exist.
5. The webshop calls the API
POST /api/invoice/
Authorization: Bearer oa_svc_…
Content-Type: application/json
{
"customer_name": "Nordic Bikes ApS",
"customer_zipcode": "8000",
"customer_country": "Denmark",
"invoice_date": "2026-11-08",
"invoice_currency": "DKK",
"invoice_lines": [
{ "invoiceline_description": "Service, 2 hours", "invoiceline_price": 450, "invoiceline_count": 2 }
]
}
OneAPI answers in the Invoice's own shape, with the ids it issued:
201 Created
{
"invoice_id": 17,
"customer_name": "Nordic Bikes ApS",
…
"invoice_lines": [
{ "invoiceline_id": 18, "invoiceline_description": "Service, 2 hours",
"invoiceline_price": 450, "invoiceline_count": 2, "invoiceline_total": 900 }
]
}
Behind the scenes OneAPI made three calls on e-conomic, and the call log shows them under the webshop's name:
| Caller | Call | Service calls | Status |
|---|---|---|---|
| Webshop (API key) | POST /api/invoice/ | GET /customers · 200 POST /customers · 201 POST /invoices/drafts · 201 |
201 · 640 ms |
The log records that these calls happened, never the customer's name or the amounts.
6. Later: a new accounting system
A year on, the company moves from e-conomic to Dinero. Without OneAPI, the webshop's integration is rewritten.
With OneAPI, an admin adds Dinero and changes the Invoice's flows to call it. The webshop keeps calling
POST /api/invoice/ with the same fields and the same key, and doesn't notice.