Search the docs

Pages and API endpoints

Developer dashboard
Docs/Guides/Create Your First Invoice

Create Your First Invoice

This guide walks through creating a customer, creating an invoice, and checking its status — all via the API.

1. Create a Customer

Every invoice needs a customer. Create one first:

Create Customer
curl -X POST https://api.syncbooksapp.com/api/v1/customers \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Ama Trading", "email": "ama@trading.com", "phone": "+233551234567" }'

Save the _id from the response — you'll need it next.

2. Create the Invoice

Create Invoice
curl -X POST https://api.syncbooksapp.com/api/v1/invoices \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "CUSTOMER_ID_FROM_STEP_1",
    "invoiceDate": "2026-06-06",
    "dueDate": "2026-07-06",
    "lineItems": [
      { "description": "Website Design", "quantity": 1, "rate": 5000 },
      { "description": "Hosting (3 months)", "quantity": 3, "rate": 150, "taxRate": 15 }
    ],
    "notes": "Thank you for your business!"
  }'

The invoice is created as draft. The response includes the auto-generated invoice number and calculated totals.

3. Send the Invoice

To send it to the customer (changes status to "sent" and posts to GL):

Update Status
curl -X PUT https://api.syncbooksapp.com/api/v1/invoices/INVOICE_ID \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "sent" }'

4. Record Payment

When the customer pays:

Record Payment
curl -X POST https://api.syncbooksapp.com/api/v1/payments \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "customerId": "CUSTOMER_ID",
    "invoiceId": "INVOICE_ID",
    "amount": 5517.50,
    "paymentMethod": "mobile_money",
    "paymentDate": "2026-06-10",
    "reference": "MoMo-TXN-789456"
  }'

The invoice status auto-updates to "paid" when the full amount is received.

What Happened Behind the Scenes

  • Invoice sent → GL entry: DR Accounts Receivable, CR Revenue
  • Payment recorded → GL entry: DR Cash/Bank, CR Accounts Receivable
  • Invoice balance updated (paidAmount = totalAmount → status = "paid")
  • Financial reports (P&L, Balance Sheet) reflect the transaction immediately