BuildInvoice API

Generate professional PDF invoices from structured JSON with a single API call. No signup forms, no dashboard — just a clean REST endpoint.

⚡ Quick Start — Invoice in 30 Seconds

1. Get an API key

curl -X POST https://buildinvoice.co/api/v1/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'

2. Generate your first invoice

curl -X POST https://buildinvoice.co/api/v1/generate \
  -H "Content-Type: application/json" \
  -H "X-API-Key: binv_YOUR_KEY_HERE" \
  -d '{
    "from": { "name": "Acme Corp" },
    "to": { "name": "Jane Smith" },
    "items": [
      { "description": "Website Design", "quantity": 1, "rate": 2500 }
    ]
  }'

3. Response

{
  "success": true,
  "pdf": "JVBERi0xLjM...",
  "pages": 1,
  "sizeBytes": 18432,
  "invoice_number": null,
  "totals": {
    "subtotal": 2500.00,
    "tax": 0,
    "discount": 0,
    "total": 2500.00
  },
  "watermark": true,
  "template": "modern"
}

Decode the pdf field from base64 to get your PDF file. That's it.

💡 Tip: Only from.name, to.name, and at least one item are required. Everything else is optional with sensible defaults.

📡 Endpoints

POST /api/v1/generate

Generate a PDF invoice from structured JSON data.

POST /api/v1/register

Get a free API key. Send {"email": "you@example.com"}.

GET /api/v1/usage

Check your current usage and remaining quota.

GET /api/v1/health

Health check — returns service status.

📋 Request Schema — /generate

from (required)

FieldTypeRequiredDescription
namestringYour company or name
addressstringStreet address, city, state
emailstringContact email
phonestringPhone number
logostringURL to logo image (Starter+ only)

to (required)

FieldTypeRequiredDescription
namestringClient / recipient name
addressstringClient address
emailstringClient email

items (required)

FieldTypeRequiredDescription
descriptionstringLine item description
quantitynumberQuantity (default: 1)
ratenumberUnit price

invoice (optional)

FieldTypeDefaultDescription
numberstring"INV-001"Invoice number
datestringInvoice date (YYYY-MM-DD)
due_datestringPayment due date
currencystringCurrency name (display only)

Other fields

FieldTypeDefaultDescription
tax_ratenumber0Tax percentage (e.g., 8.25 for 8.25%)
discountnumber0Flat discount amount in dollars
notesstringNotes shown at bottom of invoice
termsstringTerms & conditions text

options (optional)

FieldTypeDefaultDescription
templatestring"modern"Invoice template style
colorstring"#4F46E5"Accent color (hex)
pageSizestring"letter""letter", "a4", "a3", "legal"
currency_symbolstring"$"Prefix for monetary values

📦 Response Format

{
  "success": true,
  "pdf": "JVBERi0xLjM...",       // base64-encoded PDF
  "pages": 1,
  "sizeBytes": 18432,
  "invoice_number": "INV-001",
  "totals": {
    "subtotal": 2669.99,
    "tax": 220.27,
    "discount": 0,
    "total": 2890.26
  },
  "watermark": true,              // true on Free tier
  "template": "modern",
  "usage": {
    "used": 1,
    "limit": 50,
    "remaining": 49
  }
}

🔑 Authentication

All endpoints except /register and /health require an API key. Pass it via:

X-API-Key: binv_YOUR_KEY_HERE
// or
Authorization: Bearer binv_YOUR_KEY_HERE

⚠️ Error Responses

StatusMeaningExample
400Bad RequestMissing from.name, invalid items array
401UnauthorizedMissing or invalid API key
403ForbiddenFeature requires higher tier (e.g., logo)
429Rate LimitedQuota exceeded or too many requests/min
500Server ErrorPDF generation failed

💎 Pricing

Free

$0 /mo
  • 50 invoices/month
  • Watermark on PDF
  • 5 req/min

Pro

$29 /mo
  • 5,000 invoices/month
  • No watermark
  • Logo embedding
  • 150 req/min

Business

$79 /mo
  • 25,000 invoices/month
  • No watermark
  • Logo embedding
  • 500 req/min

💻 Code Examples

JavaScript (Node.js)

const res = await fetch("https://buildinvoice.co/api/v1/generate", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "binv_YOUR_KEY"
  },
  body: JSON.stringify({
    from: { name: "Acme Corp", email: "billing@acme.com" },
    to: { name: "Jane Smith" },
    items: [
      { description: "Consulting (10 hrs)", quantity: 10, rate: 150 },
      { description: "Travel expenses", quantity: 1, rate: 85 }
    ],
    tax_rate: 8.25,
    notes: "Payment due within 30 days."
  })
});

const { pdf } = await res.json();
// pdf is a base64 string — decode and save
fs.writeFileSync("invoice.pdf", Buffer.from(pdf, "base64"));

Python

import requests, base64

resp = requests.post(
    "https://buildinvoice.co/api/v1/generate",
    headers={"X-API-Key": "binv_YOUR_KEY"},
    json={
        "from": {"name": "Acme Corp"},
        "to": {"name": "Jane Smith"},
        "items": [
            {"description": "Website Design", "quantity": 1, "rate": 2500}
        ],
        "tax_rate": 8.25
    }
)

pdf_bytes = base64.b64decode(resp.json()["pdf"])
with open("invoice.pdf", "wb") as f:
    f.write(pdf_bytes)

PHP

$response = json_decode(file_get_contents(
    "https://buildinvoice.co/api/v1/generate",
    false,
    stream_context_create([
        "http" => [
            "method" => "POST",
            "header" => "Content-Type: application/json\r\nX-API-Key: binv_YOUR_KEY",
            "content" => json_encode([
                "from" => ["name" => "Acme Corp"],
                "to" => ["name" => "Jane Smith"],
                "items" => [["description" => "Service", "quantity" => 1, "rate" => 500]]
            ])
        ]
    ])
), true);

file_put_contents("invoice.pdf", base64_decode($response["pdf"]));