How to Generate PDF Invoices with an API

A complete guide for developers who need to generate invoices programmatically

If you're building a SaaS, marketplace, or freelance platform, you'll eventually need to generate invoices. Most developers face the same choice: spend days wrestling with PDF libraries, or use an API that handles it in one HTTP call.

This guide covers everything you need to know about generating PDF invoices programmatically, with working code examples you can copy and use today.

Why Use an Invoice API?

Building invoice PDF generation from scratch means dealing with:

An invoice API like DocuMint lets you skip all of that. Send JSON, get a PDF. Your invoicing is someone else's core product — which means it's always improving.

Quick Start: Generate Your First Invoice

Here's the simplest possible invoice generation call:

# Generate an invoice with curl
curl -X POST https://documint.anethoth.com/api/v1/invoice \
  -H "Authorization: Bearer dm_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"description": "Web Development", "quantity": 40, "unit_price": 150}
    ],
    "currency": "USD",
    "from": {"name": "Your Company", "email": "[email protected]"},
    "to": {"name": "Client Corp", "email": "[email protected]"}
  }' \
  --output invoice.pdf

That's it. One HTTP call, one professional PDF. No libraries to install, no templates to maintain.

Step-by-Step Integration

1. Get Your API Key

Sign up for a free account — no credit card required. You get 10 invoices per month on the free plan.

curl -X POST https://documint.anethoth.com/api/v1/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'

# Response:
# {"api_key": "dm_abc123...", "plan": "free", "monthly_limit": 10}

2. Generate an Invoice (Python)

import requests

response = requests.post(
    "https://documint.anethoth.com/api/v1/invoice",
    headers={"Authorization": "Bearer dm_your_api_key"},
    json={
        "invoice_number": "INV-001",
        "date": "2026-04-11",
        "due_date": "2026-05-11",
        "currency": "USD",
        "from": {
            "name": "Acme Corp",
            "address": "123 Main St, San Francisco, CA",
            "email": "[email protected]"
        },
        "to": {
            "name": "Client Inc",
            "address": "456 Oak Ave, New York, NY",
            "email": "[email protected]"
        },
        "items": [
            {"description": "Frontend Development", "quantity": 40, "unit_price": 150},
            {"description": "API Integration", "quantity": 20, "unit_price": 175},
            {"description": "Code Review", "quantity": 8, "unit_price": 200}
        ],
        "tax_rate": 8.5,
        "notes": "Payment due within 30 days. Thank you for your business!"
    }
)

with open("invoice.pdf", "wb") as f:
    f.write(response.content)

3. Generate an Invoice (Node.js)

const fs = require('fs');

const response = await fetch('https://documint.anethoth.com/api/v1/invoice', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer dm_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    items: [
      { description: 'Monthly Retainer', quantity: 1, unit_price: 5000 },
      { description: 'Overage Hours', quantity: 12, unit_price: 175 }
    ],
    currency: 'USD',
    from: { name: 'Your Agency' },
    to: { name: 'Client Corp' }
  })
});

const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync('invoice.pdf', buffer);

Try It Free — No Credit Card Required

Generate up to 10 invoices per month on the free plan. Upgrade anytime.

Get Your API Key

Common Use Cases

SaaS Billing

Generate monthly invoices for your subscribers automatically. Trigger invoice generation from your billing webhook (Stripe, Paddle, etc.) and email the PDF to your customer.

Freelancer Tools

Build time-tracking or project management tools that generate invoices from logged hours. Your users track time, your app generates the invoice.

Marketplace Payouts

Generate settlement invoices for marketplace sellers. Each transaction becomes a line item, and the payout summary becomes a professional invoice.

E-commerce Order Confirmations

Convert order data into PDF invoices for record-keeping, tax compliance, or customer requests.

API Features

Pricing

DocuMint offers simple, transparent pricing:

Every plan includes the same API features. No hidden fees, no per-invoice charges beyond your plan limit.

Start Generating Invoices in 30 Seconds

Sign up, get your API key, and generate your first invoice — all with a single curl command.

Get Started Free