Workflows
This guide describes common workflows in the Billogram API. The workflows combine API requests, commands, and webhook events into practical sequences.
Workflow 1: The Standard Invoicing Flow
There are two ways to create and send a billogram: an atomic (single-request) approach and a two-step approach.
Option A: Atomic (Recommended)
Create and send in a single request. This is the most efficient approach and avoids the billogram getting stuck in an Unattested state.
- Create + Send:
POST /billogramwith anon_successobject.- Payload Snippet:
{"on_success": {"command": "send", "method": "Email"}}. - Events:
BillogramCreatedfollowed byBillogramSent.
- Payload Snippet:
Option B: Two-Step
Create the billogram first, then send it as a separate step. This is useful when you need to review or modify the billogram before sending.
- Create:
POST /billogramwithout anon_successobject. The billogram is created in theUnattestedstate.- Event:
BillogramCreated.
- Event:
- Send:
POST /billogram/{id}/command/sendto attest and send the billogram.- Event:
BillogramSent.
- Event:
After Sending
Regardless of which option you chose, the remaining flow is the same:
- Payment: The customer pays via provided methods.
- Event:
Payment(theremaining_sumdecreases).
- Event:
- Completion: The billogram is fully settled.
- Event:
BillogramEnded.
- Event:
Workflow 2: Crediting an Invoice
Invoices are immutable. Corrections require a credit invoice generated within the same billogram via POST /billogram/{id}/command/credit.
| Mode | Payload | Best For |
|---|---|---|
| Full | {"mode": "full"} |
Full cancellations |
| Items | {"mode": "items", "items": [...]} |
Per-item credit; count must be negative |
Workflow 3: Stand-alone Credits and Allocation
What is a Stand-alone Credit?
Unlike credits in workflow 2 created within an existing billogram to offset a specific debit invoice, stand-alone credits are created as isolated objects. They are typically used in B2B scenarios where a credit needs to be applied flexibly across multiple different invoices over time.
Key Characteristics:
- They always have a negative sum.
- They cannot be converted into debit invoices.
- They must be enabled by Billogram support before use.
- They support the
DoNotNotifydelivery method if you prefer not to send a credit to the customer.
Workflow: Creating and Allocating Credit
- Create the Credit:
POST /billogramwith negative item prices. - Identify Target: Find the debit billogram ID that should receive the credit.
- Allocate:
POST /billogram/{debit_id}/command/credit-allocate.- Payload:
{"amount": 500.00, "source_id": "credit_billogram_id"}. - Validation: The
amountmust not exceed the remaining credit or the target's remaining debt.
- Payload:
- Multi-allocation: If the credit has a remaining balance, repeat step 3 for the next debit billogram.
Workflow 4: Respite & Rescheduling
Use this to grant additional time for payment by setting a respite date, which postpones both dunning and any scheduled payments.
- Webhook: It could be triggered from
BillogramEventwithevent.type = CustomerMessagerequesting for additional time to pay. - Extend:
POST /billogram/{id}/command/respite.- Constraint: The new
datemust be later than the currentdue_date. - Scheduled Payment: The scheduled payments are automatically moved to the new date.
- Constraint: The new
- Remove:
POST /billogram/{id}/command/remove-respiteto cancel a previously granted respite.
Workflow 5: Overdue Management
- Reactive: Monitor
event.type = Overdueand for example initiate manual reminders. - Manual Reminder:
POST /billogram/{id}/command/remind.- Constraint: You cannot send more than one reminder on the same day.
- Automatic: Configure
automatic_remindersin your accountsettingsto let billogram handle delivery schedules. You can also set automatic dunning settings per billogram during creation.
Workflow 6: Handling SEPA R-Transactions
Use this flow to handle scenarios where a settled payment is later recalled by the payer or their bank.
- Initial Settlement: Billogram is paid and
BillogramEndedis triggered. - Payment Recalled: A bank initiates a recall.
- Webhook:
callback_type: PaymentRecalledis triggered. - System Impact: The billogram is automatically reopened (state often changes to
Overdue).
- Webhook:
- Recovery: If the customer doesn't pay / settle the debt, the billogram will enter the configured dunning sequence.