DEV Community

Forgelab Africa
Forgelab Africa

Posted on

Generate Professional PDF Invoices via REST API — JSON In, PDF Out

Building invoicing into your app is painful. You spend days wrestling with PDF generation libraries, template engines, multi-currency formatting, and email delivery — then repeat it for every project.

The Forgelab Invoice API handles all of it in one API call. Send JSON, get back a professional PDF invoice.

What it does

  • JSON in → professional PDF invoice out
  • Multiple templates (professional, minimal, modern)
  • Multi-currency support (USD, EUR, GBP, and more)
  • White-label option for agencies
  • Hosted URL + base64 download
  • Free tier: 5 invoices/month, no card required

Quick start with curl

curl -X POST https://api.forgelab.africa/v1/invoice/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "template": "professional",
    "currency": "USD",
    "from": {
      "name": "Acme Corp",
      "email": "billing@acme.com",
      "address": "123 Main St, New York, NY"
    },
    "to": {
      "name": "Jane Smith",
      "email": "jane@example.com"
    },
    "items": [
      { "description": "Web Development", "quantity": 1, "rate": 2500.00 },
      { "description": "Hosting (6 months)", "quantity": 6, "rate": 25.00 }
    ],
    "notes": "Payment due within 30 days."
  }'
Enter fullscreen mode Exit fullscreen mode

Response:

{
  "success": true,
  "invoice_id": "inv_abc123",
  "pdf_url": "https://api.forgelab.africa/v1/invoice/inv_abc123/pdf",
  "total": 2650.00,
  "currency": "USD"
}
Enter fullscreen mode Exit fullscreen mode

Node.js example

const res = await fetch("https://api.forgelab.africa/v1/invoice/generate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.FORGELAB_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    template: "professional",
    currency: "USD",
    from: { name: "Acme Corp", email: "billing@acme.com" },
    to: { name: "Jane Smith", email: "jane@example.com" },
    items: [
      { description: "Web Development", quantity: 1, rate: 2500 },
    ],
  }),
});

const { pdf_url, total } = await res.json();
console.log(`Invoice ready: ${pdf_url} — Total: $${total}`);
Enter fullscreen mode Exit fullscreen mode

Python example

import requests

response = requests.post(
    "https://api.forgelab.africa/v1/invoice/generate",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    json={
        "template": "professional",
        "currency": "USD",
        "from": {"name": "Acme Corp", "email": "billing@acme.com"},
        "to": {"name": "Jane Smith", "email": "jane@example.com"},
        "items": [
            {"description": "Consulting", "quantity": 10, "rate": 150},
        ],
    }
)

data = response.json()
print(f"Invoice URL: {data['pdf_url']}")
Enter fullscreen mode Exit fullscreen mode

PHP example

$response = file_get_contents("https://api.forgelab.africa/v1/invoice/generate", false,
  stream_context_create(["http" => [
    "method"  => "POST",
    "header"  => "Authorization: Bearer {$apiKey}\r\nContent-Type: application/json",
    "content" => json_encode([
      "template" => "professional",
      "currency" => "USD",
      "from" => ["name" => "Acme Corp", "email" => "billing@acme.com"],
      "to"   => ["name" => "Jane Smith", "email" => "jane@example.com"],
      "items" => [["description" => "Design", "quantity" => 1, "rate" => 800]],
    ]),
  ]])
);
$data = json_decode($response, true);
echo $data["pdf_url"];
Enter fullscreen mode Exit fullscreen mode

When to use it

  • SaaS apps that need automated billing documents for customers
  • Freelance tools for client invoicing without building from scratch
  • E-commerce VAT invoices and order receipts
  • Agencies building white-label invoicing products

Pricing

Plan Price Invoices/month
Free $0 5
Starter $5/mo 100
Pro $15/mo 1,000
Business $30/mo 10,000

No credit card required for the free tier.


Get your API key at forgelab.africa — docs, free tier, and full endpoint reference included.

Top comments (0)