Xtopay

Invoices & Billing API

Create, retrieve, list, finalize, and void invoices, and manage client billing lifecycles.

Invoices & Billing API

Invoices represent itemized bills sent to customers for products or services. Invoices are compiled automatically for recurring subscriptions at the start of each billing period, or they can be created manually via the API or Xtopay Dashboard to bill clients for custom work.


Invoice Lifecycle & States

An invoice progresses through several statuses during its billing lifecycle:

StatusDescription
DRAFTThe invoice is being compiled. It is not visible to the customer and can still be edited.
OPENThe invoice is finalized, has a unique invoice number, and is sent to the customer for payment.
PAIDThe invoice total has been fully paid by the customer.
VOIDThe invoice was canceled or marked as voided.
UNCOLLECTIBLEThe customer failed to pay after multiple retry attempts, and the invoice is written off.

Create an Invoice

Create a new draft invoice to bill a customer. You can add one or more line items.

DetailDescription
API Endpointhttps://api.xtopay.co/v1/invoices
Request TypePOST
Content Typeapplication/json
AuthenticationBasic Base64(clientId:clientSecret)
Required Scopepayments:write

Request Parameters

ParameterTypeRequiredDescription
customerIdStringYesUnique Customer ID to bill (e.g. cust_cl8z2lh82...).
currencyStringNoISO 4217 currency code (e.g. "GHS").
taxPercentFloatNoOptional tax percentage to apply to the subtotal (e.g. 12.5 for 12.5%).
discountAmountIntegerNoFlat discount value to subtract from the subtotal in minor units (e.g. 500 = GHS 5.00).
itemsArrayYesList of invoice line items to bill. Structure detailed below.
items[].descriptionStringYesDescription narration of the billed item.
items[].quantityIntegerYesBilled quantity of the item.
items[].unitAmountIntegerYesUnit price of the item in minor units (e.g. 2000 = GHS 20.00).
metadataObjectNoFlat key-value object containing invoice metadata.

Code Examples

curl https://api.xtopay.co/v1/invoices \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "cust_cl8z2lh820000a",
    "currency": "GHS",
    "items": [
      {
        "description": "Enterprise Development Support",
        "quantity": 1,
        "unitAmount": 150000
      }
    ]
  }'

Sample Response

201 Created

{
  "success": true,
  "data": {
    "id": "inv_cl9a1b2c30000y",
    "invoiceNumber": "INV-2026-0042",
    "customerId": "cust_cl8z2lh820000a",
    "status": "DRAFT",
    "subtotal": 150000,
    "tax": 0,
    "discount": 0,
    "total": 150000,
    "amountDue": 150000,
    "amountPaid": 0,
    "currency": "GHS",
    "paymentUrl": null,
    "createdAt": "2026-06-05T12:00:00Z"
  }
}

Retrieve an Invoice

Retrieve the details of an existing invoice.

DetailDescription
API Endpointhttps://api.xtopay.co/v1/invoices/:id
Request TypeGET
AuthenticationBasic Base64(clientId:clientSecret)
Required Scopepayments:read

Path Parameters

ParameterTypeRequiredDescription
:idStringYesUnique Invoice ID to retrieve.

Code Examples

curl https://api.xtopay.co/v1/invoices/inv_cl9a1b2c30000y \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"

Finalize an Invoice

Transitions a draft invoice status to OPEN and generates a payment link.

DetailDescription
API Endpointhttps://api.xtopay.co/v1/invoices/:id/finalize
Request TypePOST
AuthenticationBasic Base64(clientId:clientSecret)
Required Scopepayments:write

Path Parameters

ParameterTypeRequiredDescription
:idStringYesUnique ID of the draft invoice to finalize.

Code Examples

curl -X POST https://api.xtopay.co/v1/invoices/inv_cl9a1b2c30000y/finalize \
  -u "YOUR_CLIENT_ID:YOUR_CLIENT_SECRET"

Sample Response

200 OK

{
  "success": true,
  "data": {
    "id": "inv_cl9a1b2c30000y",
    "invoiceNumber": "INV-2026-0042",
    "status": "OPEN",
    "total": 150000,
    "paymentUrl": "https://checkout.xtopay.co/invoice/inv_cl9a1b2c30000y",
    "createdAt": "2026-06-05T12:00:00Z"
  }
}

Void an Invoice

Void an open invoice to cancel billing collections.

DetailDescription
API Endpointhttps://api.xtopay.co/v1/invoices/:id/void
Request TypePOST
AuthenticationBasic Base64(clientId:clientSecret)
Required Scopepayments:write

Path Parameters

ParameterTypeRequiredDescription
:idStringYesUnique ID of the open invoice to void.

List Invoices

List invoices with status and customer filters.

DetailDescription
API Endpointhttps://api.xtopay.co/v1/invoices
Request TypeGET
AuthenticationBasic Base64(clientId:clientSecret)
Required Scopepayments:read

Query Parameters

ParameterTypeRequiredDescription
customerIdStringNoFilter by customer ID.
statusStringNoFilter by status: DRAFT, OPEN, PAID, VOID, UNCOLLECTIBLE.
limitIntegerNoLimit the results per page (default 20).
cursorStringNoPagination cursor.

How is this guide?

Edit this page on GitHub
Last updated on June 6, 2026

On this page