Create professional PDF invoices from a simple web request. Use your own template, sign every PDF with your own certificate, and send it to remote storage (S3, FTP, Zapier, email, webhook).
Run it on your own server, or use the hosted version.
Send the smallest valid payload to the hosted endpoint:
curl "https://invoice-as-a-service.cleverapps.io/api/invoice/generate" \
-X POST -H "content-type: application/json" \
-o invoice.pdf \
-d '{
"id": "42",
"currency": "€",
"lang": "en",
"date": 1520852472,
"due_date": 1521457272,
"items": [
{
"title": "Growth plan",
"price": 42,
"tax": 20
}
],
"customer": {
"summary": "John Doe",
"address_line_1": "1 Main Street"
},
"company": {
"summary": "Acme",
"address_line_1": "2 High Street"
}
}'The response is the PDF (201, application/pdf). Open invoice.pdf.
Every other property (items, taxes, logo, extra fields, destinations) is in the full API reference.
The hosted endpoint is run best effort, without an SLA. It receives your invoice data and any FTP or webhook credentials you put in the payload. Self-host when that matters.
Requirements: PHP 8.5, Composer, and these PHP extensions: dom, fileinfo, ftp, gd, libxml, mbstring, openssl.
composer install fails when one is missing, except gd, which dompdf needs to draw logos.
composer install
php artisan serveThen run the same request against http://localhost:8000/api/invoice/generate.
Optional features read their settings from environment variables. Copy .env.dist to .env and set the MAIL_* variables to enable email. See PDF signature for signing.
The PDF is always returned in the HTTP response. Add an object to the payload to also send it to:
- AWS S3, or any S3-compatible storage, through a presigned URL (
s3) - an FTP server (
ftp) - a webhook (
webhook) - an email, with the PDF attached, through your SMTP server (
email) - Zapier, through a "Catch hook" trigger, to reach Drive, Dropbox and others (
zapier)
It renders one invoice per request from the data you send. It stores no invoices, keeps no customers or invoice numbers, and computes no payments. Use an accounting tool for those.
- API reference: every property, destination option, instance-wide delivery settings, PDF metadata and PDF signature.
Issues and pull requests are welcome. Where to start:
- template:
resources/views/invoices/default.blade.php - controller and input validation:
app/Http/Controllers/InvoiceController.php - PDF build:
app/Helpers/PDF.php - file storage:
app/Helpers/Storage.php - instance-wide delivery settings:
config/delivery.phpandapp/Helpers/Delivery.php
Run the tests with vendor/bin/phpunit.
Generate a presigned S3 upload URL for testing:
aws configure
node ./scripts/presign-upload-url.js <region> <my-bucket> invoices/[email protected]Give a ⭐️ if this project helped you!
