Bill your customers from your product
Mirror customers, issue and send invoices, keep in sync, cancel — while AlphaCount books, sends and dunns.
Your product knows who bought what for which period. AlphaCount knows how a correct German invoice looks, books it, sends it, sees the payment arrive and dunns when it does not. This guide connects the two.
1. Mirror the customer
PUT /customers/by-ref/{source}/{external_ref} creates the customer or updates it to what you send — call it whenever
the customer changes in your product, or before every invoice.
What a valid invoice needs: name, e-mail (where the invoice goes), street, zip, city, country. For a business customer
in another EU country, add the vat_id — without it, AlphaCount cannot issue a reverse-charge invoice. For public
sector customers, leitweg_id goes into the XRechnung. contact_name appears as "attn." under the name.
2. Create the invoice
POST /invoices with an Idempotency-Key:
{
"customer": { "source": "myapp", "external_ref": "cust-42" },
"external_ref": "order-1001",
"lines": [
{ "description": "Licence, October 2026", "quantity": 1, "unit": "Monat", "unit_price_net": "1000.00", "vat_rate": 19 },
{ "description": "Textbook", "quantity": "3", "unit_price_net": "19.90", "vat_rate": 7 }
],
"service_period": { "start": "2026-10-01", "end": "2026-10-31" },
"payment_terms_days": 14,
"issue": true,
"send": true
}external_refis your id for the invoice. AlphaCount keeps one invoice per reference; a second request for the same reference with another key is409 invoice_external_ref_existsand names the invoice.service_periodis required: a German invoice states when the service was provided.- A line may name a product you keep in AlphaCount (
product_ref, or itsproduct_number) so that revenue lands on the product's account and revenue shares can depend on it.
What happens:
issue | send | Result |
|---|---|---|
false | — | a draft; a person reviews and issues it in the app |
true | false | issued: number, VAT verdict, booking, PDF — and e-invoice for business customers |
true | true | issued, then mailed from the company's mailbox |
Issuing runs all the checks the app runs. If one fails — the company has no tax number yet, the address is incomplete,
the VAT verdict needs a person — the answer is 422 invoice_not_issuable with the reasons, and nothing was
created: no draft, no number, no used-up idempotency key.
If the invoice was issued but the mail failed, the answer is still 201, with send_error saying why. Send it later
with POST /invoices/{id}/send.
3. Learn what happens next
Subscribe a webhook to the invoice events. Each comes once per invoice:
| Event | When |
|---|---|
invoice.issued | it got its number |
invoice.sent | it was mailed for the first time |
invoice.paid | it is paid in full — a partial payment is no event |
invoice.overdue | it is past due and unpaid |
invoice.dunning_sent | a reminder or dunning notice went out |
invoice.cancelled | it was cancelled |
Match an event to your record by data.external_ref. Events can arrive twice or out of order — use the envelope's
id to process each once.
To keep a copy in sync without webhooks, ask GET /invoices?changed_since=… on a schedule.
4. Cancel or correct — also after payment
An issued invoice cannot be changed or deleted. POST /invoices/{id}/cancel issues a cancellation invoice — the
negative mirror with its own number and a reference to the original — and books the reversal. It is for an invoice
nothing is paid on yet.
POST /invoices/{id}/corrections corrects any issued invoice, paid or not, with an Idempotency-Key:
{
"external_ref": "order-1001-k1",
"lines": [{ "description": "Training, half day", "quantity": 1, "unit_price_net": "50.00", "vat_rate": 19 }],
"refund": { "amount": "59.50", "paid_on": "2026-11-28" }
}- The original is cancelled by its cancellation invoice; with
linesa corrected invoice replaces it under the newexternal_ref— a partial credit is a corrected invoice with less on it. Withoutlinesit is a full credit note. - What was paid on the original moves to the corrected invoice; the rest becomes the customer's credit, with the VAT
it contains.
refundgives (part of) that credit back; the VAT goes back with it in the period of the refund. - Refunds, credit notes and chargebacks made in Stripe arrive with the Stripe sync and need no call (Stripe).
5. Take over invoices from your old system
POST /invoices/import takes over an invoice another system issued — moving from Wix, a shop or an old tool. It keeps
its number and issue_date, is booked as an open item, counts as sent, is dunned when overdue, and payments it
already had are booked with their dates. The original PDF goes along as pdf_base64. AlphaCount issues nothing a second
time; a number the company has already is 409 invoice_number_exists. More in Migration.
6. Record a payment you collected
Money AlphaCount sees on the company's bank account is matched to the invoice without a call. Money you collected
yourself — a PSP charge, a direct debit, cash — you report with POST /invoices/{id}/payment and an
Idempotency-Key:
curl -X POST https://app.alphacount.ai/api/partner/v1/invoices/<id>/payment \
-H "Authorization: Bearer $ALPHACOUNT_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "amount": "119.00", "paid_on": "2026-11-20" }'AlphaCount books it, sets the invoice to partially_paid or paid, stops dunning for what is paid, and sends
invoice.paid once it is settled in full. A payment less the cash discount the invoice offers, inside its window,
settles it, and so does one that misses the open amount by no more than the company's tolerance. More than that
answers 422 invoice_not_payable. One key per payment: a payment adds up, so a retry without the same key would
book it twice. The body fields are in the reference.
7. Know the tax before checkout
POST /tax/quote tells you what a sale is taxed at — German VAT, reverse charge to an EU business, an export, an OSS
sale at the customer's member-state rate — by the engine that issues the invoice. Send the same lines to
POST /invoices and the amounts are the same. See Taxes.
What the API does not do
- issue a draft — that is done in the app;
- change an issued invoice — it is corrected (above);
- override a tax warning that a person would confirm in the app;
- start dunning — AlphaCount does that from the open items;
- bill in another currency than EUR, or at another VAT rate than 0, 7 or 19 % on its own invoices — sales taxed in another EU state (OSS) are billed through Stripe and booked from there.