# Calculate an invoice `POST https://api.leapa.co/v2/invoices/calculate` Send your API key as a bearer token in the `Authorization` header. ## Request body Required. `application/json`. - `description` · _string_ · **required** — Description of the invoice. Constraints: Not null, min=3 and max=120 Must be: 3 to 120 characters - `affiliate` · _string_ — affiliate that can be used on this invoice Allowed values: `dwelinn` - `sendForManualPayment` · _boolean_ - `customer_id` · _string_ · **required** — Customer Id. Constraints: Not null - `products` · _array of ItemRequest_ · **required** — List of product and quantity. Constraints: Not null, Not Empty - `quantity` · _integer_ · **required** — Quantity for this product. Constraints: Not null - `product_id` · _string_ · **required** — Product Identifications. Constraints: Not Null - `rate_ids` · _array of string_ — RateIds - `due_date` · _string_ · **required** — Invoice due date. Constraints: Not null, format(YYYY-MM-DD) - `source_id` · _string_ — Customer existing source information. - `manual_payment` · _boolean_ — Collection 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_id` · _string_ — Rate Id that can be used on this invoice. - `amount_to_paid` · _number_ — this is for partial payment of an invoice - `custom_fields` · _object_ — Extra 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"}` ```json { "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 200 - `currency` · _string_ — Currency of the amount in the invoice. Allowed values: `BIF`, `USD`, `KES`, `XAF` - `amount_due` · _integer_ — amount upon applying the rate to be paid for this Invoice. - `rate_id` · _string_ — Rate Id that can be used on this invoice. ```json { "currency": "BIF", "amount_due": 45000, "rate_id": "rat_20b6df3c9e" } ``` ## Status codes - `200` OK - `400` Bad request - `401` Unauthorized - `402` Payment required - `403` Forbidden - `404` Not found - `428` Precondition required - `500` Server error ## Example ```bash 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" } }' ``` --- _Generated from the Leapa documentation at leapa.co/docs._