An API for printing invoices

SpotInvoice is our simple invoicing tool: visual invoice design lets you see exactly what you'll end up with, and PDF printing gets you a perfect invoice every time. Try Spot Invoice now

When we built Spot Invoice we initially focused on the visual design aspects: we think it makes everything better to see your work develop and know what the end result will look like. For 90% of the users creating invoices this works just fine: you're manually adding a few items to one or more invoices each day, so using the visual input interface works just fine.

For the other 10%, how would things work? Perhaps there is an automated process generating the invoices, or sales coming in from a payment provider like Stripe that performs the truly important work (of collecting your money) but doesn't provide any nice, clean way to get YOUR clients print-ready invoices they can use for their records. We actually saw a couple of people explicitly asking for a solution to the second use case.

So we built a solution. Spot Invoice comes with a really simple REST-style API: you provide a couple of request parameters with the invoice details, and we give you back a PDF file with the print-ready invoice. In its simplest possible form:

curl -v https://www.spotinvoice.com/api/print -u "<account id>:<account secret>" -H "Content-Type: application/x-www-form-urlencoded" -d "header=IdeaSynthesis LLC" -d "from.name=My Name" -d "to.name=Customer Name" -d "item.1.price=5000" -d "item.1.description=New server implementation" -d "item.2.price=35" -d "item.2.description=Graphic design" -d "item.2.quantity=40" -d "item.2.units=hours" -o "invoice.pdf"

This uses the curl command-line HTTP client to print out a PDF invoice (saved to invoice.pdf) with a header set to IdeaSynthesis LLC, the sender name set to My Name, the invoice recipient name set to Customer Name, and 2 line items, a $5000 line item for New server implementation and 40 hours of Graphic design at $35 an hour. The saved invoice will be exactly identical to an invoice that would be printed from the visual design interface: internally we consume the same API endpoint to print invoices created through https://www.spotinvoice.com.

There are many other parameters that can be used to provide a much more fully formed invoice: see the API documentation for more details as well as code samples showing how to use the API using a number of programming languages.

A couple of details: we use HTTP basic authentication over SSL to ensure that all customer data is secure. We also use a unique account identifier and secret to authenticate, NOT the account username/email and password: given that the user may be authenticating using an third-party authentication provider, they may NOT even have a password. This also allows the API authentication to be reset in an independent fashion and avoids the problem of embedding primary usernames/passwords in web applications and other scripts that may be consuming the API.

As a bonus, if you use Stripe for recurring billing, you can connect Spot Invoice to your Stripe account using the Stripe Connect interface and print out any Stripe invoices with a single line!

Invoice printing using our API is available right now to all users during the initial 14-day trial period or on a Premium plan: take a look at the documentation and see if simple PDF invoice generation can be useful to you. Let us know if there are any questions we can answer.