invoice API for Python
Invoice API for Python
Create an invoice with the Python standard library or requests. Check the status code before you read the JSON.
Base URL https://invoicetxt.com Auth Authorization: Bearer itxt_live_…
POST/v1/invoices
Create an invoice
Use requests if you already depend on it. The example below uses only the standard library so a small script does not need another package. The key stays in the environment.
import json, os, urllib.request
body = json.dumps({
'client': 'Northside Plumbing',
'due': 'net 14',
'currency': 'USD',
'tax_rate': 0,
'items': [
{'description': 'Boiler service', 'quantity': 3, 'rate': 65},
{'description': 'Replacement valve', 'quantity': 1, 'rate': 48}
]
}).encode()
req = urllib.request.Request(
'https://invoicetxt.com/v1/invoices',
data=body,
headers={'Authorization': 'Bearer ' + os.environ['INVOICETXT_API_KEY'], 'Content-Type': 'application/json'}
)
with urllib.request.urlopen(req) as res:
invoice = json.load(res)
print(invoice['url'])One line of text
If your team already writes jobs as a single line, send that line in text and skip items. InvoiceTXT splits the client, the prices and the due terms.
body = json.dumps({'text': 'Northside Plumbing, 3 hrs boiler service @ 65, replacement valve 48, due net 14'}).encode()