Ponkan
Education

Automate Your Team Invoicing

Stop creating invoices manually. Learn how to use the Ponkan API to automate invoice generation, delivery, and tracking for your entire team.

SC

Sarah Chen

March 17, 2026

Automate Your Team Invoicing

Manually creating invoices every month is tedious. If your team bills multiple clients for recurring services, the repetitive work adds up fast — creating drafts, adding line items, sending payment links, chasing overdue invoices.

With the Ponkan API, you can automate the entire invoicing workflow. This guide shows you how to build a script that creates, finalizes, and tracks invoices for your whole team.

How invoicing works in Ponkan

Every invoice follows a lifecycle:

  • Draft — You're still building the invoice. Line items and amounts can be edited. The customer can't see it yet.
  • Open — The invoice is finalized and locked. A payment link is generated for the customer.
  • Paid — The customer has paid (or you've marked it as paid manually).
  • Void — The invoice was cancelled.

This state machine is enforced by the API. You can't edit an open invoice or finalize a paid one. This keeps your financial records clean and auditable.

Setting up

You'll need an API token with write permissions. Create one in Settings > API in your Ponkan dashboard.

For this guide, we'll use simple curl commands. In production, you'd wrap these in your language of choice — the example storefront in our repo shows how to do this with TypeScript.

Step 1: Create your customers

Before you can invoice someone, they need to exist as a customer:

curl -X POST https://yourapp.com/api/v1/customers \ -H "Authorization: Bearer YOUR_TOKEN" \ -d name="Acme Corp" \ -d email="[email protected]"

Do this once per client. Save the returned id — you'll use it for every invoice.

Step 2: Create a draft invoice

Create an invoice with line items in a single request:

curl -X POST https://yourapp.com/api/v1/invoices \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "customer_id": "CUSTOMER_UUID", "due_date": "2026-04-15", "memo": "March 2026 consulting services", "items": [ { "description": "Strategy consulting — 20 hours", "quantity": 20, "unit_price_cents": 15000 }, { "description": "Design review — 5 hours", "quantity": 5, "unit_price_cents": 12000 } ] }'

The invoice is created in draft status with an auto-generated invoice number (e.g., INV-0043). The total is calculated automatically from line items — in this case, $3,600.00.

Mixing products and freeform items

Line items can reference existing products from your catalog or be freeform descriptions. This is useful when you bill for both products and services:

{ "items": [ { "product_id": "PRODUCT_UUID", "quantity": 2, "unit_price_cents": 2500 }, { "description": "Custom integration work", "quantity": 8, "unit_price_cents": 20000 } ] }

Step 3: Review and edit

While the invoice is still a draft, you can update anything — line items, due date, memo, even the customer:

curl -X PATCH https://yourapp.com/api/v1/invoices/INVOICE_ID \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "memo": "Updated: March 2026 consulting + design services", "items": [ { "description": "Strategy consulting — 22 hours", "quantity": 22, "unit_price_cents": 15000 }, { "description": "Design review — 5 hours", "quantity": 5, "unit_price_cents": 12000 } ] }'

When you pass items, the entire line item list is replaced. This keeps things simple — no need to track individual item IDs.

Step 4: Finalize and send

When you're happy with the invoice, finalize it:

curl -X POST https://yourapp.com/api/v1/invoices/INVOICE_ID/finalize \ -H "Authorization: Bearer YOUR_TOKEN"

This does three things:

  1. Locks the invoice — no more edits allowed
  2. Sets issued_at to the current timestamp
  3. Generates a payment_token for the payment link

The payment link follows this pattern:

Share this link with your customer via email, Slack, or however your team communicates with clients. The customer clicks the link, sees the invoice details, and pays online.

Step 5: Track payment status

Check individual invoices

curl https://yourapp.com/api/v1/invoices/INVOICE_ID \ -H "Authorization: Bearer YOUR_TOKEN"

The status field tells you exactly where things stand: draft, open, paid, void, or overdue.

Find overdue invoices

Filter your invoice list to surface overdue invoices that need follow-up:

curl "https://yourapp.com/api/v1/invoices?status=overdue&sort=due_date" \ -H "Authorization: Bearer YOUR_TOKEN"

Mark as paid manually

If a client pays via bank transfer, check, or cash, mark it manually:

curl -X POST https://yourapp.com/api/v1/invoices/INVOICE_ID/mark_paid \ -H "Authorization: Bearer YOUR_TOKEN"

Automating the whole thing

Here's a simple bash script that creates and finalizes invoices for multiple clients at the start of each month:

#!/bin/bash TOKEN="your_access_token" BASE="https://yourapp.com/api/v1" MONTH=$(date +"%B %Y") DUE_DATE=$(date -v+30d +"%Y-%m-%d") # Client list: customer_id, description, hours, rate (cents) CLIENTS=( "uuid-acme:Strategy consulting:20:15000" "uuid-globex:Development support:40:12000" "uuid-initech:Design review:10:18000" ) for entry in "${CLIENTS[@]}"; do IFS=':' read -r CUST_ID DESC HOURS RATE <<< "$entry" # Create and finalize in one flow INVOICE=$(curl -s -X POST "$BASE/invoices" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"customer_id\": \"$CUST_ID\", \"due_date\": \"$DUE_DATE\", \"memo\": \"$MONTH services\", \"items\": [{ \"description\": \"$DESC — $HOURS hours\", \"quantity\": $HOURS, \"unit_price_cents\": $RATE }] }") INV_ID=$(echo "$INVOICE" | jq -r '.data.id') # Finalize to generate payment link curl -s -X POST "$BASE/invoices/$INV_ID/finalize" \ -H "Authorization: Bearer $TOKEN" > /dev/null echo "Invoiced $DESC: $INV_ID" done

Run this with a cron job on the 1st of each month and your invoicing is fully automated.

Voiding invoices

Made a mistake? Void an open invoice before the customer pays:

curl -X POST https://yourapp.com/api/v1/invoices/INVOICE_ID/void \ -H "Authorization: Bearer YOUR_TOKEN"

The payment link immediately stops working. You can then create a corrected invoice.

Building it into your workflow

The API makes it straightforward to integrate invoicing into whatever tools your team already uses:

  • Cron jobs — Generate monthly invoices automatically
  • Slack bots — Get notified when invoices are paid or go overdue
  • Project management tools — Create invoices when milestones are completed
  • Accounting software — Sync invoice data for bookkeeping

What's next

Now that your invoicing is automated, explore checkout links for one-off product sales, or learn how to build a full storefront with the Ponkan API.

Education