Skip to main content

Create Invoice

Generates a new invoice for a customer.

Authentication required (User JWT).

POST /api/merchants/:merchantId/invoices

Path Parameters​

ParameterTypeDescription
merchantIdStringThe ID of the parent merchant.

Request Body​

{
"customerEmail": "customer@example.com",
"customerName": "Jane Doe", // Optional
"customerNote": "Please reference PO #123.", // Optional note displayed to customer
"lineItems": [
{
"description": "Web Development Service",
"amount": 15000000, // 150,000 NGN in kobo
"quantity": 1
},
{
"description": "Hosting Fee (Monthly)",
"amount": 500000, // 5,000 NGN in kobo
"quantity": 1
}
],
"dueDate": "2023-11-30", // Optional: YYYY-MM-DD format
"merchantNote": "Follow up if not paid by EOM.", // Optional: Internal note
"status": "DRAFT" // Optional: Defaults to DRAFT. Can be SENT etc. if logic allows.
}
FieldTypeRequiredDescription
customerEmailStringYesEmail address of the customer receiving the invoice.
customerNameStringNoCustomer's name.
customerNoteStringNoNote to display to the customer on the invoice.
lineItemsArray of LineItemDto objectsYesArray of items/services being invoiced. Must contain at least one.
lineItems[].descriptionStringYesDescription of the line item.
lineItems[].amountIntegerYesPrice per unit in kobo/cents.
lineItems[].quantityNumberYesQuantity of the item.
dueDateString (YYYY-MM-DD)NoDate the invoice payment is due.
merchantNoteStringNoInternal note for the merchant, not shown to the customer.
statusString (InvoiceStatus)NoInitial status (e.g., DRAFT, SENT). Defaults to DRAFT.

Response 201 Created​

Returns the details of the newly created invoice.

{
"message": "Invoice created successfully",
"invoice": {
"id": "uuid-invoice-abc",
"merchantId": "uuid-merchant-456",
"invoiceNumber": "INV-MER-00001", // Example generated number
"amount": 15500000, // Total calculated amount in kobo
"currency": "NGN",
"status": "DRAFT",
"customerEmail": "customer@example.com",
"customerName": "Jane Doe",
"customerNote": "Please reference PO #123.",
"merchantNote": "Follow up if not paid by EOM.",
"lineItems": [
{ "description": "Web Development Service", "amount": 15000000, "quantity": 1 },
{ "description": "Hosting Fee (Monthly)", "amount": 500000, "quantity": 1 }
],
"dueDate": "2023-11-30T00:00:00.000Z",
"paidAt": null,
"sentAt": null,
"createdAt": "2023-10-27T11:30:00.000Z",
"updatedAt": "2023-10-27T11:30:00.000Z"
// Excludes the nested 'merchant' object
}
}

Errors​

  • 400 Bad Request: Validation failed (e.g., missing fields, invalid line items).
  • 401 Unauthorized: Invalid or missing JWT.
  • 404 Not Found: Merchant not found.
  • 500 Internal Server Error