Calculate an invoice
This endpoint needs your API key
Send it as a bearer token in the Authorization header. A request without one is answered with 401. See Authentication for where to find your key and how to keep it secret.
Request
curl -X POST "https://api.leapa.co/v2/invoices/calculate" \
-H "Authorization: Bearer $LEAPA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "Room 204, two nights",
"affiliate": "dwelinn",
"sendForManualPayment": false,
"customer_id": "cus_3d8e51fa20",
"products": [
{
"quantity": 1,
"product_id": "prd_84c2e7f019",
"rate_ids": []
}
],
"due_date": "2026-01-31",
"source_id": "src_0e7b3c95af",
"manual_payment": false,
"rate_id": "rat_20b6df3c9e",
"amount_to_paid": 45000,
"custom_fields": {
"obr_code": "ADB_REGISTRE_COMMERCE"
}
}'Response
OK
{
"currency": "BIF",
"amount_due": 45000,
"rate_id": "rat_20b6df3c9e"
}Request body
Required. Send it as JSON.
descriptionstringrequiredDescription of the invoice. Constraints: Not null, min=3 and max=120
Must be:3 to 120 charactersaffiliatestringaffiliate that can be used on this invoice
Allowed values:dwelinnsendForManualPaymentbooleancustomer_idstringrequiredCustomer Id. Constraints: Not null
productsarray of ItemRequestrequiredList of product and quantity. Constraints: Not null, Not Empty
quantityinteger<int64>requiredQuantity for this product. Constraints: Not null
product_idstringrequiredProduct Identifications. Constraints: Not Null
rate_idsarray of stringRateIds
due_datestring<date>requiredInvoice due date. Constraints: Not null, format(YYYY-MM-DD)
source_idstringCustomer existing source information.
manual_paymentbooleanCollection Method of this invoice: If the payment is automatic then the system will charge against the customer register card. If it is manual the system will send an email to the customer with payment instruction.
rate_idstringRate Id that can be used on this invoice.
amount_to_paidnumber<double>this is for partial payment of an invoice
custom_fieldsobjectExtra key/value pairs carried with the invoice. Every value has to be a string. For Burundi tax collection, set obr_code to the OBR payment code the payment belongs to, for example ADB_REGISTRE_COMMERCE. Leapa sends that code to OBR when the invoice is paid and puts the quittance number OBR issues on the invoice, as quittance_number. Write once: the invoice does not return custom_fields, and updating an invoice cannot change it, so keep your own record of which code you sent.
Example:{"obr_code":"ADB_REGISTRE_COMMERCE"}
Response
currencystringCurrency of the amount in the invoice.
Allowed values:BIFUSDKESXAFamount_dueinteger<int64>amount upon applying the rate to be paid for this Invoice.
rate_idstringRate Id that can be used on this invoice.
Status codes
200OK400Bad request401Unauthorized402Payment required403Forbidden404Not found428Precondition required500Server error