How to Automate Invoice Generation with a REST API

Published Feb 20, 2026 · Tutorial · 5 min read

Automate invoice creation in your app with a PDF invoice API. Generate professional invoices with line items, tax, logos. Python & JavaScript examples.

Why Automate Invoice Generation?

Manual invoice creation is one of the most common time sinks for freelancers, SaaS businesses, and e-commerce platforms. An invoice API eliminates the tedious parts:

How Invoice APIs Work

The workflow is simple:

  1. Send JSON data — company info, client details, line items, tax rates
  2. API processes — generates a professionally formatted PDF invoice
  3. Receive PDF — download the invoice file or get a download URL

No template design needed. No PDF libraries to manage. No font or layout issues to debug.

Generate Your First Invoice

cURL

curl -X POST "https://api.commandsector.in/api/invoice/generate?api_key=YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice_number": "INV-2026-001",
    "from": {
      "name": "Acme Corp",
      "address": "123 Main St, San Francisco, CA"
    },
    "to": {
      "name": "Client Inc",
      "address": "456 Oak Ave, New York, NY"
    },
    "items": [
      {"description": "Web Development", "quantity": 40, "unit_price": 150},
      {"description": "UI Design", "quantity": 20, "unit_price": 125}
    ],
    "tax_rate": 8.5,
    "notes": "Payment due within 30 days"
  }' --output invoice.pdf

Python

import requests

invoice_data = {
    "invoice_number": "INV-2026-001",
    "from": {"name": "Acme Corp", "address": "123 Main St, SF, CA"},
    "to": {"name": "Client Inc", "address": "456 Oak Ave, NY, NY"},
    "items": [
        {"description": "Web Development", "quantity": 40, "unit_price": 150},
        {"description": "UI Design", "quantity": 20, "unit_price": 125},
    ],
    "tax_rate": 8.5,
    "currency": "USD",
    "notes": "Payment due within 30 days"
}

response = requests.post(
    "https://api.commandsector.in/api/invoice/generate",
    params={"api_key": "YOUR_KEY"},
    json=invoice_data
)
with open("invoice.pdf", "wb") as f:
    f.write(response.content)
print("Invoice generated!")

JavaScript (Node.js)

const response = await fetch(
  "https://api.commandsector.in/api/invoice/generate?api_key=YOUR_KEY",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      invoice_number: "INV-2026-001",
      from: { name: "Acme Corp", address: "123 Main St" },
      to: { name: "Client Inc", address: "456 Oak Ave" },
      items: [
        { description: "Consulting", quantity: 10, unit_price: 200 }
      ],
      tax_rate: 10
    })
  }
);
const blob = await response.blob();
// Save or serve the PDF

Advanced: Logo, Discounts, Multiple Tax

Add Company Logo

{
  "logo_url": "https://yoursite.com/logo.png",
  "from": {"name": "Your Company", "address": "..."},
  "items": [...]
}

Discounts and Custom Currency

{
  "currency": "EUR",
  "discount": 10,
  "discount_type": "percentage",
  "items": [
    {"description": "Annual License", "quantity": 1, "unit_price": 999}
  ]
}

Use Cases

SaaS Billing

Trigger invoice generation from Stripe webhooks on each successful payment. Automatically email the PDF to customers.

Freelancer Automation

Track hours in a spreadsheet, then generate monthly invoices with a simple script. Include your logo and payment terms.

E-commerce Orders

Generate invoices for each order. Include itemized products, shipping costs, and tax calculations automatically.

Start Generating Invoices

Professional PDF invoices via API. Free tier: 100 invoices/day. No credit card.

Get Free API Key

Quick Start

Get your free API key and start making requests in minutes.

curl "http://147.224.212.116/api/..." \
  -H "X-API-Key: YOUR_API_KEY"

Start Using This API Today

Get a free API key with 100 requests/day. No credit card required.

Get Free API Key