make-bill/

Documentation

API Documentation

Generate PDF invoices and documents programmatically using our easy-to-use API.

Authentication

Authenticate your requests by including your API key in the Authorization header.

Example Header

Authorization: Bearer mk_live_xxxxxxxxxxxxxxxxxxxxxxxx

Generate PDF

POST/api/generate-pdf

The primary endpoint to generate PDFs. It supports two modes:

  • Template-based (Recommended): Use a saved template ID and provide dynamic data.
  • Raw Elements (Advanced): Provide full layout definitions and elements array.

1. Template-Based Generation

This is the simplest way. Design your template in the editor, bind data fields (e.g., invoice.total), and simply pass the data JSON.

Request Body
{
  "templateId": "your-template-uuid-here",
  "data": {
    "invoice": {
      "number": "INV-2024-001",
      "date": "2024-03-20",
      "total": "$1,250.00",
      "customer": {
        "name": "Acme Corp",
        "address": "123 Business Rd"
      }
    },
    "items": [
      { "name": "Web Development", "price": "$1,000.00" },
      { "name": "Hosting", "price": "$250.00" }
    ]
  }
}
cURL Example
curl -X POST https://make-bill.com/api/generate-pdf \
  -H "Authorization: Bearer mk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "your-template-uuid",
    "data": {
      "invoice": { "total": "$500" }
    }
  }'

2. Raw Elements Generation

For complete control without saving templates. You define every element's position and style in the request.

Request Body
{
  "page": {
    "width": 794,
    "height": 1123,
    "size": "A4",
    "orientation": "portrait",
    "margin": 20
  },
  "elements": [
    {
      "id": "1",
      "type": "text",
      "x": 50,
      "y": 50,
      "width": 200,
      "height": 30,
      "content": "Invoice #001",
      "fontSize": 24,
      "fontWeight": "bold",
      "align": "left"
    }
  ]
}

Response

Successful requests return a download URL for the generated PDF.

Success Response (200 OK)
{
  "success": true,
  "url": "https://storage.googleapis.com/.../invoice.pdf",
  "path": "generated/user_id/timestamp.pdf"
}