API integration specification
Integration: Shop orders to accounting
Version: 1.0
Written by: Hamza Idrissi
Date: 5 April 2029
1. Purpose
Send each paid web shop order to the accounting system as a sales invoice, so finance does not retype it.
2. Systems
- Sends data: Web shop (API v2)
- Receives data: Accounting system (REST API)
3. Data flow
1. A customer pays for an order.
2. The shop sends a webhook to the integration service.
3. The service turns the order into an invoice and calls the accounting API.
4. The accounting system returns an invoice number, which the service saves on the order.
4. Endpoints and messages
| Method and path | What it does | Main fields | What it returns |
|---|---|---|---|
| POST /invoices | Create an invoice | Body: customer, lines, tax, total | Returns: invoice id and number |
| GET /customers?email= | Find a customer | Returns: customer id or empty | |
| POST /customers | Create a customer | Body: name, email, address |
5. Field mapping
order.total_paid → invoice.total
order.billing_email → customer.email
order.items[].sku → line.product_code
6. Authentication and security
OAuth 2.0 client credentials. Tokens last one hour. Secrets are kept in the vault, never in code. All calls use HTTPS. Webhooks are signed and the signature is checked.
Personal data is sent only when needed, is not written to logs, and is covered by the privacy terms of both systems.
7. Errors and retries
Retry on 429 and 5xx up to 5 times with growing delays. Do not retry 4xx errors; log them and alert finance. Each invoice has a unique key so a retry cannot create a duplicate.
8. Limits and volumes
The accounting API allows 60 calls per minute. Expected 400 orders a day, up to 2,000 on sale days.
9. Testing
Use the accounting sandbox. Test a normal order, an order with a discount, a refund, a customer who already exists, and an API outage.
10. Owners and support
Owner: E-commerce team. Support: Hamza Idrissi. Escalation: the accounting vendor's support desk.
11. Changes and versioning
Either side gives 30 days' notice of a breaking change.